some fixes to accented characters
[tangerine.git] / rom / dos / datestamp.c
blob6b045133f9761e0586aa31a43b9b4dca7246573d
1 /*
2 Copyright © 1995-2007, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: DateStamp() - Get the current date.
6 Lang: english
7 */
8 #include <devices/timer.h>
9 #include <proto/timer.h>
10 #include "dos_intern.h"
12 #define SECONDS_PER_DAY (60UL * 60 * 24)
13 #define SECONDS_PER_MINUTE (60UL)
14 #define uSEC_PER_SEC (1000000UL)
15 #define TICKS_PER_SEC (50UL)
16 #define uSEC_PER_TICK (uSEC_PER_SEC / TICKS_PER_SEC)
18 /*****************************************************************************
20 NAME */
21 #include <proto/dos.h>
23 AROS_LH1(struct DateStamp *, DateStamp,
25 /* SYNOPSIS */
26 AROS_LHA(struct DateStamp *, date, D1),
28 /* LOCATION */
29 struct DosLibrary *, DOSBase, 32, Dos)
31 /* FUNCTION
32 Fills the structure with the current time. Time is measured from
33 Jan 1, 1978.
35 INPUTS
36 date - The structure to fill.
38 RESULT
39 date->ds_Days is filled with the days from Jan 1, 1978.
40 date->ds_Minute is filled with the number of minutes elapsed in the
41 day. date->ds_Tick is the number of ticks elapsed in the current
42 minute. A tick happens 50 times a second. DateStamp() ensures that
43 the day and minute are consistent. All three elements are zero if
44 the date is unset.
46 NOTES
47 The original function could only return even multiples of 50 ticks.
49 EXAMPLE
51 BUGS
53 SEE ALSO
55 INTERNALS
57 *****************************************************************************/
59 AROS_LIBFUNC_INIT
61 /* We get the date from the timer.device before splitting it up */
62 struct timeval tv;
63 GetSysTime(&tv);
65 date->ds_Days = tv.tv_secs / SECONDS_PER_DAY;
66 tv.tv_secs %= SECONDS_PER_DAY;
67 date->ds_Minute = tv.tv_secs / SECONDS_PER_MINUTE;
68 tv.tv_secs %= SECONDS_PER_MINUTE;
69 date->ds_Tick = (tv.tv_micro + tv.tv_secs * uSEC_PER_SEC) /
70 uSEC_PER_TICK;
72 return date;
73 AROS_LIBFUNC_EXIT
74 } /* DateStamp */