JavaScript:
var PartTime = require("parttime");
var parttime = new PartTime("*-01-01");
var now = new Date();
if (parttime.compare(now) == 0) console.log("Happy New Year!");
TypeScript:
import PartTime = require("parttime");
const parttime = new PartTime("*-01-01");
const now = new Date();
if (parttime.compare(now) == 0) console.log("Happy New Year!");
In browser:
<script src="parttime.js"></script>
<script>
var parttime = new PartTime("*-01-01");
var now = new Date();
if (parttime.compare(now) == 0) console.log("Happy New Year!");
</script>
PartTime represents a single moment in time with placeholder that is useful for compareing repeating moment.
Currently, PartTime does not support timezones.
new PartTime()
new PartTime("*-10-12")
new PartTime("1970-1-1")
new PartTime("1970-1-1T00:*")
new PartTime("*:00:00.000")
new PartTime("*:*:30")
new PartTime("1970-1-1T00:00:00.000")
npm install -g parttime
Get parttime.js by downloading dist zip or some and
<script src="parttime.js"></script>
(C) 2019 Narazaka : Licensed under Zlib License