libc: fix localtime() for December

This commit is contained in:
K. Lange 2018-12-01 11:09:09 +09:00
parent b5754538ec
commit b1f7295d48
2 changed files with 5 additions and 0 deletions

View File

@ -22,6 +22,8 @@ static int day_of_week(long seconds) {
static long days_in_month(int month, int year) {
switch(month) {
case 12:
return 31;
case 11:
return 30;
case 10:

View File

@ -37,6 +37,9 @@ static char * months_short[] = {
};
size_t strftime(char *s, size_t max, const char *fmt, const struct tm *tm) {
if (!tm) {
return sprintf(s, "[tm is null]");
}
char * b = s;
size_t count = 0;
for (const char *f = fmt; *f; f++) {