You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 4 Next »

Date and Time API

Applies to: v10

v10 adds DNTAPI2.H ("modernized Gregorian date/time API": dnt2_*, prndat2, prnday2, prntim2) next to the DNTAPI.H described here. It is present on the v10 branch add-dntapi2-header and not in main; GCOMM.H includes it only in the working tree (#include "dntapi2.h"). This chapter's DNTAPI.H text is otherwise unchanged. ncdate()/nctime() return const CHAR *: chapter 29, section 29.4.

Applies to: WG3.x

Editor's note: this chapter is new in the WG3 layer. It is from section 9 ("Date and Time API") of the Developer's Addendum for Worldgroup 3.12 (wg312dev; the earlier 3.10 edition, devad3, is the same text apart from "3.10" for "3.12", BC5 for BC50, InstallShield V5.0 for V5.1 and spelling). The addendum has no figures. Prose is unrewritten; "Header check" notes record where the printed text disagrees with the WG3.2 headers. It supersedes the ncdate()/ncedat()/dcdate() descriptions of chapter 11 for WG3.x; the Visual Basic conversion routines (v2sdatl, ...) are client-side.

Overview

This document outlines changes and additions to the Date and Time API made for Worldgroup 3.12. This document also covers changes to the VB Date and Time API.

The most important changes were For Year 2000 compliance, and the addition of the discrete components format and sort format for dates and times. Many of the functions which take pointers as arguments or return pointers to internal buffers now specify that these are const pointers. A complete list of functions to which const was added will not be given in this document.

Year 2000 Compliance

The primary changes made for year 2000 compliance are improved support for four-digit years in string-format dates. The following defines and functions were changed or added for year 2000 compliance:

Name Type Status
dcdate Function Changed
LDATSIZ Define Added
ncdatel Function Added
ncedatl Function Added
v2sdatl Function Added

Discrete Components Date and Time Format

The most basic binary representation of a date or time is to use separate integer variables to hold the year, month, and day components of a date, and the hour, minute, and second components of a time. This format has now been formalized and will be referred to as the "discrete components" format.

The components of a discrete date are defined as follows:

Component Range Comments
Year 1582-9999 This is the calendar year. Since the Gregorian calendar was first adopted on October 15, 1582, earlier dates should not be manipulated with this API.
Month 1-12 The one-based month, where one is January and twelve is December.
Day 1-31 The one-based day of the month, where one is the first day of the month. The actual maximum value of this component depends on the month and year.

The components of a discrete time are defined as follows:

Component Range Comments
Hour 0-23 The zero-based hour of the day in 24-hour time (military time), where zero is 12:00 AM (midnight), 12 is 12:00 PM (noon), and 23 is 11:00 PM.
Minute 0-59 The zero-based minute of the hour, where the first minute in an hour is zero.
Second 0-59 The zero-based second of the minute, where the first second in a minute is zero.

The following identifiers have been changed or added to support the discrete components format:

Name Type Status
addDaysToDate Function Added
dateDecode Function Added
dayFromDate Function Added
difDate Function Added
difYear Function Added
lastDayOfMonth Function Added
prnDate Function Added
prnTime Function Added
timeDecode Function Added
validDate Function Added
validTime Function Added

Sort Date and Time String Format

In order to provide a date and time string format that is compact, provides a complete representation of the date, and can be used to sort dates easily, the sort date and time string format was defined.

The sort date format consists of a four-digit year, immediately followed by a two-digit month, immediately followed by a two-digit day. For example, January 2, 1980 is represented by "19800102".

The sort time format consists of a two-digit hour (in 24-hour format), immediately followed by a two-digit minute, immediately followed by a two-digit second. For example, three seconds before midnight (11:59:57 PM) is represented by "235957".

The following identifiers have been changed or added to support the sort format:

Name Type Status
sDateDecode Function Added
sDateDecodeDOS Function Added
sDateEncode Function Added
sDateEncodeDOS Function Added
sDecodeDT Function Added
sDecodeDTDOS Function Added
sTimeDecode Function Added
sTimeDecodeDOS Function Added
sTimeEncode Function Added
sTimeEncodeDOS Function Added

Miscellaneous

A number of identifiers have been changed or added for other reasons. These are as follows:

Name Type Status
DATSIZ Define Added
isLeapYear Define Added
PRND_* Define Added
PRNT_* Define Added
strDays Variable Added
strMonths Variable Added
validDateDOS Function Added
validTimeDOS Function Added

Defines

DATSIZ

#define DATSIZ 9 /* size of a date in MM/DD/YY format */

This define was originally declared in USRACC.H. It has been moved to DNTAPI.H.

Applies to: WG3.x

Header check: DATSIZ is defined as 9 in DNTAPI.H:137 and again, with the identical value, in UStructs.h:16; USRACC.H no longer defines it. LDATSIZ is 11 (DNTAPI.H:138) and isLeapYear(yr) is DNTAPI.H:192.

isLeapYear

#define isLeapYear(yr) /* is yr a leap year? */

This is a function-style macro that examines a year and determines whether it is a leap year based on the rules defined for the Gregorian calendar.

yr

The year to examine. It can be any integer type.

Returns:

A non-zero integer value if the year is a leap year, or zero if it is not a leap year.

LDATSIZ

#define LDATSIZ 11 /* size of a date in MM/DD/YYYY format */

The size of a character buffer required to hold a U.S. standard format date with a four-digit year (MM/DD/YYYY).

PRND_*, PRNT_*

#define PRND_*                     /* prnDate format identifiers           */
#define PRNT_*                     /* prnTime format identifiers           */

These defines have been added to make it easier to use the prndat(), prntim(), prnDate(), and prnTime() functions. See the prnDate() and prnTime() functions for details.

Variables

strMonths

Applies to: WG3.x

Header check: declared EXPWGSV(CHAR) strMonths[12][10] and strDays[7][10] (DNTAPI.H:196-197).

CHAR strMonths[12][10];            /* long month names (0 = January)       */

A zero-based array of month names in English. The array is defined as follows:

Index Value

0 "January"

1 "February"

2 "March"

3 "April"

4 "May"

5 "June"

6 "July"

7 "August"

8 "September"

9 "October"

10 "November"

11 "December"

strDays

CHAR strDays[7][10];               /* long day names (0 = Sunday)          */

A zero-based array of names of the days of the week in English. The array is defined as follows:

Index Value

0 "Sunday"

1 "Monday"

2 "Tuesday"

3 "Wednesday"

4 "Thursday"

5 "Friday"

6 "Saturday"

Functions

addDaysToDate

VOID
addDaysToDate(                     /* get date by adding # days to base    */
LONG nDays,                        /*   # days to add (can be negative)    */
INT *pYear,                        /*   base year (updated w/ new year)    */
INT *pMonth,                       /*   base month (updated w/ new month)  */
INT *pDay);                        /*   base day (updated w/ new day)      */

Adds days to or subtracts days from a date in discrete components. If the starting date is invalid or the number of days is out of range (approximately -152000 to 2922365 as of January 1998), the results are undefined.

nDays

The number of days to add to the date. If this is negative, the days will be subtracted from the date.

pYear

Pointer to a buffer containing the year component of the date. This buffer is updated with the new year.

pMonth

Pointer to a buffer containing the month component of the date. This buffer is updated with the new month.

pDay

Pointer to a buffer containing the day component of the date. This buffer is updated with the new day.

dateDecode

VOID
dateDecode(                        /* decode date from "MM/DD[/YY[YY]]"    */
const CHAR *src,                   /*   date string                        */
INT *pYear,                        /*   buffer for year (-1 if bad)        */
INT *pMonth,                       /*   buffer for month (-1 if bad)       */
INT *pDay);                        /*   buffer for day (-1 if bad)         */

Decodes a U.S. standard date string (MM/DD/YYYY) into discrete components. The year can be two digits, four digits, or not specified. If two digits are used, values less than 80 will be assumed to be in the 2000s and values greater-than or equal-to 80 will be assumed to be in the 1900s. If no year is specified, the current year will be assumed.

src

The U.S. standard date string to decode.

pYear

Pointer to a buffer to receive the year component of the date. If the year component of the date string is invalid, this buffer will be filled with -1.

pMonth

Pointer to a buffer to receive the month component of the date. If the month component of the date string is invalid, this buffer will be filled with -1.

pDay

Pointer to a buffer to receive the day component of the date. If the day component of the date string is invalid, this buffer will be filled with -1.

dayFromDate

INT                                /*   day of week (0 = Sun, <0 = error)  */
dayFromDate(                       /* get day of week given date           */
INT year,                          /*   year component (1-9999)            */
INT month,                         /*   month component (1-12)             */
INT day);                          /*   day component (1-31)               */

Determines the day of the week represented by a date specified in discrete components.

year

The year component of the date.

month

The month component of the date.

day

The day component of the date.

Returns:

A zero-based index describing the day of the week (Sunday = 0, Saturday = 6). If the specified date is not valid, a negative value will be returned.

dcdate

USHORT                             /*   returns GCINVALIDDOT if invalid    */
dcdate(                            /* decode DOS date from "MM/DD[/YY[YY]]"*/
const CHAR *datstr);               /*   date string to convert             */

Decodes a U.S. standard date string (MM/DD/YYYY) into a DOS packed date. The year can be two digits, four digits, or not specified. If two digits are used, values less than 80 will be assumed to be in the 2000s and values greater-than or equal-to 80 will be assumed to be in the 1900s. If no year is specified, the current year will be assumed.

Note: this function was changed between Worldgroup 3.0 and 3.12 to accept four-digit years in the input string.

datstr

The U.S. standard date string to decode.

Returns:

The date in DOS packed format. If the input date string is not valid, it returns GCINVALIDDOT (0xFFFF).

difDate

LONG                               /*   < 0 if end date before beg date    */
difDate(                           /* compute # days between dates         */
INT begYear,                       /*   year component of first date       */
INT begMonth,                      /*   month component of first date      */
INT begDay,                        /*   day component of first date        */
INT endYear,                       /*   year component of second date      */
INT endMonth,                      /*   month component of second date     */
INT endDay);                       /*   day component of second date       */

Computes the number of days between two dates specified in discrete components. If the ending date comes before the beginning date, the result is negative. If either of the dates are not valid, the result is undefined.

begYear

The year component of the beginning date.

begMonth

The month component of the beginning date.

begDay

The day component of the beginning date.

endYear

The year component of the ending date.

endMonth

The month component of the ending date.

endDay

The day component of the ending date.

Returns:

The number of days between the beginning date and the ending date.

difYear

LONG                               /*   < 0 if end year before beg year    */
difYear(                           /* get # days between 1JAN of two years */
INT begYear,                       /*   beginning year                     */
INT endYear);                      /*   ending year                        */

Computes the number of days between January 1st of two years. If the ending year comes before the beginning year, the result is negative. If either year is out of range (1582 to 9999), the result is undefined.

begYear

The beginning year.

endYear

The ending year.

Returns:

The number of days between January 1st of the beginning and ending years.

lastDayOfMonth

INT                                /*   number of last day (e.g. Jan = 31) */
lastDayOfMonth(                    /* get highest day in given month/year  */
INT month,                         /*   number of month (1-12)             */
INT year);                         /*   year in question (1-9999)          */

Determine the last day of a month. For example, January is always 31 and September is always 30, while February may be 28 or 29, depending on whether or not it is a leap year.

month

The month for which the last day is desired.

year

The year in which the month occurs.

Returns:

The number of the last day of the month (which is also the number of days in the month).

ncdatel

const CHAR *                       /*   returns ASCII long date string     */
ncdatel(                           /* encodes date into "MM/DD/YYYY"       */
USHORT date);                      /*   packed date                        */

Encodes a DOS packed date into a U.S. standard (MM/DD/YYYY) date string with a four-digit year. If the date specified is not valid, an empty string is returned.

date

The DOS packed format date to encode.

Returns:

A pointer to a single internal buffer containing the date string.

ncedatl

const CHAR *                       /*   date string in European long format*/
ncedatl(                           /* encodes date to DD-MMM-YYYY          */
USHORT date);                      /*   packed date                        */

Encodes a DOS packed date into a European (DD-MMM-YYYY) date string with a four-digit year. If the date specified is not valid, an empty string is returned.

date

The DOS packed format date to encode.

Returns:

A pointer to a single internal buffer containing the date string.

prnDate

CHAR *                             /*   returns pointer to buffer          */
prnDate(                           /* form formatted date string           */
INT year,                          /*   year component (1-9999)            */
INT month,                         /*   month component (1-12)             */
INT day,                           /*   day component (1-31)               */
CHAR *buf,                         /*   buffer to receive formatted date   */
size_t bufSiz,                     /*   size of buffer                     */
INT mode,                          /*   format mode                        */
CHAR sep);                         /*   separator character                */

Encodes a date specified in discrete components into a string in a variety of formats. If the date specified is not valid, an empty string is generated.

year

The year component of the date to encode.

month

The month component of the date to encode.

day

The day component of the date to encode.

buf

A pointer to the buffer to receive the encoded date string.

bufSiz

The actual size of the buf argument.

mode

A code describing the format to use when encoding the date. A standard set of modes are defined; all such identifiers begin with PRND_. The rest of the identifier is constructed as follows:

Identifier Result
Y A two-digit numeric representation of the year. This representation is always zero-padded if necessary (e.g., 2001 is represented by "01").
YY A four-digit numeric representation of the year.
M A numeric representation of the month. This representation is always zero-padded if necessary (e.g., January is represented by "01").
MM A short, three-character string representation of the month name (e.g., January is represented by "Jan").
MMM A full string representation of the month name (e.g., January is represented by "January").
C Following a string-form month specifier means that the month name should be capitalized (e.g., MMC means the date string should encode January as "JAN").
D A numeric representation of the day. This representation is always zero-padded if necessary (e.g., the first is represented by "01").

All possible combinations of these identifiers are not supported. The following combinations are currently supported:

Identifier Value Date Format

PRND_MD 0 12*31

PRND_MY 2 12*90

PRND_MDY 4 12*31*90

PRND_DMMY 6 31*Dec*90

PRND_DMMCY 7 31*DEC*90

PRND_MMDY 8 Dec 31, 90

PRND_MMCDY 9 DEC 31, 90

PRND_MMMDY 10 December 31, 90

PRND_MMMCDY 11 DECEMBER 31, 90

PRND_MYY 14 12*1990

PRND_MDYY 16 12*31*1990

PRND_DMMYY 18 31*Dec*1990

PRND_DMMCYY 19 31*DEC*1990

PRND_MMDYY 20 Dec 31, 1990

PRND_MMCDYY 21 DEC 31, 1990

PRND_MMMDYY 22 December 31, 1990

PRND_MMMCDYY 23 DECEMBER 31, 1990

sep

The character to use as a separator for certain formats. This character replaces the asterisk (*) in the above table of supported formats.

Returns:

A pointer to the buf argument.

prnTime

CHAR *                             /*   returns pointer to buffer          */
prnTime(                           /* form formatted time string           */
INT hour,                          /*   hour component (0-23)              */
INT minute,                        /*   minute component (0-59)            */
INT second,                        /*   second component (0-59)            */
CHAR *buf,                         /*   buffer to receive formatted time   */
size_t bufSiz,                     /*   size of buffer                     */
INT mode);                         /*   format mode                        */

Encodes a time specified in discrete components into a string in a variety of formats. If the time specified is not valid, an empty string is generated.

hour

The hour component of the time to encode.

minute

The minute component of the time to encode.

second

The second component of the time to encode.

buf

A pointer to the buffer to receive the encoded time string.

bufSiz

The actual size of the buf argument.

mode

A code describing the format to use when encoding the time. A standard set of modes are defined; all such identifiers begin with PRNT_. The rest of the identifier is constructed as follows:

Identifier Result
H A numeric representation of the hour. This may be in 12- or 24-hour format, and it is not zero-padded by default.
M A numeric representation of the minute. This representation is always zero-padded if necessary (e.g., the third minute of an hour, minute two, is represented by "02").
S A numeric representation of the second. This representation is always zero-padded if necessary (e.g., the third second of a minute, second two, is represented by "02").
_ A single space character.
P The AM/PM portion of the time represented by a single character. If this is specified, the hour is given in 12-hour format.
PM The AM/PM portion of the time represented by two characters. If this is specified, the hour is given in 12-hour format.
C Following P or PM specifies that the AM/PM will be capitalized.

All possible combinations of these identifiers are not supported. The following combinations are currently supported:

Identifier Value Time Format

PRNT_HM 0 23:59

PRNT_HMP 1 11:59p

PRNT_HMPM 2 11:59pm

PRNT_HM_P 3 11:59 p

PRNT_HM_PM 4 11:59 pm

PRNT_HMPC 6 11:59P

PRNT_HMPMC 7 11:59PM

PRNT_HM_PC 8 11:59 P

PRNT_HM_PMC 9 11:59 PM

PRNT_HMS 10 23:59:59

PRNT_HMSP 11 11:59:59p

PRNT_HMSPM 12 11:59:59pm

PRNT_HMS_P 13 11:59:59 p

PRNT_HMS_PM 14 11:59:59 pm

PRNT_HMSPC 16 11:59:59P

PRNT_HMSPMC 17 11:59:59PM

PRNT_HMS_PC 18 11:59:59 P

PRNT_HMS_PMC 19 11:59:59 PM

PRNT_PAD 20 Add this to one of the above identifiers to zero-pad hour

Returns:

A pointer to the buf argument.

sDateDecode

VOID
sDateDecode(                       /* decode "YYYYMMDD"                    */
const CHAR *src,                   /*   encoded date string                */
INT *pYear,                        /*   buffer for year (-1 if bad)        */
INT *pMonth,                       /*   buffer for month (-1 if bad)       */
INT *pDay);                        /*   buffer for day (-1 if bad)         */

Decodes a sort format date string into discrete components.

src

The sort format date string to decode.

pYear

Pointer to a buffer to receive the year component of the date. If the year component of the date string is invalid, this buffer will be filled with -1.

pMonth

Pointer to a buffer to receive the month component of the date. If the month component of the date string is invalid, this buffer will be filled with -1.

pDay

Pointer to a buffer to receive the day component of the date. If the day component of the date string is invalid, this buffer will be filled with -1.

sDateDecodeDOS

USHORT                             /*   DOS date or GCINVALIDDOT           */
sDateDecodeDOS(                    /* decode "YYYYMMDD" to DOS format      */
const CHAR *src);                  /*   encoded date string                */

Decodes a sort format date string into a DOS packed date.

src

The sort format date string to decode.

Returns:

The date in DOS packed format. If the input date string is not valid, it returns GCINVALIDDOT (0xFFFF).

sDateEncode

CHAR *                             /*   returns pointer to buffer          */
sDateEncode(                       /* encode date to "YYYYMMDD"            */
INT year,                          /*   year component (1-9999)            */
INT month,                         /*   month component (1-12)             */
INT day,                           /*   day component (1-31)               */
CHAR *buf,                         /*   buffer to receive encoded date     */
size_t bufSiz);                    /*   size of buffer                     */

Encodes a date in discrete components to a sort format date string.

year

The year component of the date to encode.

month

The month component of the date to encode.

day

The day component of the date to encode.

buf

A pointer to the buffer to receive the encoded date string.

bufSiz

The actual size of the buf argument.

Returns:

A pointer to the buf argument.

sDateEncodeDOS

CHAR *                             /*   returns pointer to buffer          */
sDateEncodeDOS(                    /* encode DOS date to "YYYYMMDD"        */
USHORT dosDate,                    /*   DOS packed date                    */
CHAR *buf,                         /*   buffer to receive encoded date     */
size_t bufSiz);                    /*   size of buffer                     */

Encodes a date in DOS packed format to a sort format date string.

dosDate

The date to encode in DOS packed format.

buf

A pointer to the buffer to receive the encoded date string.

bufSiz

The actual size of the buf argument.

Returns:

A pointer to the buf argument.

sDecodeDT

VOID
sDecodeDT(                         /* decode "YYYYMMDD[ ]HHMMSS"           */
const CHAR *src,                   /*   encoded date string                */
INT *pYear,                        /*   buffer for year (-1 if bad)        */
INT *pMonth,                       /*   buffer for month (-1 if bad)       */
INT *pDay,                         /*   buffer for day (-1 if bad)         */
INT *pHour,                        /*   buffer for hour (-1 if bad)        */
INT *pMinute,                      /*   buffer for minute (-1 if bad)      */
INT *pSecond);                     /*   buffer for second (-1 if bad)      */

Decodes a string containing a sort format date followed by a sort format time into a date and time in discrete components.

src

The string to decode. It must consist of a sort format date, followed by zero or more whitespace characters, followed by a sort format time.

pYear

Pointer to a buffer to receive the year component of the date. If the year component of the date string is invalid, this buffer will be filled with -1.

pMonth

Pointer to a buffer to receive the month component of the date. If the month component of the date string is invalid, this buffer will be filled with -1.

pDay

Pointer to a buffer to receive the day component of the date. If the day component of the date string is invalid, this buffer will be filled with -1.

pHour

Pointer to a buffer to receive the hour component of the time. If the hour component of the time string is invalid, this buffer will be filled with -1.

pMinute

Pointer to a buffer to receive the minute component of the time. If the minute component of the time string is invalid, this buffer will be filled with -1.

pSecond

Pointer to a buffer to receive the second component of the time. If the second component of the time string is invalid, this buffer will be filled with -1.

sDecodeDTDOS

VOID
sDecodeDTDOS(                      /* decode "YYYYMMDD[ ]HHMMSS" to DOS fmt*/
const CHAR *src,                   /*   encoded date string                */
USHORT *pDate,                     /*   buf for date (GCINVALIDDOT if bad) */
USHORT *pTime);                    /*   buf for time (GCINVALIDDOT if bad) */

Decodes a string containing a sort format date followed by a sort format time into a date and time in DOS packed format.

src

The string to decode. It must consist of a sort format date, followed by zero or more whitespace characters, followed by a sort format time.

pDate

Pointer to a buffer to receive the date in DOS packed format. If the date is not valid, this buffer will be filled with GCINVALIDDOT (0xFFFF).

pTime

Pointer to a buffer to receive the time in DOS packed format. If the time is not valid, this buffer will be filled with GCINVALIDDOT (0xFFFF).

sTimeDecode

VOID
sTimeDecode(                       /* decode "HHMMSS"                      */
const CHAR *src,                   /*   encoded date string                */
INT *pHour,                        /*   buffer for hour (-1 if bad)        */
INT *pMinute,                      /*   buffer for minute (-1 if bad)      */
INT *pSecond);                     /*   buffer for second (-1 if bad)      */

Decodes a sort format time string into discrete components.

src

The sort format time string to decode.

pHour

Pointer to a buffer to receive the hour component of the time. If the hour component of the time string is invalid, this buffer will be filled with -1.

pMinute

Pointer to a buffer to receive the minute component of the time. If the minute component of the time string is invalid, this buffer will be filled with -1.

pSecond

Pointer to a buffer to receive the second component of the time. If the second component of the time string is invalid, this buffer will be filled with -1.

sTimeDecodeDOS

USHORT                             /*   DOS time or GCINVALIDDOT           */
sTimeDecodeDOS(                    /* decode "HHMMSS" to DOS format        */
const CHAR *src);                  /*   encoded time string                */

Decodes a sort format time string into a DOS packed time.

src

The sort format time string to decode.

Returns:

The date in DOS packed format. If the input date string is not valid, it returns GCINVALIDDOT (0xFFFF).

sTimeEncode

CHAR *                             /*   returns pointer to buffer          */
sTimeEncode(                       /* encode time to "HHMMSS"              */
INT hour,                          /*   hour component (0-23)              */
INT minute,                        /*   minute component (0-59)            */
INT second,                        /*   second component (0-59)            */
CHAR *buf,                         /*   buffer to receive encoded time     */
size_t bufSiz);                    /*   size of buffer                     */

Encodes a time in discrete components to a sort format time string.

hour

The hour component of the time to encode.

minute

The minute component of the time to encode.

second

The second component of the time to encode.

buf

A pointer to the buffer to receive the encoded time string.

bufSiz

The actual size of the buf argument.

Returns:

A pointer to the buf argument.

sTimeEncodeDOS

CHAR *                             /*   returns pointer to buffer          */
sTimeEncodeDOS(                    /* encode DOS time to "HHMMSS"          */
USHORT dosTime,                    /*   DOS packed time                    */
CHAR *buf,                         /*   buffer to receive encoded time     */
size_t bufSiz);                    /*   size of buffer                     */

Encodes a time in DOS packed format to a sort format time string.

dosTime

The time to encode in DOS packed format.

buf

A pointer to the buffer to receive the encoded time string.

bufSiz

The actual size of the buf argument.

Returns:

A pointer to the buf argument.

timeDecode

VOID
timeDecode(                        /* decode time from  "HH:MM[:SS]"       */
const CHAR *src,                   /*   encoded date string                */
INT *pHour,                        /*   buffer for hour (-1 if bad)        */
INT *pMinute,                      /*   buffer for minute (-1 if bad)      */
INT *pSecond);                     /*   buffer for second (-1 if bad)      */

Decodes a standard date string (HH:MM:SS) into discrete components. The seconds portion of the time string is optional. If no second is specified, 00 will be assumed.

src

The standard time string to decode.

pHour

Pointer to a buffer to receive the hour component of the time. If the hour component of the time string is invalid, this buffer will be filled with -1.

pMinute

Pointer to a buffer to receive the minute component of the time. If the minute component of the time string is invalid, this buffer will be filled with -1.

pSecond

Pointer to a buffer to receive the second component of the time. If the second component of the time string is invalid, this buffer will be filled with -1.

v2sdatl

const CHAR *                       /*   returns ptr to MM/DD/YYYY          */
v2sdatl(                           /* convert VB date to stg "MM/DD/YYYY"  */
DOUBLE vbdat);                     /*   VB DOUBLE precision date/time      */

Encodes a VB binary date into a U.S. standard (MM/DD/YYYY) date string with a four-digit year. If the date specified is not valid, an empty string is returned.

vbdat

The VB binary format date to encode.

Returns:

A pointer to a single internal buffer containing the date string.

validDate

GBOOL
validDate(                         /* check for valid date                 */
INT year,                          /*   year component (1-9999)            */
INT month,                         /*   month component (1-12)             */
INT day);                          /*   day component (1-31)               */

Test a date in discrete components for validity.

year

The year component of the date to test. The year must be in the range 1 to 9999 for the date to be valid.

month

The month component of the date to test. The month must be in the range 1 to 12 for the date to be valid.

day

The day component of the date to test. The day must be greater-than or equal-to one, and it must be less-than or equal-to the last day of the month for the date to be valid. The last day of the month is determined from the month and year, taking leap years into account.

Returns:

A non-zero value if the date is valid, or zero if the date is not valid.

validDateDOS

GBOOL
validDateDOS(                      /* check for valid DOS date             */
USHORT dosDate);                   /*   DOS packed date                    */

Test a date in DOS packed format for validity.

dosDate

The date to test in DOS packed format.

Returns:

A non-zero value if the date is valid, or zero if the date is not valid.

validTime

GBOOL
validTime(                         /* check for valid time                 */
INT hour,                          /*   hour component (0-23)              */
INT minute,                        /*   minute component (0-59)            */
INT second);                       /*   second component (0-59)            */

Test a time in discrete components for validity.

hour

The hour component of the time to test. The hour must be in the range 0 to 23 for the time to be valid.

minute

The minute component of the time to test. The minute must be in the range 0 to 59 for the time to be valid.

second

The second component of the time to test. The second must be in the range 0 to 59 for the time to be valid.

Returns:

A non-zero value if the date is valid, or zero if the date is not valid.

validTimeDOS

GBOOL
validTimeDOS(                      /* check for valid DOS time             */
USHORT dosTime);                   /*   DOS packed time                    */

Test a time in DOS packed format for validity.

dosTime

The time to test in DOS packed format.

Returns:

A non-zero value if the date

  • No labels