1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 04:57:45 +00:00

LibC: Reimplement asctime() in terms of strftime()

This commit is contained in:
howar6hill 2020-03-08 17:00:58 +08:00 committed by Andreas Kling
parent 32f15f3c45
commit df40847c52

View file

@ -168,14 +168,9 @@ static char mon_long_names[12][10] = {
char* asctime(const struct tm* tm) char* asctime(const struct tm* tm)
{ {
constexpr int maxLength = 69; static char buffer[69];
StringBuilder builder { maxLength }; strftime(buffer, sizeof buffer, "%a %b %e %T %Y", tm);
builder.appendf("%.3s %.3s %2d %02d:%02d:%02d %4d\n", wday_short_names[tm->tm_wday], return buffer;
mon_short_names[tm->tm_mon], tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec, 1900 + tm->tm_year);
static char result[maxLength];
strncpy(result, builder.build().characters(), sizeof result);
return result;
} }
//FIXME: Some formats are not supported. //FIXME: Some formats are not supported.