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

Summary

Actions Summary Table

ActionsDescription
AddDays(integer days)
AddHours(integer hours)
AddMinutes(integer minutes)
AddMonths(integer months)
AddSeconds(integer seconds)
AddWeeks(integer weeks)
AddYears(integer years)
Compare(Libraries.Language.Object object)
DateToText()
Equals(Libraries.Language.Object object)This action determines if two objects are equal based on their hash code values.
GetDayDifference(Libraries.System.DateTime time)
GetDayOfMonth()This action returns the day of the month represented by this DateTime object.
GetDayOfWeek()This action returns the day of the week represented by this DateTime object.
GetDayOfWeekName()
GetEpochTime()This action returns the elapsed milliseconds since the epoch, January 1, 1970 00:00:00 GMT, as reported by the system.
GetHashCode()This action gets the hash code for an object.
GetHour()This action returns the hour represented by this DateTime object.
GetHourDifference(Libraries.System.DateTime time)
GetMillisecondDifference(Libraries.System.DateTime time)
GetMinute()This action returns the minute represented by this DateTime object.
GetMinuteDifference(Libraries.System.DateTime time)
GetMonth()This action returns the month represented by this DateTime object.
GetMonthDifference(Libraries.System.DateTime time)
GetMonthName()
GetSecond()This action returns the second represented by this DateTime object.
GetSecondDifference(Libraries.System.DateTime time)
GetShortDayofWeekName()
GetShortMonthName()
GetTimeZone()This action returns the timezone of the system.
GetTimestamp()
GetYear()This action returns the year represented by this DateTime object.
IsAfter(Libraries.System.DateTime time)
IsBefore(Libraries.System.DateTime time)
IsDaylightSavings()This action returns whether or not the current system is observing daylight savings time.
Now()
ParseAmericanDate(text date)
ParseDate(text date)
ParseTime(text time, boolean keepDate)
ParseTime(text time)
ParseTimestamp(text timestamp)
SetEpochTime(number epochTime)This action sets the date/time to be represented by this DateTime instance to the specified epochTime value.
SetTimeZone(integer timeZoneOffset)This action sets the time zone offset to be used when returning various date/time information to the user.
SubtractDays(integer days)
SubtractHours(integer hours)
SubtractMinutes(integer minutes)
SubtractMonths(integer months)
SubtractSeconds(integer seconds)
SubtractWeeks(integer weeks)
SubtractYears(integer years)
TimeToText()
ToText()

Actions Documentation

AddDays(integer days)

Parameters

AddHours(integer hours)

Parameters

AddMinutes(integer minutes)

Parameters

AddMonths(integer months)

Parameters

AddSeconds(integer seconds)

Parameters

AddWeeks(integer weeks)

Parameters

AddYears(integer years)

Parameters

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.

Example Code

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

Parameters

Return

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

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.

Example Code

DateTime datetime
    output datetime:GetDayOfMonth()

Return

integer: the day of the month

GetDayOfWeek()

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

Example Code

DateTime datetime
    output datetime:GetDayOfWeek()

Return

integer: the day of the week

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.

Example Code

DateTime datetime
    output datetime:GetEpochTime()

Return

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

GetHashCode()

This action gets the hash code for an object.

Example Code

Object o
        integer hash = o:GetHashCode()

Return

integer: The integer hash code of the object.

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.

Example Code

DateTime datetime
    output datetime:GetHour()

Return

integer: the hour

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.

Example Code

DateTime datetime
    output datetime:GetMinute()

Return

integer: the minute

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.

Example Code

DateTime datetime
    output datetime:GetMonth()

Return

integer: the month

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.

Example Code

DateTime datetime
    output datetime:GetSecond()

Return

integer: the second

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.

Example Code

DateTime datetime
    output datetime:GetTimeZone()

Return

integer: the timezone offset from UTC.

GetTimestamp()

Return

text

GetYear()

This action returns the year represented by this DateTime object.

Example Code

DateTime datetime
    output datetime:GetYear()

Return

integer: the year

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.

Example Code

DateTime datetime
    boolean dst = datetime:IsDaylightSavings()

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

Return

boolean: whether or no daylight savings time is being observed

Now()

Return

number

ParseAmericanDate(text date)

Parameters

ParseDate(text date)

Parameters

ParseTime(text time, boolean keepDate)

Parameters

ParseTime(text time)

Parameters

ParseTimestamp(text timestamp)

Parameters

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.

Example Code

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

Parameters

SetTimeZone(integer timeZoneOffset)

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

Example Code

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

Parameters

SubtractDays(integer days)

Parameters

SubtractHours(integer hours)

Parameters

SubtractMinutes(integer minutes)

Parameters

SubtractMonths(integer months)

Parameters

SubtractSeconds(integer seconds)

Parameters

SubtractWeeks(integer weeks)

Parameters

SubtractYears(integer years)

Parameters

TimeToText()

Return

text

ToText()

Return

text