Skip to content

Commit

Permalink
Merge pull request #526 from iamkun/feature/refactor
Browse files Browse the repository at this point in the history
Refactor
  • Loading branch information
iamkun committed Mar 10, 2019
2 parents bdbec01 + 0fc2397 commit 47bda00
Show file tree
Hide file tree
Showing 42 changed files with 978 additions and 298 deletions.
63 changes: 30 additions & 33 deletions docs/en/API-reference.md
Expand Up @@ -39,10 +39,8 @@ The `Dayjs` object is immutable, that is, all API operations that change the `Da
- [UTC offset (minutes) `.utcOffset()`](#utc-offset-minutes-utcoffset)
- [Days in the Month `.daysInMonth()`](#days-in-the-month-daysinmonth)
- [As Javascript Date `.toDate()`](#as-javascript-date-todate)
- [As Array `.toArray()`](#as-array-toarray)
- [As JSON `.toJSON()`](#as-json-tojson)
- [As ISO 8601 String `.toISOString()`](#as-iso-8601-string-toisostring)
- [As Object `.toObject()`](#as-object-toobject)
- [As String `.toString()`](#as-string-tostring)
- [Query](#query)
- [Is Before `.isBefore(compared: Dayjs, unit?: string)`](#is-before-isbeforecompared-dayjs-unit-string)
Expand All @@ -58,6 +56,8 @@ The `Dayjs` object is immutable, that is, all API operations that change the `Da
- [IsSameOrBefore](#issameorbefore)
- [IsBetween](#isbetween)
- [QuarterOfYear](#quarterofyear)
- [ToArray](#toarray)
- [ToObject](#toobject)

## Parsing

Expand Down Expand Up @@ -125,66 +125,74 @@ dayjs().isValid()

### Year `.year()`

Returns a `number` representing the `Dayjs`'s year.
Gets or sets the year.

```js
dayjs().year()
dayjs().year(2000)
```

### Month `.month()`

Returns a `number` representing the `Dayjs`'s month. Starts at 0
Gets or sets the month. Starts at 0

```js
dayjs().month()
dayjs().month(0)
```

### Day of the Month `.date()`

Returns a `number` representing the `Dayjs`'s day of the month. Starts at 1
Gets or sets the day of the month. Starts at 1

```js
dayjs().date()
dayjs().date(1)
```

### Day of the Week `.day()`

Returns a `number` representing the `Dayjs`'s day of the week. Starts on Sunday with 0
Gets or sets the day of the week. Starts on Sunday with 0

```js
dayjs().day()
dayjs().day(0)
```

### Hour `.hour()`

Returns a `number` representing the `Dayjs`'s hour.
Gets or sets the hour.

```js
dayjs().hour()
dayjs().hour(12)
```

### Minute `.minute()`

Returns a `number` representing the `Dayjs`'s minute.
Gets or sets the minute.

```js
dayjs().minute()
dayjs().minute(59)
```

### Second `.second()`

Returns a `number` representing the `Dayjs`'s second.
Gets or sets the second.

```js
dayjs().second()
dayjs().second(1)
```

### Millisecond `.millisecond()`

Returns a `number` representing the `Dayjs`'s millisecond.
Gets or sets the millisecond.

```js
dayjs().millisecond()
dayjs().millisecond(1)
```

### Set `.set(unit: string, value: number)`
Expand Down Expand Up @@ -354,14 +362,6 @@ Returns a copy of the native `Date` object parsed from the `Dayjs` object.
dayjs('2019-01-25').toDate()
```

### As Array `.toArray()`

Returns an `array` that mirrors the parameters from new Date().

```js
dayjs('2019-01-25').toArray() // [ 2019, 0, 25, 0, 0, 0, 0 ]
```

### As JSON `.toJSON()`

Returns the `Dayjs` formatted in an ISO8601 `string`.
Expand All @@ -378,21 +378,6 @@ Returns the `Dayjs` formatted in an ISO8601 `string`.
dayjs('2019-01-25').toISOString() // '2019-01-25T02:00:00.000Z'
```

### As Object `.toObject()`

Returns an `object` with the date's properties.

```js
dayjs('2019-01-25').toObject()
/* { years: 2019,
months: 0,
date: 25,
hours: 0,
minutes: 0,
seconds: 0,
milliseconds: 0 } */
```

### As String `.toString()`

Returns a `string` representation of the date.
Expand Down Expand Up @@ -492,3 +477,15 @@ plugin [`IsBetween`](./Plugin.md#isbetween)
`.quarter` to get quarter of the year

plugin [`QuarterOfYear`](./Plugin.md#quarterofyear)

### ToArray

`.toArray` to return an `array` that mirrors the parameters

plugin [`ToArray`](./Plugin.md#toarray)

### ToObject

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

plugin [`ToObject`](./Plugin.md#toobject)
32 changes: 32 additions & 0 deletions docs/en/Plugin.md
Expand Up @@ -339,6 +339,38 @@ dayjs('2018 Enero 15', 'YYYY MMMM DD', 'es')
| `ZZ` | -0500 | Compact offset from UTC, 2-digits |
| `A` | AM PM | Post or ante meridiem, upper-case |
| `a` | am pm | Post or ante meridiem, lower-case |
| `Do` | 1st... 31st | Day of Month with ordinal |

### ToArray

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

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

dayjs.extend(toArray)

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.

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

dayjs.extend(toObject)

dayjs('2019-01-25').toObject()
/* { years: 2019,
months: 0,
date: 25,
hours: 0,
minutes: 0,
seconds: 0,
milliseconds: 0 } */
```

## Customize

Expand Down
63 changes: 30 additions & 33 deletions docs/es-es/API-reference.md
Expand Up @@ -39,10 +39,8 @@ El objeto `Dayjs` es inmutable, por lo que toda operación de la API que altere
- [UTC offset (minutos) `.utcOffset()`](#utc-offset-minutos-utcoffset)
- [Días en el mes `.daysInMonth()`](#días-en-el-mes-daysinmonth)
- [Como objeto `Date` `.toDate()`](#como-objeto-date-todate)
- [Como array `.toArray()`](#como-array-toarray)
- [Como JSON `.toJSON()`](#como-json-tojson)
- [Como cadena ISO 8601 `.toISOString()`](#como-cadena-iso-8601-toisostring)
- [Como objeto `.toObject()`](#como-objecto-toobject)
- [Como cadena `.toString()`](#como-cadena-tostring)
- [Consulta](#consulta)
- [Anterior a `.isBefore(compared: Dayjs, unit?: string)`](#anterior-a-isbeforecompared-dayjs-unit-string)
Expand All @@ -58,6 +56,8 @@ El objeto `Dayjs` es inmutable, por lo que toda operación de la API que altere
- [IsSameOrBefore](#issameorbefore)
- [IsBetween](#isbetween)
- [QuarterOfYear](#quarterofyear)
- [ToArray](#toarray)
- [ToObject](#toobject)

## Análisis

Expand Down Expand Up @@ -125,66 +125,74 @@ dayjs().isValid()

### Año `.year()`

Devuelve un dato de tipo `number`, que representa el año del objeto `Dayjs`.
Gets or sets the year.

```js
dayjs().year()
dayjs().year(2000)
```

### Mes `.month()`

Devuelve un dato de tipo `number`, que representa el mes del objeto `Dayjs`. Se cuenta desde 0, que se corresponde con enero.
Gets or sets the month. Starts at 0

```js
dayjs().month()
dayjs().month(0)
```

### Día del mes `.date()`

Devuelve un dato de tipo `number`, que indica el día del mes del objeto `Dayjs`. Empieza por el día 1.
Gets or sets the day of the month. Starts at 1

```js
dayjs().date()
dayjs().date(1)
```

### Día de la semana `.day()`

Devuelve un dato de tipo `number`, que indica el día de la semana del objeto `Dayjs`. Se cuenta desde 0, que se corresponde con el domingo.
Gets or sets the day of the week. Starts on Sunday with 0

```js
dayjs().day()
dayjs().day(0)
```

### Hora `.hour()`

Devuelve un dato de tipo `number`, que indica la hora del objeto `Dayjs`.
Gets or sets the hour.

```js
dayjs().hour()
dayjs().hour(12)
```

### Minuto `.minute()`

Devuelve un dato de tipo `number`, que indica los minutos del objeto `Dayjs`.
Gets or sets the minute.

```js
dayjs().minute()
dayjs().minute(59)
```

### Segundo `.second()`

Devuelve un dato de tipo `number`, que indica los segundos del objeto `Dayjs`.
Gets or sets the second.

```js
dayjs().second()
dayjs().second(1)
```

### Milisegundo `.millisecond()`

Devuelve un dato de tipo `number`, que indica los milisegundos del objeto `Dayjs`.
Gets or sets the millisecond.

```js
dayjs().millisecond()
dayjs().millisecond(1)
```

### Set `.set(unit: string, value: number)`
Expand Down Expand Up @@ -354,14 +362,6 @@ Devuelve un objeto `Date` nativo, obtenido a partir del objeto `Dayjs`.
dayjs('2019-01-25').toDate()
```

### Como array `.toArray()`

Devuelve un array que reproduce los parámetros de `new Date()`.

```js
dayjs('2019-01-25').toArray() // [ 2019, 0, 25, 0, 0, 0, 0 ]
```

### Como JSON `.toJSON()`

Devuelve un objeto `Dayjs` formateado como una cadena ISO8601.
Expand All @@ -378,21 +378,6 @@ Devuelve un objeto `Dayjs` formateado como una cadena ISO8601.
dayjs('2019-01-25').toISOString() // '2019-01-25T02:00:00.000Z'
```

### Como objecto `.toObject()`

Devuelve un dato de tipo `object`, con las propiedades de la fecha.

```js
dayjs('2019-01-25').toObject()
/* { years: 2019,
months: 0,
date: 25,
hours: 0,
minutes: 0,
seconds: 0,
milliseconds: 0 } */
```

### Como cadena `.toString()`

Devuelve un dato de tipo `string`, que representa la fecha.
Expand Down Expand Up @@ -492,3 +477,15 @@ complemento [`IsBetween`](./Plugin.md#isbetween)
`.quarter` to get quarter of the year

plugin [`QuarterOfYear`](./Plugin.md#quarterofyear)

### ToArray

`.toArray` to return an `array` that mirrors the parameters

plugin [`ToArray`](./Plugin.md#toarray)

### ToObject

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

plugin [`ToObject`](./Plugin.md#toobject)
32 changes: 32 additions & 0 deletions docs/es-es/Plugin.md
Expand Up @@ -339,6 +339,38 @@ dayjs('2018 Enero 15', 'YYYY MMMM DD', 'es')
| `ZZ` | -0500 | Compact offset from UTC, 2-digits |
| `A` | AM PM | Post or ante meridiem, upper-case |
| `a` | am pm | Post or ante meridiem, lower-case |
| `Do` | 1st... 31st | Día del mes con ordinal |

### ToArray

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

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

dayjs.extend(toArray)

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.

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

dayjs.extend(toObject)

dayjs('2019-01-25').toObject()
/* { years: 2019,
months: 0,
date: 25,
hours: 0,
minutes: 0,
seconds: 0,
milliseconds: 0 } */
```

## Personalización

Expand Down

0 comments on commit 47bda00

Please sign in to comment.