/* Copyright (C) 2008 Emmanuel Varoquaux
This file is part of XOS.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see . */
#include "time.h"
#include
static struct tm static_tm;
struct tm __attribute__ ((weak, visibility ("default"))) *gmtime(const time_t *timep)
{
return __make_tm(timep, __utc_tz, &static_tm);
}
struct tm __attribute__ ((weak, visibility ("default"))) *localtime(const time_t *timep)
{
__tzset();
return __make_tm(timep, __current_tz, &static_tm);
}
time_t __attribute__ ((weak, visibility ("default"))) mktime(struct tm *tm)
{
__tzset();
return __make_time(tm, __current_tz);
}
char __attribute__ ((weak, visibility ("default"))) *asctime(const struct tm *tm)
{
static char wday_name[7][3] = {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"};
static char mon_name[12][3] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
static char result[26];
sprintf(result, "%.3s %.3s%3d %.2d:%.2d:%.2d %d\n",
wday_name[tm->tm_wday],
mon_name[tm->tm_mon],
tm->tm_mday, tm->tm_hour,
tm->tm_min, tm->tm_sec,
1900 + tm->tm_year);
return result;
}
char __attribute__ ((weak, visibility ("default"))) *ctime(const time_t *timep)
{
struct tm *tm;
if (!(tm = localtime(timep)))
return NULL;
return asctime(tm);
}