diff options
author | eug-vs <eug-vs@keemail.me> | 2020-10-09 20:51:00 +0300 |
---|---|---|
committer | eug-vs <eug-vs@keemail.me> | 2020-10-09 20:51:00 +0300 |
commit | 7605be6c77393ed98e179c27f3bc3915afb95f5c (patch) | |
tree | e18fb51338a2efbfd521456e4d77184e43fc891f /src/components/DateString/DateString.tsx | |
parent | fcaddcd6ad8607d05279acdb87675de6180ac1cb (diff) | |
download | which-ui-7605be6c77393ed98e179c27f3bc3915afb95f5c.tar.gz |
feat: create DateString component
Diffstat (limited to 'src/components/DateString/DateString.tsx')
-rw-r--r-- | src/components/DateString/DateString.tsx | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/components/DateString/DateString.tsx b/src/components/DateString/DateString.tsx new file mode 100644 index 0000000..e31b52e --- /dev/null +++ b/src/components/DateString/DateString.tsx @@ -0,0 +1,22 @@ +import React from 'react'; + +interface PropTypes { + value: Date | string; +} + +const DATE_FORMAT = { + month: 'long', + day: 'numeric', + year: 'numeric', + hour: '2-digit', + minute: '2-digit' +}; + +const DateString: React.FC<PropTypes> = ({ value }) => { + const date = new Date(value); + const formatted = date.toLocaleString('default', DATE_FORMAT); + + return <>{formatted}</>; +}; + +export default DateString; |