3 * Copyright (C) 2004-2006, Parrot Foundation.
10 config\gen\platform\win32\time.c
14 Provides access to system time functions for Win32 platforms.
28 =item C<INTVAL Parrot_intval_time(void)>
30 Returns the current time as an INTVAL
37 Parrot_intval_time(void)
39 #if defined(_MSC_VER) && _MSC_VER >= 1400
41 return (INTVAL
)_time64(NULL
);
52 =item C<FLOATVAL Parrot_floatval_time(void)>
54 Returns the current time as a FLOATVAL.
61 Parrot_floatval_time(void)
64 /* 100 ns ticks since 1601-01-01 00:00:00 */
68 GetSystemTime(&sysTime
);
69 SystemTimeToFileTime(&sysTime
, &fileTime
);
70 /* Documented as the way to get a 64 bit from a FILETIME. */
71 memcpy(&i
, &fileTime
, sizeof (LARGE_INTEGER
));
73 /* FILETIME uses 100ns steps since 1601-01-01 00:00:00 as epoch.
74 * We'd like 1 second steps since 1970-01-01 00:00:00.
75 * To get there, divide by 10,000,000 to get from 100ns steps to seconds.
76 * Then subtract the seconds between 1601 and 1970, i.e. 11,644,473,600.
78 return (FLOATVAL
)i
.QuadPart
/ 10000000.0 - 11644473600.0;
84 =item C<void Parrot_sleep(unsigned int seconds)>
86 Sleeps for C<seconds> seconds.
93 Parrot_sleep(unsigned int seconds
)
95 Sleep(seconds
* 1000);
100 =item C<void Parrot_usleep(unsigned int microseconds)>
102 Sleep for at least the specified number of microseconds (millionths of a
110 Parrot_usleep(unsigned int microseconds
)
112 Sleep(microseconds
/ 1000);
117 =item C<struct tm * Parrot_gmtime_r(const time_t *t, struct tm *tm)>
119 Returns a C<time_t> structure for the current Greenwich Mean Time.
127 Parrot_gmtime_r(const time_t *t
, struct tm
*tm
)
135 =item C<struct tm * Parrot_localtime_r(const time_t *t, struct tm *tm)>
137 Returns a C<time_t> struct for the current local time.
145 Parrot_localtime_r(const time_t *t
, struct tm
*tm
)
153 =item C<char* Parrot_asctime_r(const struct tm *tm, char *buffer)>
155 Returns an ASCII representation of the C<struct tm>. Puts it in the
156 character array C<buffer>.
164 Parrot_asctime_r(const struct tm
*tm
, char *buffer
)
166 static const char wday_name
[7][4] =
167 { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" };
168 static const char mon_name
[12][4] =
169 { "Jan", "Feb", "Mar", "Apr", "May", "Jun",
170 "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" };
172 sprintf(buffer
, "%.3s %.3s%3d %.2d:%.2d:%.2d %d\n",
173 wday_name
[tm
->tm_wday
],
174 mon_name
[tm
->tm_mon
],
194 * c-file-style: "parrot"
196 * vim: expandtab shiftwidth=4: