DateTime
From Pointui
The DateTime object is a basic data type class that contains a date/time value and allows the value to be manipulated. The DateTime class implements some basic operators such as ==, >, <, >=, <=, and !=.
Format Specifiers
The following specifiers can be used to create format strings with DateTime objects:
| Format Specifier | Description | Example (using 1st February 2009 3:04:05 AM) |
|---|---|---|
| d | Day | 1 |
| dd | Dayzero padded | 01 |
| M | Month | 2 |
| MM | Month zero padded | 02 |
| MMM | Month name short | Feb |
| MMMM | Month name full | February |
| yy | Year 2 digit | 09 |
| yyyy | Year | 2009 |
| h | Hour | 3 |
| hh | Hour zero padded | 03 |
| m | Minute | 4 |
| mm | Minute zero padded | 04 |
| s | Seconds | 5 |
| ss | Seconds zero padded | 05 |
| tt | am/pm | am |
Methods
String ToRegionalTimeString(String format)
Returns a string representation of the DateTime object using the supplied format.
PARAMETERS
- format – format of the String to return which must be one of the following String values:
- “” (default) – use the default system format.
- “NoSeconds” – only include the hour and minutes.
- “NoMinutesOrSeconds” – only include the hour.
RETURN VALUE
Returns a String containing the formatted time.
String ToRegionalDateString(String format)
Returns a string representation of the DateTime object using the supplied format.
PARAMETERS
- format – format of the String to return which must be one of the following String values:
- “” (default) – use the default system format.
- “Short” – short date format based on system regional settings.
- “Long” – long date format based on system regional settings.
RETURN VALUE
Returns a String containing the formatted date.
String ToString(String format)
Returns a string representation of the DateTime object using the supplied format.
PARAMETERS
- format – format of the String to return. See the “Format Specifiers” section above.
RETURN VALUE
Returns a String containing the formatted date/time.
float ToVariantTime()
Returns a floating point representation of the DateTime object that can be used as a Variant time.
RETURN VALUE
Returns a floating point value that is the Variant time representation of the date/time currently held in the DateTime object.
void Now()
Sets the DateTime object to contain the current date and time which is read from the system each time Now() is called.
int DifferenceInSeconds(DateTime olderDateTime)
Calculates the number of seconds difference between the date/time value in the DateTime object and the supplied olderDateTime.
PARAMETERS
- olderDateTime – another DateTime object that is to be compared with the value in this DateTime object. It doesn’t necessarily need to be an older date/time, but if it is the return value will be positive, otherwise the return value will be negative.
int DifferenceInMilliseconds(DateTime olderDateTime)
Calculates the number of milliseconds difference between the date/time value in the DateTime object and the supplied olderDateTime.
PARAMETERS
- olderDateTime – another DateTime object that is to be compared with the value in this DateTime object. It doesn’t necessarily need to be an older date/time, but if it is the return value will be positive, otherwise the return value will be negative.
void AddDays(int days)
Adds the specified number of days to the current date/time value in this DateTime object.
void AddMinutes(int minutes)
Adds the specified number of minutes to the current date/time value in this DateTime object.
void SetStartOfDay()
Sets the date/time value to be at the start of the day. For instance if the value was currently “1st Feb 2009 3:40am” then after calling SetStartOfDay() the value will be “1st Feb 2009 12:00am”. Essentially the time component is removed from the value.
String ShortTimeRange(DateTime endTime)
Returns a formatted string based on predefined logic for the time range as calculated by subtracting the date/time value of this DateTime object from the supplied endTime.
void ToGmt()
Adjusts the current time by the -timezone offset of the device.
bool IsLeapYear()
AVAILABLE SINCE: 2.0.30b Returns true if the value within the DateTime object is a date within a leap year.
bool IsSameDay(DateTime compareWith)
AVAILABLE SINCE: 2.0.30b Returns true if the compareWith value is on the same day as this DateTime's value.
int GetYear()
AVAILABLE SINCE: 2.0.30b Returns the year for the date/time value contained in this object. If you want the current year, then first call Now().
int GetMonth()
AVAILABLE SINCE: 2.0.30b Returns the month for the date/time value contained in this object. A return value of zero indicates an error has occurred, otherwise the return value will be between 1 and 12.
int GetDay()
AVAILABLE SINCE: 2.0.30b Returns the day of the month for the date/time value contained in this object. A return value of zero indicates an error has occurred, otherwise the return value will be between 1 and 31.
int GetHours()
AVAILABLE SINCE: 2.0.30b Returns the hour value for the date/time value contained in this object. If you want the current time, then first call Now().
int GetMinutes()
AVAILABLE SINCE: 2.0.30b Returns the minutes value for the date/time value contained in this object. If you want the current time, then first call Now().
int GetSeconds()
AVAILABLE SINCE: 2.0.30b Returns the seconds value for the date/time value contained in this object. If you want the current time, then first call Now().
int GetDaysInMonth(int year, int month)
AVAILABLE SINCE: 2.0.30b Returns the number of days in the month as specified by the year and month parameters.
int GetDayOfWeek()
AVAILABLE SINCE: 2.0.30b Returns the current day of the week. 0 = Monday, 1 = Tuesday, etc.
int GetTimeZoneOffsetMinutes()
AVAILABLE SINCE: 2.0.30b Returns the time zone bias in minutes.
