00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042 #include <assert.h>
00043 #include <stdlib.h>
00044 #include <stdio.h>
00045 #include <string.h>
00046 #include <time.h>
00047 #include <errno.h>
00048 #include "time64.h"
00049 #include "time64_limits.h"
00050
00051
00052
00053
00054 static struct TM Static_Return_Date;
00055 static char Static_Return_String[35];
00056
00057 static const int days_in_month[2][12] = {
00058 {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31},
00059 {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31},
00060 };
00061
00062 static const int julian_days_by_month[2][12] = {
00063 {0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334},
00064 {0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335},
00065 };
00066
00067 static char wday_name[7][4] = {
00068 "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"
00069 };
00070
00071 static char mon_name[12][4] = {
00072 "Jan", "Feb", "Mar", "Apr", "May", "Jun",
00073 "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
00074 };
00075
00076 static const int length_of_year[2] = { 365, 366 };
00077
00078
00079 static const Year years_in_gregorian_cycle = 400;
00080 #define days_in_gregorian_cycle ((365 * 400) + 100 - 4 + 1)
00081 static const Time64_T seconds_in_gregorian_cycle = days_in_gregorian_cycle * 60LL * 60LL * 24LL;
00082
00083
00084 #define MAX_SAFE_YEAR 2037
00085 #define MIN_SAFE_YEAR 1971
00086
00087
00088 #define SOLAR_CYCLE_LENGTH 28
00089
00090
00091 static const int safe_years_high[SOLAR_CYCLE_LENGTH] = {
00092 2016, 2017, 2018, 2019,
00093 2020, 2021, 2022, 2023,
00094 2024, 2025, 2026, 2027,
00095 2028, 2029, 2030, 2031,
00096 2032, 2033, 2034, 2035,
00097 2036, 2037, 2010, 2011,
00098 2012, 2013, 2014, 2015
00099 };
00100
00101
00102 static const int safe_years_low[SOLAR_CYCLE_LENGTH] = {
00103 1996, 1997, 1998, 1971,
00104 1972, 1973, 1974, 1975,
00105 1976, 1977, 1978, 1979,
00106 1980, 1981, 1982, 1983,
00107 1984, 1985, 1986, 1987,
00108 1988, 1989, 1990, 1991,
00109 1992, 1993, 1994, 1995,
00110 };
00111
00112
00113 static const int dow_year_start[SOLAR_CYCLE_LENGTH] = {
00114 5, 0, 1, 2,
00115 3, 5, 6, 0,
00116 1, 3, 4, 5,
00117 6, 1, 2, 3,
00118 4, 6, 0, 1,
00119 2, 4, 5, 6,
00120 0, 2, 3, 4
00121 };
00122
00123
00124
00125
00126
00127
00128 #define CHEAT_DAYS (1199145600 / 24 / 60 / 60)
00129 #define CHEAT_YEARS 108
00130
00131 #define IS_LEAP(n) ((!(((n) + 1900) % 400) || (!(((n) + 1900) % 4) && (((n) + 1900) % 100))) != 0)
00132 #define WRAP(a,b,m) ((a) = ((a) < 0 ) ? ((b)--, (a) + (m)) : (a))
00133
00134 #ifdef USE_SYSTEM_LOCALTIME
00135 # define SHOULD_USE_SYSTEM_LOCALTIME(a) ( \
00136 (a) <= SYSTEM_LOCALTIME_MAX && \
00137 (a) >= SYSTEM_LOCALTIME_MIN \
00138 )
00139 #else
00140 # define SHOULD_USE_SYSTEM_LOCALTIME(a) (0)
00141 #endif
00142
00143 #ifdef USE_SYSTEM_GMTIME
00144 # define SHOULD_USE_SYSTEM_GMTIME(a) ( \
00145 (a) <= SYSTEM_GMTIME_MAX && \
00146 (a) >= SYSTEM_GMTIME_MIN \
00147 )
00148 #else
00149 # define SHOULD_USE_SYSTEM_GMTIME(a) (0)
00150 #endif
00151
00152
00153 #ifdef TIME_64_DEBUG
00154 # define TIME64_TRACE(format) (fprintf(stderr, format))
00155 # define TIME64_TRACE1(format, var1) (fprintf(stderr, format, var1))
00156 # define TIME64_TRACE2(format, var1, var2) (fprintf(stderr, format, var1, var2))
00157 # define TIME64_TRACE3(format, var1, var2, var3) (fprintf(stderr, format, var1, var2, var3))
00158 #else
00159 # define TIME64_TRACE(format) ((void)0)
00160 # define TIME64_TRACE1(format, var1) ((void)0)
00161 # define TIME64_TRACE2(format, var1, var2) ((void)0)
00162 # define TIME64_TRACE3(format, var1, var2, var3) ((void)0)
00163 #endif
00164
00165
00166 static int is_exception_century(Year year)
00167 {
00168 int is_exception = ((year % 100 == 0) && !(year % 400 == 0));
00169 TIME64_TRACE1("# is_exception_century: %s\n", is_exception ? "yes" : "no");
00170
00171 return(is_exception);
00172 }
00173
00174
00175
00176
00177
00178
00179 int cmp_date( const struct TM* left, const struct tm* right ) {
00180 if( left->tm_year > right->tm_year )
00181 return 1;
00182 else if( left->tm_year < right->tm_year )
00183 return -1;
00184
00185 if( left->tm_mon > right->tm_mon )
00186 return 1;
00187 else if( left->tm_mon < right->tm_mon )
00188 return -1;
00189
00190 if( left->tm_mday > right->tm_mday )
00191 return 1;
00192 else if( left->tm_mday < right->tm_mday )
00193 return -1;
00194
00195 if( left->tm_hour > right->tm_hour )
00196 return 1;
00197 else if( left->tm_hour < right->tm_hour )
00198 return -1;
00199
00200 if( left->tm_min > right->tm_min )
00201 return 1;
00202 else if( left->tm_min < right->tm_min )
00203 return -1;
00204
00205 if( left->tm_sec > right->tm_sec )
00206 return 1;
00207 else if( left->tm_sec < right->tm_sec )
00208 return -1;
00209
00210 return 0;
00211 }
00212
00213
00214
00215
00216
00217 int date_in_safe_range( const struct TM* date, const struct tm* min, const struct tm* max ) {
00218 if( cmp_date(date, min) == -1 )
00219 return 0;
00220
00221 if( cmp_date(date, max) == 1 )
00222 return 0;
00223
00224 return 1;
00225 }
00226
00227
00228
00229
00230
00231
00232 Time64_T timegm64(const struct TM *date) {
00233 Time64_T days = 0;
00234 Time64_T seconds = 0;
00235 Year year;
00236 Year orig_year = (Year)date->tm_year;
00237 int cycles = 0;
00238
00239 if( orig_year > 100 ) {
00240 cycles = (orig_year - 100) / 400;
00241 orig_year -= cycles * 400;
00242 days += (Time64_T)cycles * days_in_gregorian_cycle;
00243 }
00244 else if( orig_year < -300 ) {
00245 cycles = (orig_year - 100) / 400;
00246 orig_year -= cycles * 400;
00247 days += (Time64_T)cycles * days_in_gregorian_cycle;
00248 }
00249 TIME64_TRACE3("# timegm/ cycles: %d, days: %lld, orig_year: %lld\n", cycles, days, orig_year);
00250
00251 if( orig_year > 70 ) {
00252 year = 70;
00253 while( year < orig_year ) {
00254 days += length_of_year[IS_LEAP(year)];
00255 year++;
00256 }
00257 }
00258 else if ( orig_year < 70 ) {
00259 year = 69;
00260 do {
00261 days -= length_of_year[IS_LEAP(year)];
00262 year--;
00263 } while( year >= orig_year );
00264 }
00265
00266 days += julian_days_by_month[IS_LEAP(orig_year)][date->tm_mon];
00267 days += date->tm_mday - 1;
00268
00269 seconds = days * 60 * 60 * 24;
00270
00271 seconds += date->tm_hour * 60 * 60;
00272 seconds += date->tm_min * 60;
00273 seconds += date->tm_sec;
00274
00275 return(seconds);
00276 }
00277
00278
00279 static int check_tm(struct TM *tm)
00280 {
00281
00282 assert(tm->tm_sec >= 0);
00283 assert(tm->tm_sec <= 61);
00284
00285 assert(tm->tm_min >= 0);
00286 assert(tm->tm_min <= 59);
00287
00288 assert(tm->tm_hour >= 0);
00289 assert(tm->tm_hour <= 23);
00290
00291 assert(tm->tm_mday >= 1);
00292 assert(tm->tm_mday <= days_in_month[IS_LEAP(tm->tm_year)][tm->tm_mon]);
00293
00294 assert(tm->tm_mon >= 0);
00295 assert(tm->tm_mon <= 11);
00296
00297 assert(tm->tm_wday >= 0);
00298 assert(tm->tm_wday <= 6);
00299
00300 assert(tm->tm_yday >= 0);
00301 assert(tm->tm_yday <= length_of_year[IS_LEAP(tm->tm_year)]);
00302
00303 #ifdef HAS_TM_TM_GMTOFF
00304 assert(tm->tm_gmtoff >= -24 * 60 * 60);
00305 assert(tm->tm_gmtoff <= 24 * 60 * 60);
00306 #endif
00307
00308 return 1;
00309 }
00310
00311
00312
00313
00314
00315 static Year cycle_offset(Year year)
00316 {
00317 const Year start_year = 2000;
00318 Year year_diff = year - start_year;
00319 Year exceptions;
00320
00321 if( year > start_year )
00322 year_diff--;
00323
00324 exceptions = year_diff / 100;
00325 exceptions -= year_diff / 400;
00326
00327 TIME64_TRACE3("# year: %lld, exceptions: %lld, year_diff: %lld\n",
00328 year, exceptions, year_diff);
00329
00330 return exceptions * 16;
00331 }
00332
00333
00334
00335
00336
00337
00338
00339
00340
00341
00342
00343
00344
00345
00346
00347
00348
00349
00350 static int safe_year(const Year year)
00351 {
00352 int safe_year = 0;
00353 Year year_cycle;
00354
00355 if( year >= MIN_SAFE_YEAR && year <= MAX_SAFE_YEAR ) {
00356 return (int)year;
00357 }
00358
00359 year_cycle = year + cycle_offset(year);
00360
00361
00362 if( year < MIN_SAFE_YEAR )
00363 year_cycle -= 8;
00364
00365
00366 if( is_exception_century(year) )
00367 year_cycle += 11;
00368
00369
00370 if( is_exception_century(year - 1) )
00371 year_cycle += 17;
00372
00373 year_cycle %= SOLAR_CYCLE_LENGTH;
00374 if( year_cycle < 0 )
00375 year_cycle = SOLAR_CYCLE_LENGTH + year_cycle;
00376
00377 assert( year_cycle >= 0 );
00378 assert( year_cycle < SOLAR_CYCLE_LENGTH );
00379 if( year < MIN_SAFE_YEAR )
00380 safe_year = safe_years_low[year_cycle];
00381 else if( year > MAX_SAFE_YEAR )
00382 safe_year = safe_years_high[year_cycle];
00383 else
00384 assert(0);
00385
00386 TIME64_TRACE3("# year: %lld, year_cycle: %lld, safe_year: %d\n",
00387 year, year_cycle, safe_year);
00388
00389 assert(safe_year <= MAX_SAFE_YEAR && safe_year >= MIN_SAFE_YEAR);
00390
00391 return safe_year;
00392 }
00393
00394
00395 void copy_tm_to_TM64(const struct tm *src, struct TM *dest) {
00396 if( src == NULL ) {
00397 memset(dest, 0, sizeof(*dest));
00398 }
00399 else {
00400 # ifdef USE_TM64
00401 dest->tm_sec = src->tm_sec;
00402 dest->tm_min = src->tm_min;
00403 dest->tm_hour = src->tm_hour;
00404 dest->tm_mday = src->tm_mday;
00405 dest->tm_mon = src->tm_mon;
00406 dest->tm_year = (Year)src->tm_year;
00407 dest->tm_wday = src->tm_wday;
00408 dest->tm_yday = src->tm_yday;
00409 dest->tm_isdst = src->tm_isdst;
00410
00411 # ifdef HAS_TM_TM_GMTOFF
00412 dest->tm_gmtoff = src->tm_gmtoff;
00413 # endif
00414
00415 # ifdef HAS_TM_TM_ZONE
00416 dest->tm_zone = src->tm_zone;
00417 # endif
00418
00419 # else
00420
00421 memcpy(dest, src, sizeof(*dest));
00422 # endif
00423 }
00424 }
00425
00426
00427 void copy_TM64_to_tm(const struct TM *src, struct tm *dest) {
00428 if( src == NULL ) {
00429 memset(dest, 0, sizeof(*dest));
00430 }
00431 else {
00432 # ifdef USE_TM64
00433 dest->tm_sec = src->tm_sec;
00434 dest->tm_min = src->tm_min;
00435 dest->tm_hour = src->tm_hour;
00436 dest->tm_mday = src->tm_mday;
00437 dest->tm_mon = src->tm_mon;
00438 dest->tm_year = (int)src->tm_year;
00439 dest->tm_wday = src->tm_wday;
00440 dest->tm_yday = src->tm_yday;
00441 dest->tm_isdst = src->tm_isdst;
00442
00443 # ifdef HAS_TM_TM_GMTOFF
00444 dest->tm_gmtoff = src->tm_gmtoff;
00445 # endif
00446
00447 # ifdef HAS_TM_TM_ZONE
00448 dest->tm_zone = src->tm_zone;
00449 # endif
00450
00451 # else
00452
00453 memcpy(dest, src, sizeof(*dest));
00454 # endif
00455 }
00456 }
00457
00458
00459
00460 struct tm * fake_localtime_r(const time_t *time, struct tm *result) {
00461 const struct tm *static_result = localtime(time);
00462
00463 assert(result != NULL);
00464
00465 if( static_result == NULL ) {
00466 memset(result, 0, sizeof(*result));
00467 return NULL;
00468 }
00469 else {
00470 memcpy(result, static_result, sizeof(*result));
00471 return result;
00472 }
00473 }
00474
00475
00476
00477 struct tm * fake_gmtime_r(const time_t *time, struct tm *result) {
00478 const struct tm *static_result = gmtime(time);
00479
00480 assert(result != NULL);
00481
00482 if( static_result == NULL ) {
00483 memset(result, 0, sizeof(*result));
00484 return NULL;
00485 }
00486 else {
00487 memcpy(result, static_result, sizeof(*result));
00488 return result;
00489 }
00490 }
00491
00492
00493 static Time64_T seconds_between_years(Year left_year, Year right_year) {
00494 int increment = (left_year > right_year) ? 1 : -1;
00495 Time64_T seconds = 0;
00496 int cycles;
00497
00498 if( left_year > 2400 ) {
00499 cycles = (left_year - 2400) / 400;
00500 left_year -= cycles * 400;
00501 seconds += cycles * seconds_in_gregorian_cycle;
00502 }
00503 else if( left_year < 1600 ) {
00504 cycles = (left_year - 1600) / 400;
00505 left_year += cycles * 400;
00506 seconds += cycles * seconds_in_gregorian_cycle;
00507 }
00508
00509 while( left_year != right_year ) {
00510 seconds += length_of_year[IS_LEAP(right_year - 1900)] * 60 * 60 * 24;
00511 right_year += increment;
00512 }
00513
00514 return seconds * increment;
00515 }
00516
00517
00518 Time64_T mktime64(const struct TM *input_date) {
00519 struct tm safe_date;
00520 struct TM date;
00521 Time64_T time;
00522 Year year = input_date->tm_year + 1900;
00523
00524 if( date_in_safe_range(input_date, &SYSTEM_MKTIME_MIN, &SYSTEM_MKTIME_MAX) )
00525 {
00526 copy_TM64_to_tm(input_date, &safe_date);
00527 return (Time64_T)mktime(&safe_date);
00528 }
00529
00530
00531 date = *input_date;
00532 date.tm_year = safe_year(year) - 1900;
00533 copy_TM64_to_tm(&date, &safe_date);
00534
00535 time = (Time64_T)mktime(&safe_date);
00536
00537 time += seconds_between_years(year, (Year)(safe_date.tm_year + 1900));
00538
00539 return time;
00540 }
00541
00542
00543
00544 Time64_T timelocal64(const struct TM *date) {
00545 return mktime64(date);
00546 }
00547
00548
00549 struct TM *gmtime64_r (const Time64_T *in_time, struct TM *p)
00550 {
00551 int v_tm_sec, v_tm_min, v_tm_hour, v_tm_mon, v_tm_wday;
00552 Time64_T v_tm_tday;
00553 int leap;
00554 Time64_T m;
00555 Time64_T time = *in_time;
00556 Year year = 70;
00557 int cycles = 0;
00558
00559 assert(p != NULL);
00560
00561
00562 if( SHOULD_USE_SYSTEM_GMTIME(*in_time) ) {
00563 time_t safe_time = (time_t)*in_time;
00564 struct tm safe_date;
00565 GMTIME_R(&safe_time, &safe_date);
00566
00567 copy_tm_to_TM64(&safe_date, p);
00568 assert(check_tm(p));
00569
00570 return p;
00571 }
00572
00573 #ifdef HAS_TM_TM_GMTOFF
00574 p->tm_gmtoff = 0;
00575 #endif
00576 p->tm_isdst = 0;
00577
00578 #ifdef HAS_TM_TM_ZONE
00579 p->tm_zone = "UTC";
00580 #endif
00581
00582 v_tm_sec = (int)(time % 60);
00583 time /= 60;
00584 v_tm_min = (int)(time % 60);
00585 time /= 60;
00586 v_tm_hour = (int)(time % 24);
00587 time /= 24;
00588 v_tm_tday = time;
00589
00590 WRAP (v_tm_sec, v_tm_min, 60);
00591 WRAP (v_tm_min, v_tm_hour, 60);
00592 WRAP (v_tm_hour, v_tm_tday, 24);
00593
00594 v_tm_wday = (int)((v_tm_tday + 4) % 7);
00595 if (v_tm_wday < 0)
00596 v_tm_wday += 7;
00597 m = v_tm_tday;
00598
00599 if (m >= CHEAT_DAYS) {
00600 year = CHEAT_YEARS;
00601 m -= CHEAT_DAYS;
00602 }
00603
00604 if (m >= 0) {
00605
00606 cycles = (int)(m / (Time64_T) days_in_gregorian_cycle);
00607 if( cycles ) {
00608 m -= (cycles * (Time64_T) days_in_gregorian_cycle);
00609 year += (cycles * years_in_gregorian_cycle);
00610 }
00611
00612
00613 leap = IS_LEAP (year);
00614 while (m >= (Time64_T) length_of_year[leap]) {
00615 m -= (Time64_T) length_of_year[leap];
00616 year++;
00617 leap = IS_LEAP (year);
00618 }
00619
00620
00621 v_tm_mon = 0;
00622 while (m >= (Time64_T) days_in_month[leap][v_tm_mon]) {
00623 m -= (Time64_T) days_in_month[leap][v_tm_mon];
00624 v_tm_mon++;
00625 }
00626 } else {
00627 year--;
00628
00629
00630 cycles = (int)((m / (Time64_T) days_in_gregorian_cycle) + 1);
00631 if( cycles ) {
00632 m -= (cycles * (Time64_T) days_in_gregorian_cycle);
00633 year += (cycles * years_in_gregorian_cycle);
00634 }
00635
00636
00637 leap = IS_LEAP (year);
00638 while (m < (Time64_T) -length_of_year[leap]) {
00639 m += (Time64_T) length_of_year[leap];
00640 year--;
00641 leap = IS_LEAP (year);
00642 }
00643
00644
00645 v_tm_mon = 11;
00646 while (m < (Time64_T) -days_in_month[leap][v_tm_mon]) {
00647 m += (Time64_T) days_in_month[leap][v_tm_mon];
00648 v_tm_mon--;
00649 }
00650 m += (Time64_T) days_in_month[leap][v_tm_mon];
00651 }
00652
00653 p->tm_year = year;
00654 if( p->tm_year != year ) {
00655 #ifdef EOVERFLOW
00656 errno = EOVERFLOW;
00657 #endif
00658 return NULL;
00659 }
00660
00661
00662 p->tm_mday = (int) m + 1;
00663 p->tm_yday = julian_days_by_month[leap][v_tm_mon] + (int)m;
00664 p->tm_sec = v_tm_sec;
00665 p->tm_min = v_tm_min;
00666 p->tm_hour = v_tm_hour;
00667 p->tm_mon = v_tm_mon;
00668 p->tm_wday = v_tm_wday;
00669
00670 assert(check_tm(p));
00671
00672 return p;
00673 }
00674
00675
00676 struct TM *localtime64_r (const Time64_T *time, struct TM *local_tm)
00677 {
00678 time_t safe_time;
00679 struct tm safe_date;
00680 struct TM gm_tm;
00681 Year orig_year;
00682 int month_diff;
00683
00684 assert(local_tm != NULL);
00685
00686
00687 if( SHOULD_USE_SYSTEM_LOCALTIME(*time) ) {
00688 safe_time = (time_t)*time;
00689
00690 TIME64_TRACE1("Using system localtime for %lld\n", *time);
00691
00692 LOCALTIME_R(&safe_time, &safe_date);
00693
00694 copy_tm_to_TM64(&safe_date, local_tm);
00695 assert(check_tm(local_tm));
00696
00697 return local_tm;
00698 }
00699
00700 if( gmtime64_r(time, &gm_tm) == NULL ) {
00701 TIME64_TRACE1("gmtime64_r returned null for %lld\n", *time);
00702 return NULL;
00703 }
00704
00705 orig_year = gm_tm.tm_year;
00706
00707 if (gm_tm.tm_year > (2037 - 1900) ||
00708 gm_tm.tm_year < (1970 - 1900)
00709 )
00710 {
00711 TIME64_TRACE1("Mapping tm_year %lld to safe_year\n", (Year)gm_tm.tm_year);
00712 gm_tm.tm_year = safe_year((Year)(gm_tm.tm_year + 1900)) - 1900;
00713 }
00714
00715 safe_time = (time_t)timegm64(&gm_tm);
00716 if( LOCALTIME_R(&safe_time, &safe_date) == NULL ) {
00717 TIME64_TRACE1("localtime_r(%d) returned NULL\n", (int)safe_time);
00718 return NULL;
00719 }
00720
00721 copy_tm_to_TM64(&safe_date, local_tm);
00722
00723 local_tm->tm_year = orig_year;
00724 if( local_tm->tm_year != orig_year ) {
00725 TIME64_TRACE2("tm_year overflow: tm_year %lld, orig_year %lld\n",
00726 (Year)local_tm->tm_year, (Year)orig_year);
00727
00728 #ifdef EOVERFLOW
00729 errno = EOVERFLOW;
00730 #endif
00731 return NULL;
00732 }
00733
00734
00735 month_diff = local_tm->tm_mon - gm_tm.tm_mon;
00736
00737
00738
00739
00740 if( month_diff == 11 ) {
00741 local_tm->tm_year--;
00742 }
00743
00744
00745
00746
00747 if( month_diff == -11 ) {
00748 local_tm->tm_year++;
00749 }
00750
00751
00752
00753
00754
00755
00756
00757 if( !IS_LEAP(local_tm->tm_year) && local_tm->tm_yday == 365 )
00758 local_tm->tm_yday--;
00759
00760 assert(check_tm(local_tm));
00761
00762 return local_tm;
00763 }
00764
00765
00766 int valid_tm_wday( const struct TM* date ) {
00767 if( 0 <= date->tm_wday && date->tm_wday <= 6 )
00768 return 1;
00769 else
00770 return 0;
00771 }
00772
00773 int valid_tm_mon( const struct TM* date ) {
00774 if( 0 <= date->tm_mon && date->tm_mon <= 11 )
00775 return 1;
00776 else
00777 return 0;
00778 }
00779
00780
00781 char *asctime64_r( const struct TM* date, char *result ) {
00782
00783
00784 if( !valid_tm_wday(date) || !valid_tm_mon(date) )
00785 return NULL;
00786
00787 sprintf(result, TM64_ASCTIME_FORMAT,
00788 wday_name[date->tm_wday],
00789 mon_name[date->tm_mon],
00790 date->tm_mday, date->tm_hour,
00791 date->tm_min, date->tm_sec,
00792 1900 + date->tm_year);
00793
00794 return result;
00795 }
00796
00797
00798 char *ctime64_r( const Time64_T* time, char* result ) {
00799 struct TM date;
00800
00801 localtime64_r( time, &date );
00802 return asctime64_r( &date, result );
00803 }
00804
00805
00806
00807 struct TM *localtime64(const Time64_T *time) {
00808 tzset();
00809 return localtime64_r(time, &Static_Return_Date);
00810 }
00811
00812 struct TM *gmtime64(const Time64_T *time) {
00813 return gmtime64_r(time, &Static_Return_Date);
00814 }
00815
00816 char *asctime64( const struct TM* date ) {
00817 return asctime64_r( date, Static_Return_String );
00818 }
00819
00820 char *ctime64( const Time64_T* time ) {
00821 tzset();
00822 return asctime64(localtime64(time));
00823 }