Date.opx
Date and time manipulationTo use this OPX, you must include the header file Date.oxh
, which contains the following declaration:
DECLARE OPX DATE,KUidOpxDate&,KOpxDateVersion% DTNewDateTime&:(year&,month&,day&,hour&,minute&,second&, micro&) : 1 DTDeleteDateTime:(id&) : 2 DTYear&:(id&) : 3 DTMonth&:(id&) : 4 DTDay&:(id&) : 5 DTHour&:(id&) : 6 DTMinute&:(id&) : 7 DTSecond&:(id&) : 8 DTMicro&:(id&) : 9 DTSetYear:(id&,year&) : 10 DTSetMonth:(id&,month&) : 11 DTSetDay:(id&,day&) : 12 DTSetHour:(id&,hour&) : 13 DTSetMinute:(id&,minute&) : 14 DTSetSecond:(id&,second&) : 15 DTSetMicro:(id&,micro&) : 16 DTNow&: : 17 DTDateTimeDiff:(start&,end&,BYREF year&,BYREF month&, BYREF day&,BYREF hour&,BYREF minute&, BYREF second&,BYREF micro&) : 18 DTYearsDiff&:(start&,end&) : 19 DTMonthsDiff&:(start&,end&) : 20 DTDaysDiff&:(start&,end&) : 21 DTHoursDiff&:(start&,end&) : 22 DTMinutesDiff&:(start&,end&) : 23 DTSecsDiff&:(start&,end&) : 24 DTMicrosDiff&:(start&,end&) : 25 DTWeekNoInYear&:(id&,yearstart&,rule&) : 26 DTDayNoInYear&:(id&,yearstart&) : 27 DTDayNoInWeek&:(id&) : 28 DTDaysInMonth&:(id&) : 29 DTSetHomeTime:(id&) : 30 LCCountryCode&: : 31 LCDecimalSeparator$: : 32 LCSetClockFormat:(format&) : 33 LCClockFormat&: : 34 LCStartOfWeek&: : 35 LCThousandsSeparator$: : 36 END DECLARE
ER5 WINS OPXs are not useable on the ER3 EPOC Emulator, and ER3 WINS OPXs will not work on the ER5 Emulator. However, ER5 MARM OPXs will work on ER3 EPOC devices, and ER3 MARM OPXs will work under ER5.
Usage: id&=DTNEWDATETIME&:(year&,month&,day&,hour&,minute&,second&,micro&)
Creates a new date/time object which contains all the supplied date/time components and returns a handle id& for it.
The year is stored as the usual four figure year, e.g. 1997.
The month is stored as 1 for January, 2 for February, etc.
The day is stored as the day number in the month.
The hour is the hour of the day in 12 or 24 hour clock according to the system setting.
The minutes, seconds and microseconds are stored as the usual values 0 to 59 for minutes and seconds and 0 to 999999 for microseconds.
See DTDELETEDATETIME:.
Usage: DELETEDATETIME:(id&)
Deletes the date/time object with handle id&. This should be called when a date/time object is no longer needed. Date/time objects will be deleted automatically on unloading the Date OPX or the module which uses it.
See DTNEWDATETIME&:, DTNOW&:.
Usage: y&=DTYEAR&:(id&)
Returns the year component y& which is stored in the date/time object with handle id&.
See DTNEWDATETIME&:.
Usage: m&=DTMONTH&:(id&)
Returns the month component m& which is stored in the date/time object with handle id&.
See DTNEWDATETIME&:.
Usage: day&=DTDAY&:(id&)
Returns the day component day& which is stored in the date/time object with handle id&.
See DTNEWDATETIME&:.
Usage: h&=DTHOUR&:(id&)
Returns the hour component h& which is stored in the date/time object with handle id&.
See DTNEWDATETIME&:
Usage: m&=DTMINUTE&:(id&)
Returns the minutes component m& which is stored in the date/time object with handle id&.
See DTNEWDATETIME&:.
Usage: s&=DTSECOND&:(id&)
Returns the seconds component s& which is stored in the date/time object with handle id&.
See DTNEWDATETIME&:.
Usage: m&=DTMICRO&:(id&)
Returns the microseconds component m& which is stored in the date/time object with handle id&.
See DTNEWDATETIME&:.
Usage: DTSETYEAR:(y&,id&)
Sets the year component which is stored in the date/time object with handle id& to y&.
See DTNEWDATETIME&:.
Usage: DTSETMONTH:(m&,id&)
Sets the month component which is stored in the date/time object with handle id& to m&.
See DTNEWDATETIME&:.
Usage: DTSETDAY:(day&,id&)
Sets the day component which is stored in the date/time object with handle id& to day&.
See DTNEWDATETIME&:.
Usage: DTSETHOUR:(h&,id&)
Sets the hour component which is stored in the date/time object with handle id& to h&.
See DTNEWDATETIME&:.
Usage: DTSETMINUTE:(m&,id&)
Sets the minutes component which is stored in the date/time object with handle id& to m&.
See DTNEWDATETIME&:.
Usage: DTSETSECOND:(s&,id&)
Sets the seconds component which is stored in the date/time object with handle id& to s&.
See DTNEWDATETIME&:.
Usage: DTSETMICRO:(m&,id&)
Sets the microseconds component which is stored in the date/time object with handle id& to m&.
See DTNEWDATETIME&:.
Usage: id&=DTNOW&:
Creates a new date/time object which contains all the date/time components of the current time and returns a handle id& for it.
Example: Timing a loop
... start&=DTNow&: WHILE condition ... ENDWH end&=DTNow&: PRINT "Time to do loop was",DTMicrosDiff&:(start&,end&) ...
See DTNEWDATETIME&:.
Usage: DTDATETIMEDIFF:(start&,end&,BYREF year&,BYREF month&,BYREF day&,BYREF hour&,BYREF minute&,BYREF second&,BYREF micro&)
Calculates the exact difference between two date/time objects with handles start& and end& in the form of a date/time object. The difference is returned in the variables year&, month& etc.
Usage: diff&=DTYEARSDIFF&:(start&,end&)
Returns the difference diff& in whole years between the two date/time objects with handles start& and end&.
See DTNEWDATETIME&:.
Usage: diff&=DTMONTHSDIFF&:(start&,end&)
Returns the difference diff& in whole months between the two date/time objects with handles start& and end&.
See DTNEWDATETIME&:.
Usage: diff&=DTDAYSDIFF&:(start&,end&)
Returns the difference diff& in whole days between the two date/time objects with handles start& and end&.
See DTNEWDATETIME&:.
Usage: diff&=DTHOURSDIFF&:(start&,end&)
Returns the difference diff& in whole hours between the two date/time objects with handles start& and end&.
See DTNEWDATETIME&:.
Usage: diff&=DTMINUTESDIFF&:(start&,end&)
Returns the difference diff& in whole minutes between the two date/time objects with handles start& and end&.
See DTNEWDATETIME&:.
Usage: diff&=DTSECONDSDIFF&:(start&,end&)
Returns the difference diff& in whole seconds between the two date/time objects with handles start& and end&.
See DTNEWDATETIME&:.
Usage: diff&=DTMICROSDIFF&:(start&,end&)
Returns the difference diff& in whole microseconds between the two date/time objects with handles start& and end&.
See DTNEWDATETIME&:, DTNOW&:.
Usage: w&=DTWEEKNOINYEAR&:(id&,yearstart&,rule&)
Returns the week number in the year of the date/time object with handle id&. The first day of the year is specified by the date/time object with handle yearstart&. This would usually be set to 1 January in the appropriate year, but also allows you to set the star of the year to the beginning of the financial year or the academic year, for example.
rule& can take three values (0,1,2), allowing the week number to be calculated by one of three different rules:
value |
meaning |
0 |
the first day of the year is always in week one, |
1 |
requires the first week of the year to have at least four days in it, |
2 |
requires the first week of the year to have the full seven days. |
The Agenda application and applications use the rule with value 1 by default.
Usage: DTDAYNOINYEAR&:(id&,yearstart&)
Returns the day number in the year of the date/time object with handle id&. The first day of the year is specified by the date/time object with handle yearstart&.
Usage: n&=DTDAYNOINWEEK&:(id&)
Returns the day number in the week (1-7) of the date/time object with handle id&.
Usage: n&=DTDAYSINMONTH&:(id&)
Returns the number of days in the month of the month specified by the month component of the date/time object with handle id&.
Usage: DTSETHOMETIME:(id&)
Sets the system time to the time specified in the date/time object with handle id&.
Usage: cc&=LCCOUNTRYCODE&:
Returns the country code for the current system home country (LC stands for Locale), which may be used to select country-specific data. The country code for any given country is the international dialling prefix for that country
Usage: decSep$=LCDECIMALSEPARATOR$:
Returns the decimal separator (the character used in decimal numbers to separate whole part from fractional part) according to the local system setting.
Usage: LCSETCLOCKFORMAT:(format&)
Sets the system clock format to either digital or analog. If format&=0 then the clock is set to analog or if it is 1 then the clock is set to digital.
Usage: format&=LCCLOCKFORMAT&:
Returns the current system clock format The procedure returns 0 if the system clock is analog and 1 if it is digital.
Usage: start&=LCSTARTOFWEEK&:
Returns the day of the week which set as the first day of the week in the system setting. A return value of 1 indicates Monday, 2 Tuesday, and so on.
Usage: thouSep$=LCTHOUSANDSSEPARATOR$:
Returns the thousands separator (the character used to separate every three digits of a large number) according to the local system setting.