forked from date-fns/date-fns
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8609cad
commit e1a44d9
Showing
110 changed files
with
3,830 additions
and
97 deletions.
There are no files selected for viewing
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
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
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
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
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
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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// @flow | ||
/* eslint-env mocha */ | ||
/* global suite, benchmark */ | ||
|
||
import endOfToday from '.' | ||
|
||
suite('endOfToday', () => { | ||
benchmark('date-fns', () => endOfToday()) | ||
}) |
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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
// This file is generated automatically by `scripts/build/typings.js`. Please, don't change it. | ||
|
||
import { endOfToday } from 'date-fns' | ||
export default endOfToday |
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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import endOfDay from '../endOfDay/index.js' | ||
|
||
/** | ||
* @name endOfToday | ||
* @category Day Helpers | ||
* @summary Return the end of today. | ||
* @pure false | ||
* | ||
* @description | ||
* Return the end of today. | ||
* | ||
* > ⚠️ Please note that this function is not present in the FP submodule as | ||
* > it uses `Date.now()` internally hence impure and can't be safely curried. | ||
* | ||
* ### v2.0.0 breaking changes: | ||
* | ||
* - [Changes that are common for the whole library](https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#Common-Changes). | ||
* | ||
* @returns {Date} the end of today | ||
* | ||
* @example | ||
* // If today is 6 October 2014: | ||
* var result = endOfToday() | ||
* //=> Mon Oct 6 2014 23:59:59.999 | ||
*/ | ||
export default function endOfToday() { | ||
return endOfDay(Date.now()) | ||
} |
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 |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// @flow | ||
// This file is generated automatically by `scripts/build/typings.js`. Please, don't change it. | ||
|
||
type Interval = { | ||
start: Date | number, | ||
end: Date | number | ||
} | ||
|
||
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 | ||
} | ||
} | ||
|
||
declare module.exports: () => Date |
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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// @flow | ||
/* eslint-env mocha */ | ||
|
||
import assert from 'assert' | ||
import sinon from 'sinon' | ||
import endOfToday from '.' | ||
|
||
describe('endOfToday', () => { | ||
let clock | ||
beforeEach(() => { | ||
clock = sinon.useFakeTimers( | ||
new Date(2014, 8 /* Sep */, 25, 14, 30, 45, 500).getTime() | ||
) | ||
}) | ||
|
||
afterEach(() => { | ||
clock.restore() | ||
}) | ||
|
||
it('returns the current date with the time setted to 23:59:59.999', () => { | ||
const result = endOfToday() | ||
assert.deepEqual(result, new Date(2014, 8 /* Sep */, 25, 23, 59, 59, 999)) | ||
}) | ||
}) |
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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// @flow | ||
/* eslint-env mocha */ | ||
/* global suite, benchmark */ | ||
|
||
import endOfTomorrow from '.' | ||
|
||
suite('endOfTomorrow', () => { | ||
benchmark('date-fns', () => endOfTomorrow()) | ||
}) |
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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
// This file is generated automatically by `scripts/build/typings.js`. Please, don't change it. | ||
|
||
import { endOfTomorrow } from 'date-fns' | ||
export default endOfTomorrow |
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 |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/** | ||
* @name endOfTomorrow | ||
* @category Day Helpers | ||
* @summary Return the end of tomorrow. | ||
* @pure false | ||
* | ||
* @description | ||
* Return the end of tomorrow. | ||
* | ||
* > ⚠️ Please note that this function is not present in the FP submodule as | ||
* > it uses `Date.now()` internally hence impure and can't be safely curried. | ||
* | ||
* ### v2.0.0 breaking changes: | ||
* | ||
* - [Changes that are common for the whole library](https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#Common-Changes). | ||
* | ||
* @returns {Date} the end of tomorrow | ||
* | ||
* @example | ||
* // If today is 6 October 2014: | ||
* var result = endOfTomorrow() | ||
* //=> Tue Oct 7 2014 23:59:59.999 | ||
*/ | ||
export default function endOfTomorrow() { | ||
var now = new Date() | ||
var year = now.getFullYear() | ||
var month = now.getMonth() | ||
var day = now.getDate() | ||
|
||
var date = new Date(0) | ||
date.setFullYear(year, month, day + 1) | ||
date.setHours(23, 59, 59, 999) | ||
return date | ||
} |
Oops, something went wrong.