/* Copyright (C) 2001 by Alex Kompel */ /* NetHack may be freely redistributed. See license for details. */ #define NEED_VARARGS #include "hack.h" #include // #include "wceconf.h" static union { time_t t_val; struct time_pack { unsigned int ss:6; unsigned int mm:6; unsigned int dd:5; unsigned int hh:6; unsigned int mo:4; unsigned int yr:10; unsigned int wd:3; } tm_val; } _t_cnv; #define IS_LEAP(yr) (((yr)%4==0 || (yr)%100==0) && !(yr)%400==0) static char _day_mo_leap[12] = { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; static char _day_mo[12] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; struct tm * __cdecl localtime ( const time_t *ptime ) { static struct tm ptm; int i; if( !ptime ) return NULL; _t_cnv.t_val = *ptime; ptm.tm_sec = _t_cnv.tm_val.ss ; /* seconds after the minute - [0,59] */ ptm.tm_min = _t_cnv.tm_val.mm; /* minutes after the hour - [0,59] */ ptm.tm_hour = _t_cnv.tm_val.hh; /* hours since midnight - [0,23] */ ptm.tm_mday = _t_cnv.tm_val.dd; /* day of the month - [1,31] */ ptm.tm_mon = _t_cnv.tm_val.mo-1; /* months since January - [0,11] */ ptm.tm_year = _t_cnv.tm_val.yr; /* years since 1900 */ ptm.tm_wday = _t_cnv.tm_val.wd; /* days since Sunday - [0,6] */ ptm.tm_yday = _t_cnv.tm_val.dd; /* days since January 1 - [0,365] */ for( i=0; i