d2l-insights-utils v0.11.0
d2l-insights-utils
A collection of shared utils for insights reports
Overview
This library contains common used functions for Insights reports.
API Docs
date.getDaysAgoUTC(daysAgo, dateMs)
return UTCMilliSeconds that was daysAgo
from dateMs
date.getMonthsAgoUTC(monthsAgo, dateMs)
return UTCMilliSeconds that was monthsAgo
from dateMs
date.getYearsAgoUTC(yearsAgo, dateMs)
return UTCMilliSeconds that was yearsAgo
from dateMs
date.formatDateUTC(date)
formate a UTCMilliSeconds into %B %e, %Y
format.
date.formatDateUTCMonth(date)
formate a UTCMilliSeconds into %B %Y
format.
date.getTimestampAtUtcMidnight(timestamp)
reset a UTCMilliSeconds to previous midnight
date.isValidTimezone(timezone)
returns true if the timezone is valid, false otherwise
date.getStartOfDayForTimezone(timezone)
get the start of day for a timezone
date.getStartOfDayLastNDaysForTimezone(timezone, numberOfdays)
returns an array of timestamps for the last number of days for a timezone with each value being the start of day
date.getMetronOffsetTimezone(utcTimestamp, metronTimezone)
takes a utcTimestamp and returns another timestamp that represents the same relative date in the metronTimezone
logger.*
Simple logger functions
string.replaceAll(value, search, replace)
replace all occurance of search
with replace
in value
helpers.checkNullOrUndefined
Check if a variable is null or undefined (returns true if it is null or undefined)
Command quick reference:
- Running Unit Tests:
karma start test/karma.conf.js