Libraries.System.DateTime Documentation

The DateTime class is used to gather information about date and time on the system, or from a specified date/time. On creation, this object will return information pertaining to the current date and time as reported by the system. This class can also be used to gather information about a different date and time using the standard epoch time and the SetEpochTime() action. If SetEpochTime() is not called, information about the current date and time will be returned by the various functions.

Example Code

use Libraries.System.DateTime

class Main
action main
    DateTime datetime
    // Print the current date and time.
    output datetime:GetMonth() + " " + datetime:GetDayOfMonth() + ", " + datetime:GetYear() + " " datetime:GetHour() + ":" + datetime:GetMinutes()
end

Inherits from: Libraries.Language.Object

Actions Documentation

AddDays(integer days)

Parameters

  • integer days

AddHours(integer hours)

Parameters

  • integer hours

AddMinutes(integer minutes)

Parameters

  • integer minutes

AddMonths(integer months)

Parameters

  • integer months

AddSeconds(integer seconds)

Parameters

  • integer seconds

AddWeeks(integer weeks)

Parameters

  • integer weeks

AddYears(integer years)

Parameters

  • integer years

Compare(Libraries.Language.Object object)

Parameters

Return

integer

DateToText()

Return

text

Equals(Libraries.Language.Object object)

This action determines if two objects are equal based on their hash code values.

Parameters

Return

boolean: True if the hash codes are equal and false if they are not equal.

Example

use Libraries.Language.Object
use Libraries.Language.Types.Text
Object o
Text t
boolean result = o:Equals(t)

GetDayDifference(Libraries.System.DateTime time)

Parameters

Return

number

GetDayOfMonth()

This action returns the day of the month represented by this DateTime object. The day is in the range 1 to 31, inclusive.

Return

integer: the day of the month

Example

DateTime datetime
output datetime:GetDayOfMonth()

GetDayOfWeek()

This action returns the day of the week represented by this DateTime object. The day is in the range 1 to 7, inclusive.

Return

integer: the day of the week

Example

DateTime datetime
output datetime:GetDayOfWeek()

GetDayOfWeekName()

Return

text

GetEpochTime()

This action returns the elapsed milliseconds since the epoch, January 1, 1970 00:00:00 GMT, as reported by the system. This time can be used to store a date and use it at a later time to retrieve information such as the hour. This action will always return the current epoch time, regardless of whether or not SetEpochTime() has been called.

Return

number: Returns the elapsed time since the epoch as reported by the system.

Example

DateTime datetime
output datetime:GetEpochTime()

GetHashCode()

This action gets the hash code for an object.

Return

integer: The integer hash code of the object.

Example

Object o
integer hash = o:GetHashCode()

GetHour()

This action returns the hour represented by this DateTime object. The hour is in the range 0 to 23, where 0-12 represent the times 12 AM to 12 PM, and 13-23 represent 1 PM to 11 PM.

Return

integer: the hour

Example

DateTime datetime
output datetime:GetHour()

GetHourDifference(Libraries.System.DateTime time)

Parameters

Return

number

GetMillisecondDifference(Libraries.System.DateTime time)

Parameters

Return

number

GetMinute()

This action returns the minute represented by this DateTime object. The minute is in the range 0 to 59, inclusive.

Return

integer: the minute

Example

DateTime datetime
output datetime:GetMinute()

GetMinuteDifference(Libraries.System.DateTime time)

Parameters

Return

number

GetMonth()

This action returns the month represented by this DateTime object. The month is in the range 1 to 12, inclusive.

Return

integer: the month

Example

DateTime datetime
output datetime:GetMonth()

GetMonthDifference(Libraries.System.DateTime time)

Parameters

Return

number

GetMonthName()

Return

text

GetSecond()

This action returns the second represented by this DateTime object. The second is in the range 0 to 59, inclusive.

Return

integer: the second

Example

DateTime datetime
output datetime:GetSecond()

GetSecondDifference(Libraries.System.DateTime time)

Parameters

Return

number

GetShortDayofWeekName()

Return

text

GetShortMonthName()

Return

text

GetTimeZone()

This action returns the timezone of the system. The timezone is reported as an offset of UTC. For example, Central Standard Time in the United States is UTC - 6.

Return

integer: the timezone offset from UTC.

Example

DateTime datetime
output datetime:GetTimeZone()

GetTimestamp()

Return

text

GetYear()

This action returns the year represented by this DateTime object.

Return

integer: the year

Example

DateTime datetime
output datetime:GetYear()

IsAfter(Libraries.System.DateTime time)

Parameters

Return

boolean

IsBefore(Libraries.System.DateTime time)

Parameters

Return

boolean

IsDaylightSavings()

This action returns whether or not the current system is observing daylight savings time.

Return

boolean: whether or no daylight savings time is being observed

Example

DateTime datetime
boolean dst = datetime:IsDaylightSavings()

if dst
    output "Spring forward"
else
    output "Fall back"
end

Now()

Return

number

ParseAmericanDate(text date)

Parameters

  • text date

ParseDate(text date)

Parameters

  • text date

ParseTime(text time, boolean keepDate)

Parameters

  • text time
  • boolean keepDate

ParseTime(text time)

Parameters

  • text time

ParseTimestamp(text timestamp)

Parameters

  • text timestamp

SetEpochTime(number epochTime)

This action sets the date/time to be represented by this DateTime instance to the specified epochTime value. Once this function is called, this DateTime instance cannot be used to get the current date/time.

Parameters

  • number epochTime: - the number of milliseconds that have elapsed since the epoch, returned by GetEpochTime().

Example

DateTime datetime
// Set this instance to the exact time of the epoch.
datetime:SetEpochTime(0)
output datetime:GetMonth() // will return 1 for January

SetTimeZone(integer timeZoneOffset)

This action sets the time zone offset to be used when returning various date/time information to the user.

Parameters

  • integer timeZoneOffset

Example

DateTime datetime
datetime:SetTimeZone(0) // set time zone to UTC.
output "The current UTC hour is " + datetime:GetHour()

SubtractDays(integer days)

Parameters

  • integer days

SubtractHours(integer hours)

Parameters

  • integer hours

SubtractMinutes(integer minutes)

Parameters

  • integer minutes

SubtractMonths(integer months)

Parameters

  • integer months

SubtractSeconds(integer seconds)

Parameters

  • integer seconds

SubtractWeeks(integer weeks)

Parameters

  • integer weeks

SubtractYears(integer years)

Parameters

  • integer years

TimeToText()

Return

text

ToText()

Return

text