mirror of
https://github.com/cc65/cc65.git
synced 2025-02-09 17:33:00 +00:00
Call strftime instead of formatting the time manually
git-svn-id: svn://svn.cc65.org/cc65/trunk@1515 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
parent
3ed8d565d4
commit
521f30c011
@ -46,33 +46,10 @@
|
|||||||
|
|
||||||
char* __fastcall__ asctime (const struct tm* timep)
|
char* __fastcall__ asctime (const struct tm* timep)
|
||||||
{
|
{
|
||||||
static const char days[7][4] = {
|
|
||||||
"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"
|
|
||||||
};
|
|
||||||
static const char months[12][4] = {
|
|
||||||
"Jan", "Feb", "Mar", "Apr", "May", "Jun",
|
|
||||||
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
|
|
||||||
};
|
|
||||||
static char buf[26];
|
static char buf[26];
|
||||||
|
|
||||||
/* Create a copy of the given data and make sure it is valid */
|
/* Format into given buffer and return the result */
|
||||||
struct tm t;
|
return strftime (buf, sizeof (buf), "%c\n", timep)? buf : 0;
|
||||||
t = *timep;
|
|
||||||
mktime (&t);
|
|
||||||
|
|
||||||
/* Format into given buffer */
|
|
||||||
sprintf(buf,
|
|
||||||
"%s %s%3d %02d:%02d:%02d %d\n",
|
|
||||||
days[t.tm_wday],
|
|
||||||
months[t.tm_mon],
|
|
||||||
t.tm_mday,
|
|
||||||
t.tm_hour,
|
|
||||||
t.tm_min,
|
|
||||||
t.tm_sec,
|
|
||||||
t.tm_year + 1900);
|
|
||||||
|
|
||||||
/* Return the result */
|
|
||||||
return buf;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user