Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/freearhey/dayjs-twitter
A Twitter-like date formatter for day.js
https://github.com/freearhey/dayjs-twitter
dayjs formatter twitter
Last synced: 24 days ago
JSON representation
A Twitter-like date formatter for day.js
- Host: GitHub
- URL: https://github.com/freearhey/dayjs-twitter
- Owner: freearhey
- License: mit
- Created: 2019-08-29T15:22:48.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2021-08-25T23:12:24.000Z (about 3 years ago)
- Last Synced: 2024-04-29T12:20:22.410Z (6 months ago)
- Topics: dayjs, formatter, twitter
- Language: JavaScript
- Size: 102 KB
- Stars: 3
- Watchers: 3
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# dayjs-twitter [![Build Status](https://app.travis-ci.com/freearhey/dayjs-twitter.svg?branch=master)](https://app.travis-ci.com/freearhey/dayjs-twitter)
dayjs-twitter is a plugin to [day.js](https://github.com/iamkun/dayjs) that formats dates like Twitter
## Installation
### NPM
```sh
npm install dayjs-twitter
``````js
import dayjs from 'dayjs'
import dayjsTwitter from 'dayjs-twitter'dayjs.extend(dayjsTwitter)
```### CDN
```html
dayjs.extend(dayjsTwitter.default)
```
## Usage
```js
dayjs().twitter() // => 'Now'
dayjs().subtract(10, 'second').twitter() // => '10s'
dayjs().subtract(1, 'minute').twitter() // => '1m'
dayjs().subtract(23, 'hour').twitter() // => '23h'
dayjs().subtract(1, 'day').twitter() // => 'Aug 28'
dayjs().subtract(1, 'year').twitter() // => 'Aug 28, 2018'
```## Localization
```js
dayjs.locale('es')dayjs().twitter() // => 'Ahora'
dayjs().subtract(10, 'second').twitter() // => '10s'
dayjs().subtract(1, 'minute').twitter() // => '1min'
dayjs().subtract(23, 'hour').twitter() // => '23h'
dayjs().subtract(1, 'day').twitter() // => '28 aug.'
dayjs().subtract(1, 'year').twitter() // => '28 aug. 2018'
```The list of all currently available translations can be found in the [src/locale](src/locale).
## Testing
```sh
npm test
```## Contribution
If you find a bug or want to contribute to the code or documentation, you can help by submitting an [issue](https://github.com/freearhey/dayjs-twitter/issues) or a [pull request](https://github.com/freearhey/dayjs-twitter/pulls).
## License
[MIT](https://github.com/freearhey/dayjs-twitter/blob/master/LICENSE)