justinmimbs / date-functions

Utility functions for working with Dates in JavaScript

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

date-functions

Utility functions for working with Dates in JavaScript. All functions are side-effect free, returning new Dates, and never mutating Dates passed in.

lib/date-functions.js exports the following functions:

isDate(value, acceptInvalidDate) // -> Boolean
isDateString(string) // -> Boolean
dateFromString(string) // -> Date
dateToUTC(date) // -> Date
dateFormat(format, date) // -> String
dateFloor(interval, date) // -> Date
dateCeil(interval, date) // -> Date
dateAdd(unit, n, date) // -> Date
dateDiff(unit, date1, date2) // -> Number
dateRange(interval, date1, date2, step) // -> [Date]

where unit is one of the following strings, representing a date part:

'ms'
'second'
'minute'
'hour'
'day'
'week'
'month'
'year'

and interval is either a unit as listed above or one of:

'monday'
'tuesday'
'wednesday'
'thursday'
'friday'
'saturday'
'sunday'
'quarter'

About

Utility functions for working with Dates in JavaScript


Languages

Language:JavaScript 98.9%Language:HTML 1.1%