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
Compare(Libraries.Language.Object object)This action compares two object hash codes and returns a CompareResult.
Equals(Libraries.Language.Object object)This action determines if two objects are equal based on their hash code values.
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.
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.
GetMinute()This action returns the minute represented by this DateTime object.
GetMonth()This action returns the month represented by this DateTime object.
GetSecond()This action returns the second represented by this DateTime object.
GetTimeZone()This action returns the timezone of the system.
GetYear()This action returns the year represented by this DateTime object.
IsDaylightSavings()This action returns whether or not the current system is observing daylight savings time.
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.

Actions Documentation

Compare(Libraries.Language.Object object)

This action compares two object hash codes and returns a CompareResult. The compare result is either larger if this hash code is larger than the object passed as a parameter, smaller, or equal.

Example Code

use Libraries.Language.Support.CompareResult
        Object o
        Object t
        CompareResult result = o:Compare(t)

Parameters

Return

Libraries.Language.Support.CompareResult: The Compare result, Smaller, Equal, or Larger.

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.

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

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

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

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

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

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.

GetYear()

This action returns the year represented by this DateTime object.

Example Code

DateTime datetime
    output datetime:GetYear()

Return

integer: the year

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

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