Jump to content

DosSetDateTime: Difference between revisions

From EDM2
Ak120 (talk | contribs)
mNo edit summary
Line 1: Line 1:
==DosSetDateTime==
'''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===
 
rc = DosSetDateTime( ''pdt'' );
rc = 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
  APIRET  rc
  0      NO_ERROR
  0      NO_ERROR
Line 19: Line 13:


===Include Info===
===Include Info===
  #define INCL_DOSDATETIME
  #define INCL_DOSDATETIME
  #include <os2.h>
  #include <os2.h>
===Usage Explanation===
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.


===Relevant Structures===
===Relevant Structures===
  typedef struct _DATETIME
  typedef struct _DATETIME
  {
  {
Line 45: Line 32:


===Gotchas===
===Gotchas===
The sign of the time zone is opposed to that ordinarily used. Ie GMT+1 (Western Europe) <=> -60
The sign of the time zone is opposed to that ordinarily used. Ie GMT+1 (Western Europe) <=> -60


Line 73: Line 59:
     /* Success */
     /* Success */
  }
  }


===See Also===
===See Also===
* [[OS2 API:DosGetDateTime|DosGetDateTime]]
* [[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:The OS/2 API Project]]

Revision as of 22:16, 23 December 2016

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

rc = 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

Include Info

#define INCL_DOSDATETIME
#include <os2.h>

Relevant Structures

typedef struct _DATETIME
{
  UCHAR  hours;       /* 0..23 */
  UCHAR  minutes;     /* 0..59 */
  UCHAR  seconds;     /* 0..59 */
  UCHAR  hundredths;  /* 0..99, 1/100 s */
  UCHAR  day;         /* 0..31 */
  UCHAR  month;       /* 0..12 */
  USHORT year;
  SHORT  timezone;    /* Difference in minutes between current time zone and */
                      /* GMT. > 0 west of Greenwich */
  UCHAR  weekday;     /* 0..6 0=Sunday */
} DATETIME, *PDATETIME;

Gotchas

The sign of the time zone is opposed to that ordinarily used. Ie 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

  1. OS2Linux project (Common Public License) created a clone for this function [1].