Bundle Date, time, and elapsed-timer utilities. Date provides current date/time and arithmetic (AddDays, AddHours). Timer measures wall-clock elapsed time. Included in lang.obl.
DateUtility
Utilities for handling dates
date := DateUtility->Parse("12/25/2024", "MM/dd/yyyy", false);
date->GetMonth()->PrintLine();
date->GetDay()->PrintLine();
date->GetYear()->PrintLine();Operations
Format # function
Formats date into a string
function : Format(date:System.Time.Date, format:String) ~ StringParameters
| Name | Type | Description |
|---|---|---|
| date | Date | date |
| format | String | date string format options:
|
Return
| Type | Description |
|---|---|
| String | Date instance |
Example
date := DateUtility->Parse("01/20/2025", "MM/dd/yyyy", false);
formatted := DateUtility->Format(date, "dd-MM-yyyy");
formatted->PrintLine();GetNetworkTime # function
Get the network time
function : GetNetworkTime() ~ Collection.Tuple.Triplet<IntRef,Date,Date>Return
| Type | Description |
|---|---|
| CollectionTupleTriplet<IntRef,Date,Date> | triplet with: unix time, UTC time and local time |
Example
triplet := DateUtility->GetNetworkTime();
if(triplet <> Nil) {
utc := triplet->GetSecond();
Console->Print("UTC year: ")->PrintLine(utc->GetYear());
};Parse # function
Parses a date from a String.
function : Parse(date_str:String, format:String, gmt:Bool) ~ DateParameters
| Name | Type | Description |
|---|---|---|
| date_str | String | date |
| format | String | date string format options:
|
| gmt | Bool | true is GMT, false otherwise |
Return
| Type | Description |
|---|---|
| Date | Date instance |
Example
date := DateUtility->Parse("06/15/2025", "MM/dd/yyyy", false);
Console->Print("Year: ")->PrintLine(date->GetYear());
Console->Print("Month: ")->PrintLine(date->GetMonth());
Console->Print("Day: ")->PrintLine(date->GetDay());