Skip to content

Commit

Permalink
Add new function fromUnixTime (#937) (closes #830)
Browse files Browse the repository at this point in the history
  • Loading branch information
xkizer authored and kossnocorp committed Oct 23, 2018
1 parent 71169da commit ffd36db
Show file tree
Hide file tree
Showing 19 changed files with 1,795 additions and 962 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Expand Up @@ -162,6 +162,8 @@ for the list of changes made since `v2.0.0-alpha.1`.

- [New `roundToNearestMinutes` function](https://github.com/date-fns/date-fns/pull/928). Kudos to [@xkizer](https://github.com/xkizer).

- Added new function `fromUnixTime`

### Changed

- **BREAKING**: new format string API for `format` function
Expand Down
858 changes: 560 additions & 298 deletions src/esm/fp/index.js

Large diffs are not rendered by default.

329 changes: 180 additions & 149 deletions src/esm/index.js

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions src/fp/fromUnixTime/index.d.ts
@@ -0,0 +1,4 @@
// This file is generated automatically by `scripts/build/typings.js`. Please, don't change it.

import {fromUnixTime} from 'date-fns/fp'
export = fromUnixTime
8 changes: 8 additions & 0 deletions src/fp/fromUnixTime/index.js
@@ -0,0 +1,8 @@
// This file is generated automatically by `scripts/build/fp.js`. Please, don't change it.

import fn from '../../fromUnixTime/index.js'
import convertToFP from '../_lib/convertToFP/index.js'

var fromUnixTime = convertToFP(fn, 1)

export default fromUnixTime
52 changes: 52 additions & 0 deletions src/fp/fromUnixTime/index.js.flow
@@ -0,0 +1,52 @@
// @flow
// This file is generated automatically by `scripts/build/typings.js`. Please, don't change it.

type Interval = {
start: Date | string | number,
end: Date | string | number
}

type Options = {
weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6,
firstWeekContainsDate?: 1 | 2 | 3 | 4 | 5 | 6 | 7,
additionalDigits?: 0 | 1 | 2,
locale?: Locale,
includeSeconds?: boolean,
addSuffix?: boolean,
unit?: 'second' | 'minute' | 'hour' | 'day' | 'month' | 'year',
roundingMethod?: 'floor' | 'ceil' | 'round',
awareOfUnicodeTokens?: boolean
}

type Locale = {
formatDistance: Function,
formatRelative: Function,
localize: {
ordinalNumber: Function,
era: Function,
quarter: Function,
month: Function,
day: Function,
dayPeriod: Function
},
formatLong: Object,
date: Function,
time: Function,
dateTime: Function,
match: {
ordinalNumber: Function,
era: Function,
quarter: Function,
month: Function,
day: Function,
dayPeriod: Function
},
options?: {
weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6,
firstWeekContainsDate?: 1 | 2 | 3 | 4 | 5 | 6 | 7
}
}

type CurriedFn1<A, R> = <A>(a: A) => R

declare module.exports: CurriedFn1<number, Date>
4 changes: 4 additions & 0 deletions src/fp/fromUnixTimeWithOptions/index.d.ts
@@ -0,0 +1,4 @@
// This file is generated automatically by `scripts/build/typings.js`. Please, don't change it.

import {fromUnixTimeWithOptions} from 'date-fns/fp'
export = fromUnixTimeWithOptions
8 changes: 8 additions & 0 deletions src/fp/fromUnixTimeWithOptions/index.js
@@ -0,0 +1,8 @@
// This file is generated automatically by `scripts/build/fp.js`. Please, don't change it.

import fn from '../../fromUnixTime/index.js'
import convertToFP from '../_lib/convertToFP/index.js'

var fromUnixTimeWithOptions = convertToFP(fn, 2)

export default fromUnixTimeWithOptions
55 changes: 55 additions & 0 deletions src/fp/fromUnixTimeWithOptions/index.js.flow
@@ -0,0 +1,55 @@
// @flow
// This file is generated automatically by `scripts/build/typings.js`. Please, don't change it.

type Interval = {
start: Date | string | number,
end: Date | string | number
}

type Options = {
weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6,
firstWeekContainsDate?: 1 | 2 | 3 | 4 | 5 | 6 | 7,
additionalDigits?: 0 | 1 | 2,
locale?: Locale,
includeSeconds?: boolean,
addSuffix?: boolean,
unit?: 'second' | 'minute' | 'hour' | 'day' | 'month' | 'year',
roundingMethod?: 'floor' | 'ceil' | 'round',
awareOfUnicodeTokens?: boolean
}

type Locale = {
formatDistance: Function,
formatRelative: Function,
localize: {
ordinalNumber: Function,
era: Function,
quarter: Function,
month: Function,
day: Function,
dayPeriod: Function
},
formatLong: Object,
date: Function,
time: Function,
dateTime: Function,
match: {
ordinalNumber: Function,
era: Function,
quarter: Function,
month: Function,
day: Function,
dayPeriod: Function
},
options?: {
weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6,
firstWeekContainsDate?: 1 | 2 | 3 | 4 | 5 | 6 | 7
}
}

type CurriedFn1<A, R> = <A>(a: A) => R

type CurriedFn2<A, B, R> = <A>(a: A) => CurriedFn1<B, R>
| <A, B>(a: A, b: B) => R

declare module.exports: CurriedFn2<Options, number, Date>
2 changes: 2 additions & 0 deletions src/fp/index.js
Expand Up @@ -99,6 +99,8 @@ module.exports = {
formatRelative: require('./formatRelative/index.js'),
formatRelativeWithOptions: require('./formatRelativeWithOptions/index.js'),
formatWithOptions: require('./formatWithOptions/index.js'),
fromUnixTime: require('./fromUnixTime/index.js'),
fromUnixTimeWithOptions: require('./fromUnixTimeWithOptions/index.js'),
getDate: require('./getDate/index.js'),
getDateWithOptions: require('./getDateWithOptions/index.js'),
getDay: require('./getDay/index.js'),
Expand Down
2 changes: 2 additions & 0 deletions src/fp/index.js.flow
Expand Up @@ -160,6 +160,8 @@ declare module.exports: {
formatRelative: CurriedFn2<Date | string | number, Date | string | number, string>,
formatRelativeWithOptions: CurriedFn3<Options, Date | string | number, Date | string | number, string>,
formatWithOptions: CurriedFn3<Options, string, Date | string | number, string>,
fromUnixTime: CurriedFn1<number, Date>,
fromUnixTimeWithOptions: CurriedFn2<Options, number, Date>,
getDate: CurriedFn1<Date | string | number, number>,
getDateWithOptions: CurriedFn2<Options, Date | string | number, number>,
getDay: CurriedFn1<Date | string | number, number>,
Expand Down

0 comments on commit ffd36db

Please sign in to comment.