DosSetDateTime: Difference between revisions
Appearance
mNo edit summary |
|||
(5 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
'''DosSetDateTime''' sets the current date and time for the system. Although you can set day, month, year and weekday to whatever you want, DosSetDateTime will check if it is a correct combination and will return an error if it is incorrect. | |||
===Syntax=== | ===Syntax=== | ||
DosSetDateTime( ''pdt'' ) | |||
===Parameters=== | ===Parameters=== | ||
;PDATETIME ''pdt'' (input): The pointer to a [[DATETIME]] structure containing the date and time to be set as the system's date and time. | |||
; PDATETIME ''pdt'' (input) | |||
: The pointer to a DATETIME structure containing the date and time to be set as the system's date and time. | |||
===Returns=== | ===Returns=== | ||
;APIRET rc | |||
:0 NO_ERROR | |||
:327 ERROR_TS_DATETIME | |||
===Gotchas=== | ===Gotchas=== | ||
The sign of the time zone is opposed to that ordinarily used. I.e. GMT+1 (Western Europe) <=> -60 | |||
The sign of the time zone is opposed to that ordinarily used. | |||
===Sample Code=== | ===Sample Code=== | ||
<code> | |||
#define INCL_DOSDATETIME | #define INCL_DOSDATETIME | ||
#include <os2.h> | #include <os2.h> | ||
Line 65: | Line 33: | ||
if(DosSetDateTime(&dt)) /* Set time to 12:34:56.78, Monday July 8, 1996 */ | if(DosSetDateTime(&dt)) /* Set time to 12:34:56.78, Monday July 8, 1996 */ | ||
/* somewhere in Western Europe */ | |||
{ | { | ||
/* Failure */ | /* Failure */ | ||
Line 73: | Line 41: | ||
/* Success */ | /* Success */ | ||
} | } | ||
</code> | |||
===See Also=== | ===See Also=== | ||
* [[ | * [[DosGetDateTime]] | ||
==Alternative Version== | ==Alternative Version== | ||
# OS2Linux project (Common Public License) created a clone for this function [https://github.com/OS2World/LINUX-SYSTEM-OS2Linux/blob/1eaffacb404b31b79068582ef8bf4d7583c8fa8d/os2/datetime.c]. | # OS2Linux project (Common Public License) created a clone for this function [https://github.com/OS2World/LINUX-SYSTEM-OS2Linux/blob/1eaffacb404b31b79068582ef8bf4d7583c8fa8d/os2/datetime.c]. | ||
[[Category:Dos]] | |||
[[Category: |
Latest revision as of 18:21, 18 March 2019
DosSetDateTime sets the current date and time for the system. Although you can set day, month, year and weekday to whatever you want, DosSetDateTime will check if it is a correct combination and will return an error if it is incorrect.
Syntax
DosSetDateTime( pdt )
Parameters
- PDATETIME pdt (input)
- The pointer to a DATETIME structure containing the date and time to be set as the system's date and time.
Returns
- APIRET rc
- 0 NO_ERROR
- 327 ERROR_TS_DATETIME
Gotchas
The sign of the time zone is opposed to that ordinarily used. I.e. GMT+1 (Western Europe) <=> -60
Sample Code
#define INCL_DOSDATETIME
#include <os2.h>
DATETIME dt;
dt.hours=12;
dt.minutes=34;
dt.seconds=56;
dt.hundredths=78;
dt.day=8;
dt.month=7;
dt.year=1996;
dt.timezone=-60; /* West Europe */
dt.weekday=1; /* Monday */
if(DosSetDateTime(&dt)) /* Set time to 12:34:56.78, Monday July 8, 1996 */
/* somewhere in Western Europe */
{
/* Failure */
}
else
{
/* Success */
}
See Also
Alternative Version
- OS2Linux project (Common Public License) created a clone for this function [1].