Skip to content

Commit

Permalink
Merge pull request #545 from iamkun/dev
Browse files Browse the repository at this point in the history
D2M
  • Loading branch information
iamkun authored Apr 2, 2019
2 parents be6b891 + 6a297b7 commit 534d51c
Show file tree
Hide file tree
Showing 121 changed files with 2,334 additions and 142 deletions.
55 changes: 37 additions & 18 deletions docs/en/API-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@ The `Dayjs` object is immutable, that is, all API operations that change the `Da
- [Minute `.minute()`](#minute-minute)
- [Second `.second()`](#second-second)
- [Millisecond `.millisecond()`](#millisecond-millisecond)
- [Set `.set(unit: string, value: number)`](#set-setunit-string-value-number)
- [Get `.get(unit: string)`](#get-getunit-string)
- [List of all available units](#list-of-all-available-units)
- [Set `.set(unit: string, value: number)`](#set-setunit-string-value-number)
- [Manipulating](#manipulating)
- [Add `.add(value: number, unit: string)`](#add-addvalue-number-unit-string)
- [Subtract `.subtract(value: number, unit: string)`](#subtract-subtractvalue-number-unit-string)
Expand All @@ -49,15 +50,6 @@ The `Dayjs` object is immutable, that is, all API operations that change the `Da
- [Is a Dayjs `.isDayjs()`](#is-a-dayjs-isdayjscompared-any)
- [UTC](#utc)
- [Plugin APIs](#plugin-apis)
- [RelativeTime](#relativetime)
- [IsLeapYear](#isleapyear)
- [WeekOfYear](#weekofyear)
- [IsSameOrAfter](#issameorafter)
- [IsSameOrBefore](#issameorbefore)
- [IsBetween](#isbetween)
- [QuarterOfYear](#quarterofyear)
- [ToArray](#toarray)
- [ToObject](#toobject)

## Parsing

Expand Down Expand Up @@ -195,14 +187,13 @@ dayjs().millisecond()
dayjs().millisecond(1)
```

### Set `.set(unit: string, value: number)`
### Get `.get(unit: string)`

Returns a `Dayjs` with the applied changes.
Returns a `number` with information getting from `Dayjs` object

```js
dayjs().set('date', 1)
dayjs().set('month', 3) // April
dayjs().set('second', 30)
dayjs().get('month') // start 0
dayjs().get('day')
```

#### List of all available units
Expand All @@ -211,16 +202,26 @@ dayjs().set('second', 30)
| ------------- | --------- | ---------------------------------------- |
| `date` | | Date of Month |
| `day` | `d` | Day of Week (Sunday as 0, Saturday as 6) |
| `month` | `M` | Month |
| `month` | `M` | Month (January as 0, December as 11) |
| `year` | `y` | Year |
| `hour` | `h` | Hour |
| `minute` | `m` | Minute |
| `second` | `s` | Second |
| `millisecond` | `ms` | Millisecond |

### Set `.set(unit: string, value: number)`

Returns a `Dayjs` with the applied changes.

```js
dayjs().set('date', 1)
dayjs().set('month', 3) // April
dayjs().set('second', 30)
```

## Manipulating

`Dayjs` objects can be manipulated in many ways.
`Dayjs` object can be manipulated in many ways.

```js
dayjs('2019-01-25')
Expand Down Expand Up @@ -454,6 +455,12 @@ plugin [`IsLeapYear`](./Plugin.md#isleapyear)

plugin [`WeekOfYear`](./Plugin.md#weekofyear)

### IsoWeeksInYear

`.isoWeeksInYear` to get the number of weeks in year

plugin [`IsoWeeksInYear`](./Plugin.md#isoweeksinyear)

### IsSameOrAfter

`.isSameOrAfter` to check if a date is same of after another date
Expand Down Expand Up @@ -486,6 +493,18 @@ plugin [`ToArray`](./Plugin.md#toarray)

### ToObject

`.toObject` to return an `object` with the date's properties.
`.toObject` to return an `object` with the date's properties

plugin [`ToObject`](./Plugin.md#toobject)

### MinMax

`.min` `.max` to compare given dayjs instances

plugin [`MinMax`](./Plugin.md#minmax)

### Calendar

`.calendar` to display calendar time

plugin [`Calendar`](./Plugin.md#calendar)
7 changes: 6 additions & 1 deletion docs/en/I18n.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,12 @@ const localeObject = {
L: 'MM/DD/YYYY',
LL: 'MMMM D, YYYY',
LLL: 'MMMM D, YYYY h:mm A',
LLLL: 'dddd, 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
Expand Down
58 changes: 55 additions & 3 deletions docs/en/Plugin.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,10 @@ List of added formats:
| `LL` | MMMM D, YYYY | August 16, 2018 |
| `LLL` | MMMM D, YYYY h:mm A | August 16, 2018 8:02 PM |
| `LLLL` | dddd, MMMM D, YYYY h:mm A | Thursday, August 16, 2018 8:02 PM |
| `l` | M/D/YYYY | 8/16/2018 |
| `ll` | MMM D, YYYY | Aug 16, 2018 |
| `lll` | MMM D, YYYY h:mm A | Aug 16, 2018 8:02 PM |
| `llll` | ddd, MMM D, YYYY h:mm A | Thu, Aug 16, 2018 8:02 PM |

### RelativeTime

Expand Down Expand Up @@ -282,9 +286,24 @@ dayjs('2018-06-27').week() // 26
dayjs('2018-06-27').week(5) // set week
```

### IsoWeeksInYear

- IsoWeeksInYear adds `.isoWeeksInYear()` API to return a `number` to get the number of weeks in year, according to ISO weeks.

```javascript
import isoWeeksInYear from 'dayjs/plugin/isoWeeksInYear'
import isLeapYear from 'dayjs/plugin/isLeapYear' // rely on isLeapYear plugin

dayjs.extend(isoWeeksInYear)
dayjs.extend(isLeapYear)

dayjs('2004-01-01').isoWeeksInYear() // 53
dayjs('2005-01-01').isoWeeksInYear() // 52
```

### QuarterOfYear

- QuarterOfYear add `.quarter()` API to return to which quarter of the year belongs a date, and extends `.add` `.subtract` `.startOf` `.endOf` APIs to support unit `quarter`.
- QuarterOfYear adds `.quarter()` API to return to which quarter of the year belongs a date, and extends `.add` `.subtract` `.startOf` `.endOf` APIs to support unit `quarter`.

```javascript
import quarterOfYear from 'dayjs/plugin/quarterOfYear'
Expand Down Expand Up @@ -344,7 +363,7 @@ dayjs('2018 Enero 15', 'YYYY MMMM DD', 'es')

### ToArray

- ToArray add `.toArray()` API to return an `array` that mirrors the parameters
- ToArray adds `.toArray()` API to return an `array` that mirrors the parameters

```javascript
import toArray from 'dayjs/plugin/toArray'
Expand All @@ -356,7 +375,7 @@ dayjs('2019-01-25').toArray() // [ 2019, 0, 25, 0, 0, 0, 0 ]

### ToObject

- ToObject add `.toObject()` API to return an `object` with the date's properties.
- ToObject adds `.toObject()` API to return an `object` with the date's properties.

```javascript
import toObject from 'dayjs/plugin/toObject'
Expand All @@ -373,6 +392,39 @@ dayjs('2019-01-25').toObject()
milliseconds: 0 } */
```

### MinMax

- MinMax adds `.min` `.max` APIs to return a `dayjs` to compare given dayjs instances.

```javascript
import minMax from 'dayjs/plugin/minMax'

dayjs.extend(minMax)

dayjs.max(dayjs(), dayjs('2018-01-01'), dayjs('2019-01-01'))
dayjs.min([dayjs(), dayjs('2018-01-01'), dayjs('2019-01-01')])
```

### Calendar

- Calendar adds `.calendar` API to return a `string` to display calendar time

```javascript
import calendar from 'dayjs/plugin/calendar'

dayjs.extend(calendar)

dayjs().calendar(dayjs('2008-01-01'))
dayjs().calendar(null, {
sameDay: '[Today at] h:mm A', // The same day ( Today at 2:30 AM )
nextDay: '[Tomorrow]', // The next day ( Tomorrow at 2:30 AM )
nextWeek: 'dddd', // The next week ( Sunday at 2:30 AM )
lastDay: '[Yesterday]', // The day before ( Yesterday at 2:30 AM )
lastWeek: '[Last] dddd', // Last week ( Last Monday at 2:30 AM )
sameElse: 'DD/MM/YYYY' // Everything else ( 7/10/2011 )
})
```

## Customize

You could build your own Day.js plugin to meet different needs.
Expand Down
41 changes: 30 additions & 11 deletions docs/es-es/API-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@ El objeto `Dayjs` es inmutable, por lo que toda operación de la API que altere
- [Minuto `.minute()`](#minuto-minute)
- [Segundo `.second()`](#segundo-second)
- [Milisegundo `.millisecond()`](#milisegundo-millisecond)
- [Set `.set(unit: string, value: number)`](#set-setunit-string-value-number)
- [Get `.get(unit: string)`](#get-getunit-string)
- [Lista de unidades disponibles](#lista-de-unidades-disponibles)
- [Set `.set(unit: string, value: number)`](#set-setunit-string-value-number)
- [Manipulación](#manipulación)
- [Añadir `.add(value: number, unit: string)`](#añadir-addvalue-number-unit-string)
- [Restar `.subtract(value: number, unit: string)`](#restar-subtractvalue-number-unit-string)
Expand All @@ -49,15 +50,6 @@ El objeto `Dayjs` es inmutable, por lo que toda operación de la API que altere
- [Es Dayjs `.isDayjs()`](#es-dayjs-isdayjscompared-any)
- [UTC](#utc)
- [API de complementos](#api-de-complementos)
- [RelativeTime](#relativetime)
- [IsLeapYear](#isleapyear)
- [WeekOfYear](#weekofyear)
- [IsSameOrAfter](#issameorafter)
- [IsSameOrBefore](#issameorbefore)
- [IsBetween](#isbetween)
- [QuarterOfYear](#quarterofyear)
- [ToArray](#toarray)
- [ToObject](#toobject)

## Análisis

Expand Down Expand Up @@ -195,6 +187,15 @@ dayjs().millisecond()
dayjs().millisecond(1)
```

### Get `.get(unit: string)`

Returns a `number` with information getting from `Dayjs` object

```js
dayjs().get('month') // start 0
dayjs().get('day')
```

### Set `.set(unit: string, value: number)`

Devuelve un nuevo objeto `Dayjs` con los cambios aplicados.
Expand All @@ -211,7 +212,7 @@ dayjs().set('second', 30)
| ------------- | ----------- | ------------------------------------------- |
| `date` | | Día del mes |
| `day` | `d` | Día de la semana (de domingo 0, a sábado 6) |
| `month` | `M` | Mes |
| `month` | `M` | Mes (January as 0, December as 11) |
| `year` | `y` | Año |
| `hour` | `h` | Hora |
| `minute` | `m` | Minuto |
Expand Down Expand Up @@ -454,6 +455,12 @@ complemento [`IsLeapYear`](./Plugin.md#isleapyear)

complemento [`WeekOfYear`](./Plugin.md#weekofyear)

### IsoWeeksInYear

`.isoWeeksInYear` to get the number of weeks in year

plugin [`IsoWeeksInYear`](./Plugin.md#isoweeksinyear)

### IsSameOrAfter

`.isSameOrAfter` to check if a date is same of after another date
Expand Down Expand Up @@ -489,3 +496,15 @@ plugin [`ToArray`](./Plugin.md#toarray)
`.toObject` to return an `object` with the date's properties.

plugin [`ToObject`](./Plugin.md#toobject)

### MinMax

`.min` `.max` to compare given dayjs instances.

plugin [`MinMax`](./Plugin.md#minmax)

### Calendar

`.calendar` to display calendar time

plugin [`Calendar`](./Plugin.md#calendar)
48 changes: 48 additions & 0 deletions docs/es-es/Plugin.md
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,21 @@ dayjs('2018-06-27').week() // 26
dayjs('2018-06-27').week(5) // set week
```

### IsoWeeksInYear

- IsoWeeksInYear adds `.isoWeeksInYear()` API to return a `number` to get the number of weeks in year, according to ISO weeks.

```javascript
import isoWeeksInYear from 'dayjs/plugin/isoWeeksInYear'
import isLeapYear from 'dayjs/plugin/isLeapYear' // rely on isLeapYear plugin

dayjs.extend(isoWeeksInYear)
dayjs.extend(isLeapYear)

dayjs('2004-01-01').isoWeeksInYear() // 53
dayjs('2005-01-01').isoWeeksInYear() // 52
```

### QuarterOfYear

- QuarterOfYear add `.quarter()` API to return to which quarter of the year belongs a date, and extends `.add` `.subtract` `.startOf` `.endOf` APIs to support unit `quarter`.
Expand Down Expand Up @@ -373,6 +388,39 @@ dayjs('2019-01-25').toObject()
milliseconds: 0 } */
```

### MinMax

- MinMax adds `.min` `.max` APIs to return a `dayjs` to compare given dayjs instances.

```javascript
import minMax from 'dayjs/plugin/minMax'

dayjs.extend(minMax)

dayjs.max(dayjs(), dayjs('2018-01-01'), dayjs('2019-01-01'))
dayjs.min([dayjs(), dayjs('2018-01-01'), dayjs('2019-01-01')])
```

### Calendar

- Calendar adds `.calendar` API to return a `string` to display calendar time

```javascript
import calendar from 'dayjs/plugin/calendar'

dayjs.extend(calendar)

dayjs().calendar(dayjs('2008-01-01'))
dayjs().calendar(null, {
sameDay: '[Today at] h:mm A', // The same day ( Today at 2:30 AM )
nextDay: '[Tomorrow]', // The next day ( Tomorrow at 2:30 AM )
nextWeek: 'dddd', // The next week ( Sunday at 2:30 AM )
lastDay: '[Yesterday]', // The day before ( Yesterday at 2:30 AM )
lastWeek: '[Last] dddd', // Last week ( Last Monday at 2:30 AM )
sameElse: 'DD/MM/YYYY' // Everything else ( 7/10/2011 )
})
```

## Personalización

Puedes construir tu propio complemento de Day.js para cubrir tus necesidades.
Expand Down
Loading

0 comments on commit 534d51c

Please sign in to comment.