Skip to content
Merged
Show file tree
Hide file tree
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 Feb 22, 2024
d184b02
feat(@stdlib/assert): add isSameDateObject function, closes 1337
adityacodes30 Feb 22, 2024
4e840f0
docs(@stdlib/assert/is-same-date-object): update documentation in doc…
adityacodes30 Feb 22, 2024
55e77d3
docs(@stdlib/assert/is-same-date-object): update documentation in doc…
adityacodes30 Feb 22, 2024
b690edf
feat(@stdlib/assert): add isDateObject function,requested changes,#1337
adityacodes30 Feb 23, 2024
d426b82
feat(@stdlib/assert): add isDateObject function,requested changes,#1337
adityacodes30 Feb 29, 2024
8dfcc54
Update lib/node_modules/@stdlib/assert/is-same-date-object/docs/repl.txt
adityacodes30 Mar 1, 2024
8c73111
feat(@stdlib/assert): add isDateObject function,requested changes,#1337
adityacodes30 Mar 1, 2024
f1710dd
feat(@stdlib/assert): add isDateObject function,requested changes,#1337
adityacodes30 Mar 1, 2024
bc9877a
Update lib/node_modules/@stdlib/assert/is-same-date-object/benchmark/…
adityacodes30 Mar 1, 2024
59fb3c9
Update lib/node_modules/@stdlib/assert/is-same-date-object/docs/repl.txt
adityacodes30 Mar 1, 2024
bb1a8ae
feat(@stdlib/assert): add isDateObject function,requested changes,#1337
adityacodes30 Mar 1, 2024
87f1275
Merge branch 'is-same-date-object' of https://github.com/adityacodes3…
adityacodes30 Mar 1, 2024
34d7024
Update lib/node_modules/@stdlib/assert/is-same-date-object/package.json
Planeshifter Mar 3, 2024
7445142
Update lib/node_modules/@stdlib/assert/is-same-date-object/docs/repl.txt
Planeshifter Mar 3, 2024
0cefc0e
Update lib/node_modules/@stdlib/assert/is-same-date-object/docs/repl.txt
Planeshifter Mar 3, 2024
063b38e
Update lib/node_modules/@stdlib/assert/is-same-date-object/examples/i…
Planeshifter Mar 3, 2024
fdf2ab4
Update lib/node_modules/@stdlib/assert/is-same-date-object/examples/i…
Planeshifter Mar 3, 2024
b0cda06
Update lib/node_modules/@stdlib/assert/is-same-date-object/examples/i…
Planeshifter Mar 3, 2024
50a5189
Update lib/node_modules/@stdlib/assert/is-same-date-object/examples/i…
Planeshifter Mar 3, 2024
9aadb60
Update lib/node_modules/@stdlib/assert/is-same-date-object/examples/i…
Planeshifter Mar 3, 2024
d38aa8b
Update lib/node_modules/@stdlib/assert/is-same-date-object/package.json
Planeshifter Mar 3, 2024
6cda4aa
Update lib/node_modules/@stdlib/assert/is-same-date-object/examples/i…
Planeshifter Mar 3, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
91 changes: 91 additions & 0 deletions lib/node_modules/@stdlib/assert/is-same-date-object/README.md
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 -->
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 lib/node_modules/@stdlib/assert/is-same-date-object/docs/repl.txt
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
--------

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;
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
}
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 lib/node_modules/@stdlib/assert/is-same-date-object/lib/index.js
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;
Loading