TimeUtils

Library that exposes a dictionary of time periods and subroutine to calculate relative time periods.

\TimeUtils\Periods

Description: Dictionary containing time periods. (Not a function) .
Returns: Timestamp
Usage: Script or steady state.
Function Groups: Time and Date
Related to:  
Format: \TimeUtils\Periods
Parameters:  
PeriodName

Text. May be any of the following:

  • CurrentDay
  • CurrentMonth
  • CurrentQuarter
  • CurrentWeek
  • CurrentYear
  • PreviousDay
  • PreviousMonth
  • PreviousQuarter
  • PreviousWeek
  • PreviousYear
BoundaryName

Text. Specifies the start or end boundary of the period, in either UTC or local time. May be any of the following:

  • EndTimeLocal
  • EndTimeUTC
  • StartTimeLocal
  • StartTimeUTC

Comments:

Periods update each time a new period begins. Note that UTC time is adjusted for the local time zone. For example, in ADT (GMT - 3), the start of the CurrentDay when this text was written is returned as April 19, 2018, 03:00:00.00

Example:

\TimeUtils\Periods["CurrentWeek"]["StartTimeUTC"]

returns: 1523847600 (April 16, 2018, 03:00:00.00), when run on April 19th, 2018 in Atlantic Daylight Time.

 

\TimeUtils\GetPeriods

Description: Subroutine that calculates time periods relative to a given time stamp.
Returns: Dictionary
Usage: Script or steady state.
Function Groups: Time and Date
Related to:  
Format: \TimeUtils\GetPeriods(PeriodName[, ReferenceTimestamp, WeekStartDay, WholePeriod])
Parameters:  
PeriodName

Text. May be any of the following:

  • CurrentDay
  • CurrentMonth
  • CurrentQuarter
  • CurrentWeek
  • CurrentYear
  • PreviousDay
  • PreviousMonth
  • PreviousQuarter
  • PreviousWeek
  • PreviousYear
ReferenceTimestamp

Optional Numeric. Local time, for which relative periods are to be calculated. Defaults to current time.

WeekStartDay
Optional numeric. Specifies which day a week is considered to start on. 0 for Sunday, 1 for Monday, etc. Defaults to the value of the application property, \StartOfWeek.
WholePeriod
Optional Boolean. If TRUE, the EndTime is the end of the full period rather than the ReferenceTime. Defaults to FALSE.

Comments:

The returned dictionary contains all four boundaries of the specified period: "EndTimeLocal", "EndTimeUTC", "StartTimeLocal", "StartTimeUTC".