compare24hTime
integer
compare24hTime(a, b)
comparator for the 24h part of the clock
- Parameters:
-
a <Date> -
b <Date>
- Returns:
integer - [-1, 0, +1]
formatDuration
private
string
formatDuration(duration, [shortFormat=false])
todo: support stopping (rounding) on for example hours or minutes (i.e no ms..)
todo: this is currently not that general, more or less tailored for VT fatpoint display.. (only shortformat is "ok")
- Parameters:
-
duration <integer[7]>([y, m, d .. ]) output from getDifference -
[shortFormat=false] <boolean>
- Returns:
string
fuzzyDateParse
integer[3]
fuzzyDateParse(strDate)
parses "YYYY-MM-DD", "YY-MM-DD" or "MM-DD" format. "MM-DD" assumes current year.
note: doesn't validate the actual date based on days in month or leapyears etc (add as optional flag?)
todo: settings param?
todo: allow '/' and '\' also?
- Parameters:
-
strDate <string>
- Returns:
integer[3] [yyyy, mm, dd], nullif format error. note:! month is 1..12 Not 0..11 as JS Date uses!
fuzzyDateTimeParse
Date
fuzzyDateTimeParse(dateTime)
parses human-friendly datetime strings.
parses same formats as fuzzyTimeParse() and fuzzyDateParse() but in same string and in any order. todo: add optional setting params. todo: allow special cased "today", "tomorrow", "+10 min" etc input? :) (cron style?)
parses same formats as fuzzyTimeParse() and fuzzyDateParse() but in same string and in any order. todo: add optional setting params. todo: allow special cased "today", "tomorrow", "+10 min" etc input? :) (cron style?)
- Parameters:
-
dateTime <string>
- Returns:
Date
fuzzyTimeParse
integer[3]
fuzzyTimeParse(strTime)
parses 24h time in either "hh:mm" or "hh:mm:ss" format
todo: support AM/PM format
- Parameters:
-
strTime <string>
- Returns:
integer[3] - [hh, mm, ss] or null if format error
get24hTime
integer
get24hTime([date=now])
- Parameters:
-
[date=now] <Date>
- Returns:
integer - number of milliseconds passed since 00:00 (current 24h) for the current date
getDaysInMonth
integer
getDaysInMonth(year, month)
- Parameters:
-
year <integer> -
month <integer>
- Returns:
integer
getFirstDayofMonth
integer
getFirstDayofMonth(year, month)
- Parameters:
-
year <integer> -
month <integer>
- Returns:
integer
getHourMinSecDiff
integer[3]
getHourMinSecDiff(dateA, dateB)
note: hours is not bound to 24h (since we're not extracting months, days etc)
- Parameters:
-
dateA <Date> -
dateB <Date>
- Returns:
integer[3] [hour, min, sec]absolute difference.
guessCentury
integer
guessCentury(year, [cutoffYear=(19)68])
Guesses the century for two-digit years.
according to the X/Open CAE specifications. 0->68 20th century, 69->99 21th century todo: hmm, MySQL uses 1969 and others 1970, MS Excel 1929, MSSql Server 1949, OLE 1930, 38 etc..
according to the X/Open CAE specifications. 0->68 20th century, 69->99 21th century todo: hmm, MySQL uses 1969 and others 1970, MS Excel 1929, MSSql Server 1949, OLE 1930, 38 etc..
- Parameters:
-
year <integer> -
[cutoffYear=(19)68] <integer>
- Returns:
integer - four-digit year
isSameDay
boolean
isSameDay(dateA, dateB)
example:
var isToday = isSameDay(new Date(), date);
- Parameters:
-
dateA <Date> -
dateB <Date>
- Returns:
boolean
isValidDate
boolean
isValidDate(year, month, [day=1], [hours=0], [minutes=0], [seconds=0])
- Parameters:
-
year <integer>uses guessCentury() if only a two digit number is given. -
month <integer>note: validated as 1-based -
[day=1] <integer> -
[hours=0] <integer> -
[minutes=0] <integer> -
[seconds=0] <integer>
- Returns:
boolean