Jump to content

DosSetDateTime (OS/2 1.x): Difference between revisions

From EDM2
No edit summary
 
(4 intermediate revisions by 2 users not shown)
Line 1: Line 1:
[[image:legacy.png]]
{{Legacy
This is the legacy function. It is recommended to use:  [[OS2 API:CPI:DosSetDateTime|DosSetDateTime]]
|RepFunc=[[DosSetDateTime]]
 
|Remarks=The function described here was part of the OS2 1.x API. It had been updated for modern OS/2 development, it is available at [[DosSetDateTime]].
==Description==
}}
This call is used to set the date and time that are maintained by the operating system.
This call is used to set the date and time that are maintained by the operating system.


==Syntax==
==Syntax==
<PRE>
  DosSetDateTime (DateTime)
  DosSetDateTime


    (DateTime)
</PRE>
==Parameters==
==Parameters==
; DateTime (PDATETIME) - input : Address of the date and time structure:
;DateTime (PDATETIME) - input : Address of the date and time structure:
 
::hours (UCHAR) - Current hour (0-23)
* hours (UCHAR)
::minutes (UCHAR) - Current minute (0-59)
        Current hour (0-23).
::seconds (UCHAR) - Current second (0-59)
* minutes (UCHAR)
::hundredths (UCHAR) - Current hundredth of a second (0-99)
        Current minute (0-59).
::day (UCHAR) - Current day (1-31)
* seconds (UCHAR)
::month (UCHAR) - Current month (1-12)
        Current second (0-59).
::year (USHORT) - Current year (1980-2079)
* hundredths (UCHAR)
::timezone (SHORT) - Minutes west of UTC (Universal Time Coordinate -720 to 720).  
        Current hundredth of a second (0-99).
::weekday (UCHAR) - Current day of the week. This value is ignored and is calculated from the other parameter information.
* day (UCHAR)
        Current day (1-31).
* month (UCHAR)
        Current month (1-12).
* year (USHORT)
        Current year (1980-2079).
* timezone (SHORT)
        Minutes west of UTC (Universal Time Coordinate -720 to 720).  
* weekday (UCHAR)
        Current day of the week. This value is ignored and is calculated from the other parameter information.
 


==Return Code==
==Return Code==
rc (USHORT) - return
;rc (USHORT) - return:Return code descriptions are:
 
* 0 NO_ERROR
Return code descriptions are:
*327 ERROR_TS_DATETIME
 
* 0         NO_ERROR  
* 327       ERROR_TS_DATETIME  


==Remarks==
==Remarks==
Line 49: Line 32:
Not adhering to the limits on any of the parameters results in the return code being set to rc = 327 (ERROR_TS_DATETIME). Also, OS/2 verifies that the day is possible for the month and the year (even for leap year). If the day is not reasonable, OS/2 will also set rc = 327.  
Not adhering to the limits on any of the parameters results in the return code being set to rc = 327 (ERROR_TS_DATETIME). Also, OS/2 verifies that the day is possible for the month and the year (even for leap year). If the day is not reasonable, OS/2 will also set rc = 327.  


==Example Code==
==Bindings==
===C Binding===
===C===
<PRE>
<PRE>
typedef struct _DATETIME {  /* date */
typedef struct _DATETIME {  /* date */
   UCHAR  hours;            /* current hour */
   UCHAR  hours;            /* current hour */
   UCHAR  minutes;          /* current minute */
   UCHAR  minutes;          /* current minute */
Line 63: Line 45:
   SHORT  timezone;        /* minutes of time west of UTC */
   SHORT  timezone;        /* minutes of time west of UTC */
   UCHAR  weekday;          /* current day of week */
   UCHAR  weekday;          /* current day of week */
} DATETIME;
} DATETIME;


#define INCL_DOSDATETIME
#define INCL_DOSDATETIME


USHORT rc = DosSetDateTime(DateTime);
USHORT   rc = DosSetDateTime(DateTime);
PDATETIME DateTime;      /* Date/time structure */
USHORT    rc;            /* return code */
</PRE>
 
===MASM===
<pre>
DATETIME struc
  date_hours      db  ? ;current hour
  date_minutes    db  ? ;current minute
  date_seconds    db  ? ;current second
  date_hundredths db  ? ;current hundredths of a second
  date_day        db  ? ;current day
  date_month      db  ? ;current month
  date_year      dw  ? ;current year
  date_timezone  dw  ? ;minutes of time west of UTC
  date_weekday    db  ? ;current day of week
DATETIME ends
 
EXTRN  DosSetDateTime:FAR
INCL_DOSDATETIME    EQU 1


PDATETIME        DateTime;     /* Date/time structure */
PUSH@  OTHER  DateTime     ;Date/time structure
CALL  DosSetDateTime


USHORT          rc;            /* return code */
Returns WORD
</PRE>
</pre>
The following example obtains and prints date and time information. It then changes the system date to 5/10/1987 and prints the updated information.


==Example==
The following example obtains and prints date and time information. It then changes the system date to 5/10/1987 and prints the updated information.
<PRE>
<PRE>
#define INCL_DOSDATETIME
#define INCL_DOSDATETIME
#include <os2.h>
#include <os2.h>


Line 99: Line 101:
</PRE>
</PRE>


===MASM Binding===
[[Category:Dos16]]
<PRE>
DATETIME struc
  date_hours      db  ? ;current hour
  date_minutes    db  ? ;current minute
  date_seconds    db  ? ;current second
  date_hundredths db  ? ;current hundredths of a second
  date_day        db  ? ;current day
  date_month      db  ? ;current month
  date_year      dw  ? ;current year
  date_timezone  dw  ? ;minutes of time west of UTC
  date_weekday    db  ? ;current day of week
DATETIME ends
 
EXTRN  DosSetDateTime:FAR
INCL_DOSDATETIME    EQU 1
 
PUSH@  OTHER  DateTime      ;Date/time structure
CALL  DosSetDateTime
 
Returns WORD
</PRE>
==Related Functions==
*
 
 
[[Category:The OS/2 API Project]]

Latest revision as of 17:45, 1 May 2023

Legacy Function Warning
It is recommended to use a newer replacement for this function.
Replacement: DosSetDateTime
Remarks: The function described here was part of the OS2 1.x API. It had been updated for modern OS/2 development, it is available at DosSetDateTime.

This call is used to set the date and time that are maintained by the operating system.

Syntax

DosSetDateTime (DateTime)

Parameters

DateTime (PDATETIME) - input
Address of the date and time structure:
hours (UCHAR) - Current hour (0-23)
minutes (UCHAR) - Current minute (0-59)
seconds (UCHAR) - Current second (0-59)
hundredths (UCHAR) - Current hundredth of a second (0-99)
day (UCHAR) - Current day (1-31)
month (UCHAR) - Current month (1-12)
year (USHORT) - Current year (1980-2079)
timezone (SHORT) - Minutes west of UTC (Universal Time Coordinate -720 to 720).
weekday (UCHAR) - Current day of the week. This value is ignored and is calculated from the other parameter information.

Return Code

rc (USHORT) - return
Return code descriptions are:
  • 0 NO_ERROR
  • 327 ERROR_TS_DATETIME

Remarks

The value of timezone is the difference in minutes between the current time zone and UTC. This is a positive number if earlier than UTC, and negative number if it is later. For Eastern Standard Time this value is 300 (five hours earlier than UTC).

To get the date and time, issue DosGetDateTime. If the application is executing in the OS/2 environment, it is more efficient to obtain these variables by calling DosGetInfoSeg instead of this function. However, applications written to the family API cannot depend on the availability of DosGetInfoSeg.

Not adhering to the limits on any of the parameters results in the return code being set to rc = 327 (ERROR_TS_DATETIME). Also, OS/2 verifies that the day is possible for the month and the year (even for leap year). If the day is not reasonable, OS/2 will also set rc = 327.

Bindings

C

typedef struct _DATETIME {  /* date */
  UCHAR   hours;            /* current hour */
  UCHAR   minutes;          /* current minute */
  UCHAR   seconds;          /* current second */
  UCHAR   hundredths;       /* current hundredths of a second */
  UCHAR   day;              /* current day */
  UCHAR   month;            /* current month */
  USHORT  year;             /* current year */
  SHORT   timezone;         /* minutes of time west of UTC */
  UCHAR   weekday;          /* current day of week */
} DATETIME;

#define INCL_DOSDATETIME

USHORT    rc = DosSetDateTime(DateTime);
PDATETIME DateTime;      /* Date/time structure */
USHORT    rc;            /* return code */

MASM

DATETIME struc
  date_hours      db  ? ;current hour
  date_minutes    db  ? ;current minute
  date_seconds    db  ? ;current second
  date_hundredths db  ? ;current hundredths of a second
  date_day        db  ? ;current day
  date_month      db  ? ;current month
  date_year       dw  ? ;current year
  date_timezone   dw  ? ;minutes of time west of UTC
  date_weekday    db  ? ;current day of week
DATETIME ends

EXTRN  DosSetDateTime:FAR
INCL_DOSDATETIME    EQU 1

PUSH@  OTHER   DateTime      ;Date/time structure
CALL   DosSetDateTime

Returns WORD

Example

The following example obtains and prints date and time information. It then changes the system date to 5/10/1987 and prints the updated information.

#define INCL_DOSDATETIME
#include <os2.h>

main()
{
  DATETIME   DateTime;       /* Structure to hold date/time info. */
  USHORT     rc;

  rc = DosGetDateTime(&DateTime);     /* Address of d/t structure */
  printf("Today is %d-%d-%d; the time is %d:%d\n", DateTime.month,
         DateTime.day, DateTime.year, DateTime.hours, DateTime.minutes);
  DateTime.day = 10;
  DateTime.month = 5;
  DateTime.year = 1987;
  printf("The new date is %d-%d-%d; the time is %d:%d\n", DateTime.month,
         DateTime.day, DateTime.year, DateTime.hours, DateTime.minutes);
  rc = DosSetDateTime(&DateTime);    /* Address of d/t structure */
  printf("rc is %d\n", rc);
 }