-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: remove old github docs, redirect to day.js.org
- Loading branch information
Showing
24 changed files
with
44 additions
and
7,549 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,165 +1,3 @@ | ||
### Notice | ||
### Note | ||
|
||
The document here **no longer** updates. | ||
|
||
Please visit our website [https://day.js.org](https://day.js.org/docs/en/i18n/i18n) for more information. | ||
|
||
------------- | ||
|
||
<br /> | ||
<br /> | ||
<br /> | ||
<br /> | ||
<br /> | ||
<br /> | ||
<br /> | ||
<br /> | ||
<br /> | ||
<br /> | ||
|
||
## Internationalization | ||
|
||
Day.js has great support for internationalization. | ||
|
||
But none of them will be included in your build unless you use that. | ||
|
||
By default, Day.js comes with English (United States) locale. | ||
|
||
You can load multiple locales and switch between them easily. | ||
|
||
[List of supported locales](../../src/locale) | ||
|
||
You are super welcome to add a locale by opening a pull request :+1: | ||
|
||
## API | ||
|
||
#### Changing locale globally | ||
|
||
- Returns locale string | ||
|
||
```js | ||
import 'dayjs/locale/es' | ||
import de from 'dayjs/locale/de' | ||
dayjs.locale('es') // use loaded locale globally | ||
dayjs.locale('de-german', de) // use locale and update default name string | ||
const customizedLocaleObject = { ... } // More details can be found in Customize section below. | ||
dayjs.locale(customizedLocaleObject) // use customize locale | ||
dayjs.locale('en') // switch back to default English locale globally | ||
``` | ||
|
||
- Changing the global locale doesn't affect existing instances. | ||
|
||
#### Changing locales locally | ||
|
||
- Returns a new `Dayjs` object by switching to new locale. | ||
|
||
Exactly the same as `dayjs#locale`, but only use locale in a specific instance. | ||
|
||
```js | ||
import 'dayjs/locale/es' | ||
dayjs() | ||
.locale('es') | ||
.format() // use loaded locale locally | ||
dayjs('2018-4-28', { locale: 'es' }) // through constructor | ||
``` | ||
|
||
## Installation | ||
|
||
- Via NPM: | ||
|
||
```javascript | ||
import 'dayjs/locale/es' // load on demand | ||
// require('dayjs/locale/es') // CommonJS | ||
// import locale_es from 'dayjs/locale/es' -> load and get locale_es locale object | ||
|
||
dayjs.locale('es') // use locale globally | ||
dayjs() | ||
.locale('es') | ||
.format() // use locale in a specific instance | ||
``` | ||
|
||
- Via CDN: | ||
|
||
```html | ||
<script src="https://unpkg.com/dayjs"></script> | ||
<!-- Load locale as window.dayjs_locale_NAME --> | ||
<script src="https://unpkg.com/dayjs/locale/zh-cn"></script> | ||
<script> | ||
dayjs.locale('zh-cn') | ||
dayjs() | ||
.locale('zh-cn') | ||
.format() | ||
// get locale object | ||
const customLocale = window.dayjs_locale_zh_cn // zh-cn -> zh_cn | ||
</script> | ||
``` | ||
|
||
## Customize | ||
|
||
You could update locale config via plugin [`UpdateLocale`](./Plugin.md#updateLocale) | ||
|
||
You could also create your own locale. | ||
|
||
Feel free to open a pull request to share your locale. | ||
|
||
Template of a Day.js locale Object. | ||
|
||
```javascript | ||
const localeObject = { | ||
name: 'es', // name String | ||
weekdays: 'Domingo_Lunes ...'.split('_'), // weekdays Array | ||
weekdaysShort: 'Sun_M'.split('_'), // OPTIONAL, short weekdays Array, use first three letters if not provided | ||
weekdaysMin: 'Su_Mo'.split('_'), // OPTIONAL, min weekdays Array, use first two letters if not provided | ||
weekStart: 1, // OPTIONAL, set the start of a week. If the value is 1, Monday will be the start of week instead of Sunday。 | ||
yearStart: 4, // OPTIONAL, the week that contains Jan 4th is the first week of the year. | ||
months: 'Enero_Febrero ... '.split('_'), // months Array | ||
monthsShort: 'Jan_F'.split('_'), // OPTIONAL, short months Array, use first three letters if not provided | ||
ordinal: n => `${n}º`, // ordinal Function (number) => return number + output | ||
formats: { | ||
// abbreviated format options allowing localization | ||
LTS: 'h:mm:ss A', | ||
LT: 'h:mm A', | ||
L: 'MM/DD/YYYY', | ||
LL: 'MMMM D, YYYY', | ||
LLL: 'MMMM D, YYYY h:mm A', | ||
LLLL: 'dddd, MMMM D, YYYY h:mm A', | ||
// lowercase/short, optional formats for localization | ||
l: 'D/M/YYYY', | ||
ll: 'D MMM, YYYY', | ||
lll: 'D MMM, YYYY h:mm A', | ||
llll: 'ddd, MMM D, YYYY h:mm A' | ||
}, | ||
relativeTime: { | ||
// relative time format strings, keep %s %d as the same | ||
future: 'in %s', // e.g. in 2 hours, %s been replaced with 2hours | ||
past: '%s ago', | ||
s: 'a few seconds', | ||
m: 'a minute', | ||
mm: '%d minutes', | ||
h: 'an hour', | ||
hh: '%d hours', // e.g. 2 hours, %d been replaced with 2 | ||
d: 'a day', | ||
dd: '%d days', | ||
M: 'a month', | ||
MM: '%d months', | ||
y: 'a year', | ||
yy: '%d years' | ||
}, | ||
meridiem: (hour, minute, isLowercase) => { | ||
// OPTIONAL, AM/PM | ||
return hour > 12 ? 'PM' : 'AM' | ||
} | ||
} | ||
``` | ||
|
||
Template of a Day.js locale file. | ||
|
||
```javascript | ||
import dayjs from 'dayjs' | ||
|
||
const locale = { ... } // Your Day.js locale Object. | ||
|
||
dayjs.locale(locale, null, true) // load locale for later use | ||
|
||
export default locale | ||
``` | ||
The documents are moved to [https://day.js.org](https://day.js.org). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,49 +1,3 @@ | ||
### Notice | ||
### Note | ||
|
||
The document here **no longer** updates. | ||
|
||
Please visit our website [https://day.js.org](https://day.js.org/docs/en/installation/installation) for more information. | ||
|
||
------------- | ||
|
||
<br /> | ||
<br /> | ||
<br /> | ||
<br /> | ||
<br /> | ||
<br /> | ||
<br /> | ||
<br /> | ||
<br /> | ||
<br /> | ||
|
||
## Installation Guide | ||
|
||
You have multiple ways of getting Day.js: | ||
|
||
- Via NPM: | ||
|
||
```console | ||
npm install dayjs --save | ||
``` | ||
|
||
```js | ||
import dayjs from 'dayjs' | ||
// Or CommonJS | ||
// var dayjs = require('dayjs'); | ||
dayjs().format() | ||
``` | ||
|
||
- Via CDN: | ||
|
||
```html | ||
<!-- Latest compiled and minified JavaScript --> | ||
<script src="https://unpkg.com/dayjs"></script> | ||
<script> | ||
dayjs().format() | ||
</script> | ||
``` | ||
|
||
- Via download and self-hosting: | ||
|
||
Just download the latest version of Day.js at [https://unpkg.com/dayjs/](https://unpkg.com/dayjs/) | ||
The documents are moved to [https://day.js.org](https://day.js.org). |
Oops, something went wrong.