isCurrentYear
Test if a value is the current year.
Usage
var isCurrentYear = require( '@stdlib/assert/is-current-year' );
isCurrentYear( value )
Tests if a value
is either an integer equal to the current year or a Date
object representing the current year.
var currentYear = require( '@stdlib/time/current-year' );
var bool = isCurrentYear( currentYear() );
// returns true
bool = isCurrentYear( 2021 );
// returns false
Examples
var currentYear = require( '@stdlib/time/current-year' );
var isCurrentYear = require( '@stdlib/assert/is-current-year' );
var bool = isCurrentYear( new Date() );
// returns true
bool = isCurrentYear( currentYear() );
// returns true
bool = isCurrentYear( 2021 );
// returns false
bool = isCurrentYear( null );
// returns false
CLI
Usage
Usage: is-current-year [options] [<year>]
Options:
-h, --help Print this message.
-V, --version Print the package version.
--split sep Delimiter for stdin data. Default: '/\\r?\\n/'.
Notes
If the split separator is a regular expression, ensure that the
split
option is either properly escaped or enclosed in quotes.# Not escaped... $ echo -n $'1998\n1999' | is-current-year --split /\r?\n/ # Escaped... $ echo -n $'1998\n1999' | is-current-year --split /\\r?\\n/
The implementation ignores trailing delimiters.
Examples
$ is-current-year 2011
false
To use as a standard stream,
$ echo -n 1914 | is-current-year
false
By default, when used as a standard stream, the implementation assumes newline-delimited data. To specify an alternative delimiter, set the split
option.
$ echo -n '2001\t2002' | is-current-year --split '\t'
false
false