Data::Sah::Compiler::js::TH::date - js's type handler for type "date"
This document describes version 0.87 of Data::Sah::Compiler::js::TH::date (from Perl distribution Data-Sah-JS), released on 2016-09-14.
Unlike in perl compiler where the date type can be represented either as int (epoch), DateTime object or Time::Moment object, in js compiler we only represent date with the Date object.
Date() accept various kinds of arguments, including:
Date(year, month, date, hour, minute, sec, millisec)
But year is 114 utk 2014, month=0 for January.
This saves us from doing date parsing ourselves.
Date(another Date object)
But note that if the arguments are invalid, Date() will still return a Date object, but if we try to do d.getMonth() or d.getYear() it will return NaN. This can be used to check that a date is invalid: isNaN(d.getYear()) or simply <isNaN(d)>.
To compare 2 Date object, we can use d1 > d2, d1 < d2, but for anything involving equality check, we need to prefix using +, +d1 === +d2.
d1 > d2
d1 < d2
+d1 === +d2
Please visit the project's homepage at https://metacpan.org/release/Data-Sah-JS.
Source repository is at https://github.com/perlancar/perl-Data-Sah-JS.
Please report any bugs or feature requests on the bugtracker website https://rt.cpan.org/Public/Dist/Display.html?Name=Data-Sah-JS
When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature.
This software is copyright (c) 2016 by email@example.com.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install Data::Sah::JS, copy and paste the appropriate command in to your terminal.
perl -MCPAN -e shell
For more information on module installation, please visit the detailed CPAN module installation guide.