-
-
Notifications
You must be signed in to change notification settings - Fork 956
feat: add assert/is-same-date-object
#1348
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Planeshifter
merged 23 commits into
stdlib-js:develop
from
adityacodes30:is-same-date-object
Mar 3, 2024
Merged
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
4e499da
added is-same-date-object #1337
adityacodes30 d184b02
feat(@stdlib/assert): add isSameDateObject function, closes 1337
adityacodes30 4e840f0
docs(@stdlib/assert/is-same-date-object): update documentation in doc…
adityacodes30 55e77d3
docs(@stdlib/assert/is-same-date-object): update documentation in doc…
adityacodes30 b690edf
feat(@stdlib/assert): add isDateObject function,requested changes,#1337
adityacodes30 d426b82
feat(@stdlib/assert): add isDateObject function,requested changes,#1337
adityacodes30 8dfcc54
Update lib/node_modules/@stdlib/assert/is-same-date-object/docs/repl.txt
adityacodes30 8c73111
feat(@stdlib/assert): add isDateObject function,requested changes,#1337
adityacodes30 f1710dd
feat(@stdlib/assert): add isDateObject function,requested changes,#1337
adityacodes30 bc9877a
Update lib/node_modules/@stdlib/assert/is-same-date-object/benchmark/…
adityacodes30 59fb3c9
Update lib/node_modules/@stdlib/assert/is-same-date-object/docs/repl.txt
adityacodes30 bb1a8ae
feat(@stdlib/assert): add isDateObject function,requested changes,#1337
adityacodes30 87f1275
Merge branch 'is-same-date-object' of https://github.com/adityacodes3…
adityacodes30 34d7024
Update lib/node_modules/@stdlib/assert/is-same-date-object/package.json
Planeshifter 7445142
Update lib/node_modules/@stdlib/assert/is-same-date-object/docs/repl.txt
Planeshifter 0cefc0e
Update lib/node_modules/@stdlib/assert/is-same-date-object/docs/repl.txt
Planeshifter 063b38e
Update lib/node_modules/@stdlib/assert/is-same-date-object/examples/i…
Planeshifter fdf2ab4
Update lib/node_modules/@stdlib/assert/is-same-date-object/examples/i…
Planeshifter b0cda06
Update lib/node_modules/@stdlib/assert/is-same-date-object/examples/i…
Planeshifter 50a5189
Update lib/node_modules/@stdlib/assert/is-same-date-object/examples/i…
Planeshifter 9aadb60
Update lib/node_modules/@stdlib/assert/is-same-date-object/examples/i…
Planeshifter d38aa8b
Update lib/node_modules/@stdlib/assert/is-same-date-object/package.json
Planeshifter 6cda4aa
Update lib/node_modules/@stdlib/assert/is-same-date-object/examples/i…
Planeshifter File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
91 changes: 91 additions & 0 deletions
91
lib/node_modules/@stdlib/assert/is-same-date-object/README.md
This file contains hidden or 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,91 @@ | ||
| <!-- | ||
|
|
||
| @license Apache-2.0 | ||
|
|
||
| Copyright (c) 2024 The Stdlib Authors. | ||
|
|
||
| Licensed under the Apache License, Version 2.0 (the "License"); | ||
| you may not use this file except in compliance with the License. | ||
| You may obtain a copy of the License at | ||
|
|
||
| http://www.apache.org/licenses/LICENSE-2.0 | ||
|
|
||
| Unless required by applicable law or agreed to in writing, software | ||
| distributed under the License is distributed on an "AS IS" BASIS, | ||
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| See the License for the specific language governing permissions and | ||
| limitations under the License. | ||
|
|
||
| --> | ||
|
|
||
| # isSameDateObject | ||
|
|
||
| > Test if two values are [Date](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date) objects corresponding to the same date and time. | ||
|
|
||
| <section class="usage"> | ||
|
|
||
| ## Usage | ||
|
|
||
| ```javascript | ||
| var isSameDateObject = require( '@stdlib/assert/is-same-date-object' ); | ||
| ``` | ||
|
|
||
| #### isSameDateObject( d1, d2 ) | ||
|
|
||
| Tests if two values are both Date objects corresponding to the same date and time. | ||
|
|
||
| ```javascript | ||
| var d1 = new Date( 2024, 11, 31, 23, 59, 59, 999 ); | ||
| var d2 = new Date( 2024, 11, 31, 23, 59, 59, 999 ); | ||
| var bool = isSameDateObject( d1, d2 ); | ||
| // returns true | ||
|
|
||
| bool = isSameDateObject( d1, new Date( 2023, 11, 31, 23, 59, 59, 78 ) ); | ||
| // returns false | ||
| ``` | ||
|
|
||
| </section> | ||
|
|
||
| <!-- /.usage --> | ||
|
|
||
| <section class="examples"> | ||
|
|
||
| ## Examples | ||
|
|
||
| <!-- eslint no-undef: "error" --> | ||
|
|
||
| ```javascript | ||
| var isSameDateObject = require( '@stdlib/assert/is-same-date-object' ); | ||
|
|
||
| var d1 = new Date( 2024, 11, 31, 23, 59, 59, 999 ); | ||
| var d2 = new Date( 2024, 11, 31, 23, 59, 59, 999 ); | ||
|
|
||
| var bool = isSameDateObject( d1, d2 ); | ||
| // returns true | ||
|
|
||
| d1 = new Date( 2024, 11, 31, 23, 59, 59, 999 ); | ||
| d2 = new Date( 2024, 11, 31, 23, 59, 59, 78 ); | ||
|
|
||
| bool = isSameDateObject( d1, d2 ); | ||
| // returns false | ||
|
|
||
| d1 = new Date(); | ||
| d2 = new Date( '2024-12-31T23:59:59.999' ); | ||
|
|
||
| bool = isSameDateObject( d1, d2 ); | ||
| // returns false | ||
|
|
||
| var d3 = new Date( 2024, 11, 31 ); | ||
| var d4 = new Date( 'December 31, 2024 23:59:59:999' ); | ||
|
|
||
| bool = isSameDateObject( d1, d3 ); | ||
| // returns false | ||
|
|
||
| bool = isSameDateObject( d2, d4 ); | ||
| // returns true | ||
| ``` | ||
|
|
||
| </section> | ||
|
|
||
|
|
||
| <!-- /.examples --> |
62 changes: 62 additions & 0 deletions
62
lib/node_modules/@stdlib/assert/is-same-date-object/benchmark/benchmark.js
This file contains hidden or 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,62 @@ | ||
| /** | ||
| * @license Apache-2.0 | ||
| * | ||
| * Copyright (c) 2024 The Stdlib Authors. | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| 'use strict'; | ||
|
|
||
| // MODULES // | ||
|
|
||
| var bench = require( '@stdlib/bench' ); | ||
| var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; | ||
| var pkg = require( './../package.json' ).name; | ||
| var isSameDateObject = require( './../lib' ); | ||
|
|
||
|
|
||
| // MAIN // | ||
|
|
||
| bench( pkg, function benchmark( b ) { | ||
| var values; | ||
| var date1; | ||
| var date2; | ||
| var bool; | ||
| var i; | ||
| values = [ | ||
| '5', | ||
| 'Date', | ||
| new Date( 'December 31, 2024 23:59:59:999' ), | ||
| new Date( '2024-12-31T23:59:59.999' ), | ||
| NaN, | ||
| true, | ||
| false, | ||
| null | ||
| ]; | ||
| date1 = new Date(); | ||
| b.tic(); | ||
| for ( i = 0; i < b.iterations; i++ ) { | ||
| date2 = values[ i%values.length ]; | ||
| bool = isSameDateObject( date1, date2 ); | ||
| if ( typeof bool !== 'boolean' ) { | ||
| b.fail( 'should return a boolean' ); | ||
| } | ||
| } | ||
| b.toc(); | ||
| if ( !isBoolean( bool ) ) { | ||
| b.fail( 'should return a boolean' ); | ||
| } | ||
| b.pass( 'benchmark finished' ); | ||
| b.end(); | ||
| }); |
32 changes: 32 additions & 0 deletions
32
lib/node_modules/@stdlib/assert/is-same-date-object/docs/repl.txt
This file contains hidden or 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,32 @@ | ||
|
|
||
| {{alias}}( d1, d2 ) | ||
| Tests if two values are both Date objects corresponding | ||
| to the same date and time. | ||
|
|
||
| Parameters | ||
| ---------- | ||
| d1: any | ||
| First input value. | ||
| d2: any | ||
| Second input value. | ||
|
|
||
| Returns | ||
| ------- | ||
| bool: boolean | ||
| Boolean indicating whether both values are Date objects | ||
| corresponding to the same date and time. | ||
|
|
||
| Examples | ||
| -------- | ||
| > var d1 = new Date( 2024, 11, 31, 23, 59, 59, 999 ); | ||
| > var d2 = new Date( 2024, 11, 31, 23, 59, 59, 999 ); | ||
| > var bool = {{alias}}( d1, d2 ) | ||
| true | ||
| > var d1 = new Date( 2024, 11, 31, 23, 59, 59, 999 ); | ||
| > var d2 = new Date( 2024, 11, 31, 23, 59, 59, 78 ); | ||
| > var bool = {{alias}}( d1, d2 ) | ||
| false | ||
|
|
||
| See Also | ||
| -------- | ||
|
|
47 changes: 47 additions & 0 deletions
47
lib/node_modules/@stdlib/assert/is-same-date-object/docs/types/index.d.ts
This file contains hidden or 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,47 @@ | ||
| /* | ||
| * @license Apache-2.0 | ||
| * | ||
| * Copyright (c) 2024 The Stdlib Authors. | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| // TypeScript Version: 4.1 | ||
|
|
||
| /** | ||
| * Tests if two values are both Date objects corresponding to the same date and time. | ||
| * | ||
| * @param d1 - first input value | ||
| * @param d2 - second input value | ||
| * @returns boolean indicating whether both are Date objects corresponding to the same date and time. | ||
| * | ||
| * @example | ||
| * var d1 = new Date( 2024, 11, 31, 23, 59, 59, 999 ); | ||
| * var d2 = new Date( 2024, 11, 31, 23, 59, 59, 999 ); | ||
| * | ||
| * var bool = isSameDateObject( d1, d2 ); | ||
| * // returns true | ||
| * | ||
| * @example | ||
| * var d1 = new Date( 2024, 11, 31, 23, 59, 59, 999 ); | ||
| * var d2 = new Date( 2024, 11, 31, 23, 59, 59, 78 ); | ||
| * | ||
| * var bool = isSameDateObject( d1, d2 ); | ||
| * // returns false | ||
| */ | ||
| declare function isSameDateObject( d1: any, d2: any ): boolean; | ||
|
|
||
|
|
||
| // EXPORTS // | ||
|
|
||
| export = isSameDateObject; | ||
36 changes: 36 additions & 0 deletions
36
lib/node_modules/@stdlib/assert/is-same-date-object/docs/types/test.ts
This file contains hidden or 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,36 @@ | ||
| /* | ||
| * @license Apache-2.0 | ||
| * | ||
| * Copyright (c) 2024 The Stdlib Authors. | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| import isSameDateObject = require( './index' ); | ||
|
|
||
|
|
||
| // TESTS // | ||
|
|
||
| // The function returns a boolean... | ||
| { | ||
| isSameDateObject( new Date(), new Date() ); // $ExpectType boolean | ||
| isSameDateObject( null, null ); // $ExpectType boolean | ||
| isSameDateObject( 'beep', 'boop' ); // $ExpectType boolean | ||
| } | ||
|
|
||
| // The compiler throws an error if the function is provided an unsupported number of arguments... | ||
| { | ||
| isSameDateObject(); // $ExpectError | ||
| isSameDateObject( new Date() ); // $ExpectError | ||
| isSameDateObject( 'beep', 'beep', new Date() ); // $ExpectError | ||
| } |
51 changes: 51 additions & 0 deletions
51
lib/node_modules/@stdlib/assert/is-same-date-object/examples/index.js
This file contains hidden or 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,51 @@ | ||
| /** | ||
| * @license Apache-2.0 | ||
| * | ||
| * Copyright (c) 2024 The Stdlib Authors. | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| 'use strict'; | ||
|
|
||
| var isSameDateObject = require( './../lib' ); | ||
|
|
||
| var d1 = new Date( 2024, 11, 31, 23, 59, 59, 999 ); | ||
| var d2 = new Date( 2024, 11, 31, 23, 59, 59, 999 ); | ||
|
|
||
| var bool = isSameDateObject( d1, d2 ); | ||
| console.log( bool ); | ||
| // => true | ||
|
|
||
| d1 = new Date( 2024, 11, 31, 23, 59, 59, 999 ); | ||
| d2 = new Date( 2024, 11, 31, 23, 59, 59, 78 ); | ||
|
|
||
| bool = isSameDateObject( d1, d2 ); | ||
| console.log( bool ); | ||
| // => false | ||
|
|
||
| d1 = new Date(); | ||
| d2 = new Date( '2024-12-31T23:59:59.999' ); | ||
| bool = isSameDateObject( d1, d2 ); | ||
| // returns false | ||
|
|
||
| var d3 = new Date( 2024, 11, 31 ); | ||
| var d4 = new Date( 'December 31, 2024 23:59:59:999' ); | ||
|
|
||
| bool = isSameDateObject( d1, d3 ); | ||
| console.log( bool ); | ||
| // => false | ||
|
|
||
| bool = isSameDateObject( d2, d4 ); | ||
| console.log( bool ); | ||
| // => true |
52 changes: 52 additions & 0 deletions
52
lib/node_modules/@stdlib/assert/is-same-date-object/lib/index.js
This file contains hidden or 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,52 @@ | ||
| /** | ||
| * @license Apache-2.0 | ||
| * | ||
| * Copyright (c) 2024 The Stdlib Authors. | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| 'use strict'; | ||
|
|
||
| /** | ||
| * Test if two arguments are both Date objects corresponding to the same date and time. | ||
| * | ||
| * @module @stdlib/assert/is-same-date-object | ||
| * | ||
| * @example | ||
| * var isSameDateObject = require( '@stdlib/assert/is-same-date-object' ); | ||
| * | ||
| * var d1 = new Date( 2024, 11, 31, 23, 59, 59, 999 ); | ||
| * var d2 = new Date( 2024, 11, 31, 23, 59, 59, 999 ); | ||
| * | ||
| * var bool = isSameDateObject( d1, d2 ); | ||
| * // returns true | ||
| * | ||
| * @example | ||
| * var isSameDateObject = require( '@stdlib/assert/is-same-date-object' ); | ||
| * | ||
| * var d1 = new Date( 2024, 11, 31, 23, 59, 59, 999 ); | ||
| * var d2 = new Date( 2024, 11, 31, 23, 59, 59, 78 ); | ||
| * | ||
| * var bool = isSameDateObject( d1, d2 ); | ||
| * // returns false | ||
| */ | ||
|
|
||
| // MODULES // | ||
|
|
||
| var main = require( './main.js' ); | ||
|
|
||
|
|
||
| // EXPORTS // | ||
|
|
||
| module.exports = main; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.