2 #include <Preferences.h> // Core/System/
3 #include <DateTime.h> //Core/System/, DateToAscii() etc.
4 #include <TimeMgr.h> //Core/System/, TimGetTicks()
16 #define SEC_1904_1970 2082844800LU//0x7C25B080 // 0x7C25B080 == 2082844800LU
22 // UInt32 TimGetSeconds(void); // seconds since 1/1/1904
23 // void TimSetSeconds (UInt32 seconds); // seconds since 1/1/1904
24 // UInt32 TimGetTicks(void); // ticks since power on
25 sec
= TimGetSeconds ();
27 *T
= sec
- SEC_1904_1970
;
29 return (sec
- SEC_1904_1970
);
33 palmtimet2unixtm (const time_t t
, struct tm
*ptm
)
36 memset (&dt
, 0, sizeof (dt
));
37 memset (ptm
, 0, sizeof (*ptm
));
38 TimSecondsToDateTime (t
, &dt
);
39 ptm
->tm_sec
= dt
.second
;
40 ptm
->tm_min
= dt
.minute
;
41 ptm
->tm_hour
= dt
.hour
;
42 ptm
->tm_mday
= dt
.day
;
43 ptm
->tm_mon
= dt
.month
;
44 ptm
->tm_year
= dt
.year
;
45 ptm
->tm_wday
= dt
.weekDay
;
47 //ptm->tm_wday = DayOfWeek (dt.month, dt.day, dt.year);
48 //ptm->tm_mday = DayOfMonth (dt.month, dt.day, dt.year);
53 gmtime_r (const time_t *pt
, struct tm
*ptm
)
56 Int16 timeZone
= PrefGetPreference(prefTimeZone
);
57 Int16 daylightSavingAdjustment
= PrefGetPreference(prefDaylightSavingAdjustment
);
59 if ((NULL
== pt
) || (NULL
== ptm
)) {
62 utcTime
= TimTimeZoneToUTC (*pt
+ SEC_1904_1970
, timeZone
, daylightSavingAdjustment
);
63 palmtimet2unixtm (utcTime
, ptm
);
68 localtime_r (const time_t *pt
, struct tm
*ptm
)
71 Int16 timeZone
= PrefGetPreference(prefTimeZone
);
72 Int16 daylightSavingAdjustment
= PrefGetPreference(prefDaylightSavingAdjustment
);
73 if ((NULL
== pt
) || (NULL
== ptm
)) {
76 utcTime
= TimUTCToTimeZone (*pt
+ SEC_1904_1970
, timeZone
, daylightSavingAdjustment
);
77 palmtimet2unixtm (utcTime
, ptm
);
81 static struct tm g_gmtime_info;
84 gmtime (const time_t *CLOCK)
89 if (NULL == gmtime_r (CLOCK, &g_gmtime_info)) {
92 return &g_gmtime_info;
95 static struct tm g_localtime_info
;
98 localtime (const time_t *CLOCK
)
103 if (NULL
== localtime_r (CLOCK
, &g_localtime_info
)) {
106 return &g_localtime_info
;
109 static char * g_strftime_wdayconv
[][2] = {
113 {"Wed", "Wednesday"},
119 static char * g_strftime_monconv
[][2] = {
128 {"Sep", "September"},
133 #define SFCONV_ABBR 0
134 #define SFCONV_FULL 1
137 strftime (char *buf
, size_t sz_buf
, const char *fmt
, const struct tm
*ptm
)
141 if ((timeStringLength
> sz_buf
) || (strlen (fmt
) < 1)) {
144 memset (buf
, 0, sz_buf
);
147 for (; *p
!= '\0';) {
153 // FIXME: Åжϻº³åÊÇ·ñÒç³ö
156 strcpy (pret
, g_strftime_wdayconv
[ptm
->tm_wday
% 7][SFCONV_ABBR
]);
160 strcpy (pret
, g_strftime_wdayconv
[ptm
->tm_wday
% 7][SFCONV_FULL
]);
161 pret
+= strlen (g_strftime_wdayconv
[ptm
->tm_wday
% 7][SFCONV_FULL
]);
164 strcpy (pret
, g_strftime_monconv
[ptm
->tm_mon
% 12][SFCONV_ABBR
]);
168 strcpy (pret
, g_strftime_monconv
[ptm
->tm_mon
% 12][SFCONV_FULL
]);
169 pret
+= strlen (g_strftime_monconv
[ptm
->tm_mon
% 12][SFCONV_FULL
]);
172 strcpy (pret
, g_strftime_wdayconv
[ptm
->tm_wday
% 7][SFCONV_ABBR
]);
176 strcpy (pret
, g_strftime_monconv
[ptm
->tm_mon
% 12][SFCONV_ABBR
]);
180 sprintf (pret
, "%d %02d:%02d:%02d %d", ptm
->tm_mday
,
181 ptm
->tm_hour
, ptm
->tm_min
, ptm
->tm_sec
, ptm
->tm_year
);
182 pret
+= strlen (pret
);
185 sprintf (pret
, "%02d", ptm
->tm_mday
% 31);
189 sprintf (pret
, "%02d", ptm
->tm_hour
% 24);
193 sprintf (pret
, "%02d", (ptm
->tm_hour
% 12) + 1);
197 sprintf (pret
, "%03d", ptm
->tm_year
% 400);
201 sprintf (pret
, "%02d", (ptm
->tm_mon
% 12) + 1);
205 sprintf (pret
, "%02d", ptm
->tm_min
% 60);
209 if (ptm
->tm_hour
> 12) {
217 sprintf (pret
, "%02d", ptm
->tm_sec
% 61);
221 // FIXME: Week number with the first Sunday as the first day of week one (00-53)
222 sprintf (pret
, "%02d", ptm
->tm_yday
/ 7);
226 sprintf (pret
, "%d", ptm
->tm_wday
% 7);
230 // FIXME: Week number with the first Sunday as the first day of week one (00-53)
231 sprintf (pret
, "%02d", ptm
->tm_yday
/ 7);
235 sprintf (pret
, "%02d/%02d/%02d",
236 ptm
->tm_mon
, ptm
->tm_mday
, ptm
->tm_year
- 1900);
237 pret
+= strlen (pret
);
240 sprintf (pret
, "%02d:%02d:%02d",
241 ptm
->tm_hour
, ptm
->tm_min
, ptm
->tm_sec
);
242 pret
+= strlen (pret
);
245 sprintf (pret
, "%02d", ptm
->tm_year
- 1900);
249 sprintf (pret
, "%02d", ptm
->tm_year
);
250 pret
+= strlen (pret
);
255 ll
.language
= lmAnyLanguage
;
257 TimeZoneToAscii (ptm
->tm_gmtoff
, &ll
, pret
);
259 pret
+= strlen (pret
);
276 mktime (struct tm
*ptm
)
282 memset (&dt
, 0, sizeof (dt
));
283 dt
.second
= ptm
->tm_sec
;
284 dt
.minute
= ptm
->tm_min
;
285 dt
.hour
= ptm
->tm_hour
;
286 dt
.day
= ptm
->tm_mday
;
287 dt
.month
= ptm
->tm_mon
;
288 dt
.year
= ptm
->tm_year
;
289 dt
.weekDay
= ptm
->tm_wday
;
290 return TimDateTimeToSeconds (&dt
);
294 vsscanf (const char *s
, const char *format
, va_list param
)
299 FILE * fopen (const char *_name
, const char *_type
) {return NULL
;}
300 int fclose (FILE *fp
) {return 0;}
301 size_t fread (void *buf
, size_t _size
, size_t _n
, FILE *fp
) {return 0;}
302 size_t fwrite (const void *buf
, size_t _size
, size_t _n
, FILE *fp
) {return 0;}
303 int fseek (FILE *fp
, long offset
, int whence
) {return -1;}
304 long ftell (FILE *fp
) {return -1;}
305 int feof (FILE *fp
) {return -1;}
306 int ferror (FILE *fp
) {return -1;}
307 void clearerr (FILE *fp
) {}
309 #endif // __WXPALMOS6__
311 #define _BIT_ALPHA 0X0001
312 #define _BIT_BLANK 0X0002
313 #define _BIT_CNTRL 0X0004
314 #define _BIT_DIGIT 0X0008
315 #define _BIT_GRAPH 0X0010
316 #define _BIT_LOWER 0X0020
317 #define _BIT_PRINT 0X0040
318 #define _BIT_PUNCT 0X0080
319 #define _BIT_SPACE 0X0100
320 #define _BIT_UPPER 0X0200
321 #define _BIT_XDIGIT 0X0400
323 int iswalnum(wint_t C
) {return 0;}
324 int iswalpha(wint_t C
) {return 0;}
325 int iswcntrl(wint_t C
) {return 0;}
326 int iswdigit(wint_t C
) {return 0;}
327 int iswgraph(wint_t C
) {return 0;}
328 int iswlower(wint_t C
) {return 0;}
329 int iswprint(wint_t C
) {return 0;}
330 int iswpunct(wint_t C
) {return 0;}
331 int iswspace(wint_t C
) {return 0;}
332 int iswupper(wint_t C
) {return 0;}
333 int iswxdigit(wint_t C
) {return 0;}
335 wint_t towlower(wint_t C
) {return 0;}
336 wint_t towupper(wint_t C
) {return 0;}
337 size_t wcsftime(wchar_t *strDest
, size_t maxsize
, const wchar_t *format
, const struct tm
*timeptr
) {return 0;}
339 size_t wcslen (const wchar_t * str
) {return 0;}
340 wchar_t * wcscpy (wchar_t * dst
, const wchar_t * src
) {return NULL
;}
341 wchar_t * wcsncpy (wchar_t * dst
, const wchar_t * src
, size_t n
) {return NULL
;}
342 wchar_t * wcscat (wchar_t * dst
, const wchar_t * src
) {return NULL
;}
343 wchar_t * wcsncat (wchar_t * dst
, const wchar_t * src
, size_t n
) {return NULL
;}
344 int wcscmp (const wchar_t * str1
, const wchar_t * str2
) {return 0;}
345 int wcsncmp (const wchar_t * str1
, const wchar_t * str2
, size_t n
) {return 0;}
346 wchar_t * wcschr (const wchar_t * str
, const wchar_t chr
) {return NULL
;}
347 int wcscoll (const wchar_t *str1
, const wchar_t * str2
) {return 0;}
348 size_t wcsxfrm (wchar_t * str1
, const wchar_t * str2
, size_t n
) {return 0;}
349 wchar_t * wcsrchr (const wchar_t * str
, wchar_t chr
) {return NULL
;}
350 wchar_t * wcspbrk (const wchar_t * str
, const wchar_t * set
) {return NULL
;}
351 size_t wcsspn (const wchar_t * str
, const wchar_t * set
) {return 0;}
352 size_t wcscspn (const wchar_t * str
, const wchar_t * set
) {return 0;}
353 wchar_t * wcsstr (const wchar_t * str
, const wchar_t * pat
) {return NULL
;}
354 wchar_t * wcstok (wchar_t * str
, const wchar_t * set
, wchar_t ** a
) {return NULL
;}
356 unsigned long wcstoul (const wchar_t * a
, wchar_t ** b
, int c
) {return 0;}
357 double wcstod (const wchar_t * a
, wchar_t ** b
) {return 0.0;}
359 long wcstol (const wchar_t * str
, wchar_t ** end
, int base
) {return 0;}
360 char * setlocale (int category
, const char *locale
) {return NULL
;}