The Date object is provided to make it easier to deal with variables representing dates. It converts automatically to an ActiveX VT_DATE value and so can function as a drop-in replacement for a scripting language's native date variables. The main advantage is that it retains milliseconds, unlike VT_DATE which has a one second resolution. It also provides some utility methods to manipulate dates. The Item object has a number of properties that returns Date objects.
You can create a new Date object using the DOpusFactory.Date method.
Property Name |
Return Type |
Description |
---|---|---|
<default value> |
date |
Returns a VT_DATE representing the value of this Date object (excluding the milliseconds). |
day |
int |
Get or set the day value of the date. |
hour |
int |
Get or set the hour value of the date. |
min |
int |
Get or set the minute value of the date. |
month |
int |
Get or set the month value of the date. |
ms |
int |
Get or set the milliseconds value of the date. |
sec |
int |
Get or set the seconds value of the date. |
wday |
int |
Get the day-of-the-week value of the date. |
year |
int |
Get or set the year value of the date. |
Method Name |
Arguments |
Return Type |
Description |
---|---|---|---|
Add |
<int:value> |
none |
Adds the specified value to the date. The interpretation of the
specified value is controlled by the type
string: |
Clone |
none |
object:Date |
Returns a new Date object set to the same date as this one. |
Compare |
<date:other> |
int |
Compares this date against the other date. The return value
will be 0 (equal), 1 (greater) or
-1 (less). |
Format |
[<string:format>] |
string |
Returns a formatted date or time string. The format and flags arguments are both optional. If you do not give a format, the result will include both date and time, formatted the same as date-time columns in the file display. If you give a format of just "d" or "t" then the result will be just the date or time part, formatted the same as date or time columns in the file display. The file display's formats depend on the user's locale and Windows settings. You should use those options if you wish to present a date/time to the user in the way they expect them to look, but not if you need to store them in a specific format. When using the file display's format (that is, the format argument is empty, "d" or "t"), you can optionally pass one or more case-sensitive flags in the second flags argument to override a few settings:
For example, to get just the date, using the user's locale, but with day names forced off: myDate.Format("d","n"). To get the date and time, using the user's locale, but with day names forced on and seconds forced off: myDate.Format("","Ns"). The format can also use the syntax shown in Codes for date and time, allowing for arbitrary formats. For example, myDate.Format("D#yyyy-MM-dd T#HH:mm:ss") would return a string like 2016-07-28 15:45:26. When explicitly specifying a format, the flags argument should not be used and will be ignored. |
FromUTC |
none |
object:Date |
Returns a new Date object with the date converted from UTC (based on the local time zone). |
Reset |
none |
none |
Resets the date to the current local date/time. |
Set |
<date:newdate> |
none |
Sets the value of this Date object to the supplied date. |
Sub |
<int:value> |
none |
Subtracts the specified value from the date. The parameters are the same as for the Add method. |
ToUTC |
none |
object:Date |
Returns a new Date object with the date converted to UTC (based on the local time zone). |