(C) 1998 AROS - The Amiga Research OS


NAME
#include <dos/datetime.h>
#include <proto/dos.h>

BOOL DateToStr (datetime)

LOCATION
In DOSBase at offset 124

SYNOPSIS
struct DateTime * datetime

FUNCTION
DateToStr converts an AmigaDOS DateStamp to a human readable ASCII string as requested by your settings in the DateTime structure.

INPUTS
DateTime
a pointer to an initialized DateTime structure. The DateTime structure should be initialized as follows:

\begin{description} \item{dat_Stamp} The datestamp to convert to ascii

\item{dat_Format} How to convert the datestamp into dat_StrDate. Can be any of the following:

\begin{description}

dd
mmm-yy). This is the default if you specify something other than any entry in this list.

yy
mmm-dd).

mm
dd-yy).

dd
mm-yy).

\item{FORMAT_DEF} default format for locale.

\end{description}

\item{dat_Flags} Modifies dat_Format. The only flag used by this function is DTF_SUBST. If set, then a string like "Today" or "Monday" is generated instead of the normal format if possible.

\item{dat_StrDay} Pointer to a buffer to receive the day of the week string. (Monday, Tuesday, etc.). If null, this string will not be generated.

\item{dat_StrDate} Pointer to a buffer to receive the date string, in the format requested by dat_Format, subject to possible modifications by DTF_SUBST. If null, this string will not be generated.

\item{dat_StrTime} Pointer to a buffer to receive the time of day string. If NULL, this will not be generated.

\end{description}

RESULT
A zero return indicates that the DateStamp was invalid, and could not be converted. Non-zero indicates that the call succeeded.

EXAMPLE
#	include 
#	include 
#	undef AROS_LH1
#	undef DateToStr
#	undef AROS_LHA
#	define AROS_LH1(ret,name,arg,type,base,offset,libname) \
    ret name (arg)
#	define AROS_LHA(type,name,reg) type name

#	include 
#	include 
#	include 

int main (int argc, char ** argv)
{
    struct DateTime curr;
    char day[LEN_DATSTRING];
    char time[LEN_DATSTRING];
    char date[LEN_DATSTRING];

    DateStamp (&curr.dat_Stamp);

    curr.dat_Format  = FORMAT_DOS;
    curr.dat_Flags   = 0;
    curr.dat_StrDay  = day;
    curr.dat_StrDate = date;
    curr.dat_StrTime = time;

    DateToStr (&curr);

    printf ("Today is %s, %s. It's %s\n"
	, day
	, date
	, time
    );

    curr.dat_Format = FORMAT_DEF;

    DateToStr (&curr);

    printf ("Local date: %s\n", date);

    curr.dat_Flags = DTF_SUBST;

    DateToStr (&curr);

    printf ("Date with DTF_SUBST: %s\n", date);

    curr.dat_Stamp.ds_Days ++;

    DateToStr (&curr);

    printf ("Date +1 with DTF_SUBST: %s\n", date);

    curr.dat_Stamp.ds_Days ++;

    DateToStr (&curr);

    printf ("Date +2 with DTF_SUBST: %s\n", date);

    curr.dat_Stamp.ds_Days ++;

    DateToStr (&curr);

    printf ("Date +3 with DTF_SUBST: %s\n", date);

    curr.dat_Stamp.ds_Days -= 4;

    DateToStr (&curr);

    printf ("Date -1 with DTF_SUBST: %s\n", date);

    curr.dat_Stamp.ds_Days --;

    DateToStr (&curr);

    printf ("Date -2 with DTF_SUBST: %s\n", date);

    curr.dat_Stamp.ds_Days --;

    DateToStr (&curr);

    printf ("Date -3 with DTF_SUBST: %s\n", date);

    curr.dat_Stamp.ds_Days   = 0;
    curr.dat_Stamp.ds_Minute = 0;
    curr.dat_Stamp.ds_Tick   = 0;

    DateToStr (&curr);

    printf ("First Date: %s, %s. Time: %s\n", day, date, time);

    curr.dat_Stamp.ds_Days   = 0;
    curr.dat_Stamp.ds_Minute = 1;
    curr.dat_Stamp.ds_Tick   = 0;

    DateToStr (&curr);

    printf ("First Date + 1 Minute: %s, %s. Time: %s\n", day, date, time);

    curr.dat_Stamp.ds_Days   = 0;
    curr.dat_Stamp.ds_Minute = 0;
    curr.dat_Stamp.ds_Tick   = 153;

    DateToStr (&curr);

    printf ("First Date + 153 Ticks: %s, %s. Time: %s\n", day, date, time);

    curr.dat_Stamp.ds_Days   = 1;
    curr.dat_Stamp.ds_Minute = 0;
    curr.dat_Stamp.ds_Tick   = 0;

    DateToStr (&curr);

    printf ("First Date: %s, %s. Time: %s\n", day, date, time);

    return 0;
} /* main */
SEE ALSO
DateStamp(), StrtoDate()

NOTES

BUGS

INTERNALS

HISTORY