daze
Module to manage simple 8-digit integer dates.
npm install daze
Usage
- To Date - Get a standard Javascript
Date
object. - To Daze - Get an 8-digit integer to save/JSON/compare with.
- Is Late - Determine if
dateA
has occurred sincedateB
. - Is Greater - Compare two dates to find if
dateA
comes afterdateB
. - Is Lesser - Compare two dates to find if
dateA
comes beforedateB
. - Days Past - Get a whole integer representing the amount of days from
dateA
sincedateB
(can be negative - will still be whole.) - Days Until - Get a whole integer representing the amount of days from
dateA
todateB
(can be negative - will still be whole.)
String date formats may conflict with your processing time zone. If you receive a formatted date string, from something like Date.toISOString
, from a source in another time zone then you'll encounter a conflict when daze
'ing. Try sharing daze
'ed values or, instead, daze
formatted string values from sources with expected time zones. Maybe this can be a to-do?.. maybe regex/parse values out of strings of known standards?
All examples below assume April 3rd, 2016 - the day of this writing - if not otherwise specified.
Using Two Dates
Both dateA
and dateB
can be different date types - those types are shown in examples further below.
var dateA = 20160401;var dateB = 20160501; ;;;;;;;
Using No Dates
When you do not provide a date, today - or daze().toDaze()
- is assumed.
; // 20160403 === ;
Using Different Date Types
All the below would return 20160403
.
;;;;
Programmatically
Standard Usage Examples
var daze = ; /* As of this writing, this month - April - has// 30 days. The below examples illustrate some// general usage with real results.*/console; // "[Function: daze]" console; // 20160403console; // Sun Apr 03 2016 19:09:49 GMT-0500 (CDT) console; // trueconsole; // trueconsole; // false console; // 2console; // 0console; // -27 console; // -2console; // 0console; // 27 console; // trueconsole; // true
Within The Browser
Standard Usage Examples