isDateObj ( dateObj )
returns a boolean
, is the given dateObj a valid Date object?
ex,
simpletime.isDateObj(new Date())
getDateYNum ( dateObj )
returns a number
, the year on the date object.
ex,
simpletime.getDateYNum(new Date())
getDateYStr ( dateObj )
returns a string
, the year on the date object.
ex,
simpletime.getDateYStr(new Date())
getDateMNum ( dateObj )
returns a number
, the month on the date object.
ex,
simpletime.getDateMNum(new Date())
getDateMStr ( dateObj )
returns a string
, the month on the date object.
ex,
simpletime.getDateMStr(new Date())
getDateDNum ( dateObj )
returns a number
, the day on the date object.
ex,
simpletime.getDateDNum(new Date())
getDateDStr ( dateObj )
returns a string
, the day on the date object.
ex,
simpletime.getDateDStr(new Date())
getDateYMDNumArr ( dateObj )
return an array of numbers, the YNum, MNum and DNum of a date object.
ex,
simpletime.getDateYMDNumArr(new Date())
getDateYMDStrArr ( dateObj )
return an array of strings, the YStr, MStr and DStr of a date object.
ex,
simpletime.getDateYMDStrArr(new Date())
getYMDArrDate ( ymdArr )
return a Date object from a YMDNumArr or YMDStrArr
ex,
simpletime.getYMDArrDate([2016, 12, 31])
getMinFromDate ( dateObj, optNum )
return a Date object with given number of minutes added.
ex,
var date = new Date('Sat Dec 31 2016 17:43:20 GMT-0800 (PST)');
simpletime.getMinFromDate(date, 5);
simpletime.getMinFromDate(date, 50);
simpletime.getMinFromDate(date, -5);
simpletime.getMinFromDate(date, -50);
getMinFromTodayDate ( optNum )
returns a Date object with given number of minutes added to now's new Date()
ex
simpletime.getMinFromTodayDate(5);
simpletime.getMinFromTodayDate(50);
simpletime.getMinFromTodayDate(-5);
simpletime.getMinFromTodayDate(-50);
getDayFromDate ( dateObj, optNum )
returns a Date object with given number of days added
ex,
var date = new Date('Sat Dec 31 2016 17:43:20 GMT-0800 (PST)');
simpletime.getDayFromDate(date, 5);
simpletime.getDayFromDate(date, 50);
simpletime.getDayFromDate(date, -5);
simpletime.getDayFromDate(date, -50);
getDayFromTodayDate ( optNum )
returns a Date object with given number of days added to now's new Date()
ex,
simpletime.getDayFromTodayDate(5);
simpletime.getDayFromTodayDate(50);
simpletime.getDayFromTodayDate(-5);
simpletime.getDayFromTodayDate(-50);
getMonthFromDate ( dateObj, optNum )
returns a Date object with given number of months added
ex,
var date = new Date('Sat Dec 31 2016 17:43:20 GMT-0800 (PST)');
simpletime.getMonthFromDate(date, 5);
simpletime.getMonthFromDate(date, 50);
simpletime.getMonthFromDate(date, -5);
simpletime.getMonthFromDate(date, -50);
getMonthFromTodayDate ( optNum )
returns a Date object with given number of months added to now's Date.now()
ex,
simpletime.getMonthFromTodayDate(5);
simpletime.getMonthFromTodayDate(50);
simpletime.getMonthFromTodayDate(-5);
simpletime.getMonthFromTodayDate(-50);
getYearFromDate ( optNum )
returns a Date object with given number of years added
ex,
var date = new Date('Sat Dec 31 2016 17:43:20 GMT-0800 (PST)');
simpletime.getYearFromDate(date, 5);
simpletime.getYearFromDate(date, 50);
simpletime.getYearFromDate(date, -5);
simpletime.getYearFromDate(date, -50);
getYearFromTodayDate ( optNum )
returns a Date object with given number of years added to now's Date.now()
ex,
simpletime.getYearFromTodayDate(5);
simpletime.getYearFromTodayDate(50);
simpletime.getYearFromTodayDate(-5);
simpletime.getYearFromTodayDate(-50);
getDaysInMonth ( yearNum, monthNum )
return the number of days found in the give month for the given year
ex,
simpletime.getDaysInMonth(2015, 2);
simpletime.getDaysInMonth(2014, 2);
simpletime.getDaysInMonth(2013, 2);
simpletime.getDaysInMonth(2012, 2);
getMFittedYMDNumArr ( YMDNumArr )
return a YMDNumArr with the month value 'fitted' to fall within the range of 1 and 12.
ex,
simpletime.getMFittedYMDNumArr([2015, 2, 2]);
simpletime.getMFittedYMDNumArr([2015, 0, 2]);
simpletime.getMFittedYMDNumArr([2015, 13, 2]);
getDFittedYMDNumArr ( YMDNumArr )
return a YMDNumArr with the day value 'fitted' to fall within the range of days in the given month and year.
ex,
simpletime.getDFittedYMDNumArr([2015, 2, 2]);
simpletime.getDFittedYMDNumArr([2015, 2, -4]);
simpletime.getDFittedYMDNumArr([2015, 2, 35]);
simpletime.getDFittedYMDNumArr([2012, 2, 35]);
getTimeBgnMonth ( dateObj )
return a date from given dateObj, set to day 1, hour 0, minute 0, second 0, millisecond 0
ex,
simpletime.getTimeBgnMonth(
new Date('Sat Dec 31 2016 17:43:20 GMT-0800 (PST)')
)
getTimeEndMonth ( dateObj )
return a date from given dateObj, set to day last, hour 23, minute 59, second 59, millisecond 999
ex,
simpletime.getTimeEndMonth(
new Date('Sat Dec 31 2016 17:43:20 GMT-0800 (PST)')
)
getTimeBgnDay ( dateObj )
return a date from given dateObj, set to hour 0, minute 0, second 0, millisecond 0
ex,
simpletime.getTimeBgnDay(
new Date('Sat Dec 31 2016 17:43:20 GMT-0800 (PST)')
)
getTimeEndDay ( dateObj )
return a date from given dateObj, set to hour 23, minute 0, second 0, millisecond 0
ex,
simpletime.getTimeEndDay(
new Date('Sat Dec 31 2016 17:43:20 GMT-0800 (PST)')
)
isDateBeforeDate ( dateObj, dateObj )
return a boolean value, is the date object before given date?
ex,
simpletime.isDateBeforeDate(
new Date('Sat Dec 31 2016 17:43:20 GMT-0800 (PST)'),
new Date('Sat Dec 31 2016 6:43:20 GMT-0800 (PST)')
)
isDateBeforeToday ( dateObj )
return a boolean value, is the date object before date.now()?
ex,
Date.now();
simpletime.isDateBeforeToday(
new Date('Sat Dec 31 2016 6:43:20 GMT-0800 (PST)')
)
parseISO8601 ( str )
return a date object from a simple ISO formatted string date, format yyyy.mm.dd, yyyy/mm/dd, or yyyy-mm-dd
ex,
simpletime.parseISO8601('2016/12/31');
parseUSEndian ( str )
return a date object from a simple endian formatted string date, format mm.dd.yyyy, mm/dd/yyyy, or mm-dd-yyyy
ex,
simpletime.parseISO8601('12/31/2016');
yieldRangeMonthly ( bgnDateObj, endDateObj, fn )
return a monthly array of dates within the range of bgnDate and endDate. An optional filter function may be provided as the third parameter.
ex,
var bgndate = new Date('Sat Dec 5 2015 17:43:20 GMT-0800 (PST)'),
enddate = new Date('Sat Dec 31 2016 17:43:20 GMT-0800 (PST)');
simpletime.yieldRangeMonthly(bgndate, enddate);
yieldRangeDaily ( bgnDateObj, endDateObj, fn )
return a daily array of dates within the range of bgnDate and endDate. An optional filter function may be provided as the third parameter.
ex,
var bgndate = new Date('Sat Dec 23 2016 17:43:20 GMT-0800 (PST)'),
enddate = new Date('Sat Dec 31 2016 17:43:20 GMT-0800 (PST)');
simpletime.yieldRangeDaily(bgndate, enddate);