Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/porsager/datie
Small template string based date formatter for the browser and Node.js.
https://github.com/porsager/datie
date formatter
Last synced: 2 days ago
JSON representation
Small template string based date formatter for the browser and Node.js.
- Host: GitHub
- URL: https://github.com/porsager/datie
- Owner: porsager
- License: wtfpl
- Created: 2020-05-13T08:44:17.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2024-05-01T19:34:03.000Z (6 months ago)
- Last Synced: 2024-10-27T18:22:40.802Z (7 days ago)
- Topics: date, formatter
- Language: JavaScript
- Size: 89.8 KB
- Stars: 13
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 🗓 Datie
> Small template string based date formatter for the browser and Node.js.
Follows https://www.unicode.org/reports/tr35/tr35-dates.html#Date_Field_Symbol_Table with the inclusion of `o` suffix to enable eg. `1st, 2nd` etc.
## Usage
Datie takes the format as a tagged template function and then returns a function which accepts the date or a `new Date` compatible string.
```js
import datie from 'datie'const string = "2020-05-13T08:34:30.911Z"
const date = new Date(string)datie`d/M-y hh:mm`(string) // 13/5-2020 08:34
// or
datie`d/M-y hh:mm`(date) // 13/5-2020 08:34
```