Codechange: Use {ZEROFILL_NUM} instead of custom seprintf + {RAW_STRING}

This commit is contained in:
Rubidium 2023-04-16 19:36:43 +02:00 committed by rubidium42
parent e97bf271dc
commit 29b09523d1
2 changed files with 4 additions and 9 deletions

View File

@ -5521,10 +5521,10 @@ STR_VEHICLE_NAME_AIRCRAFT_POWERNAUT_HELICOPTER :Powernaut Helic
##id 0x8800
# Formatting of some strings
STR_FORMAT_DATE_TINY :{RAW_STRING}-{RAW_STRING}-{NUM}
STR_FORMAT_DATE_TINY :{ZEROFILL_NUM}-{ZEROFILL_NUM}-{NUM}
STR_FORMAT_DATE_SHORT :{STRING} {NUM}
STR_FORMAT_DATE_LONG :{STRING} {STRING} {NUM}
STR_FORMAT_DATE_ISO :{2:NUM}-{1:RAW_STRING}-{0:RAW_STRING}
STR_FORMAT_DATE_ISO :{2:NUM}-{1:ZEROFILL_NUM}-{0:ZEROFILL_NUM}
STR_FORMAT_COMPANY_NUM :(Company {COMMA})
STR_FORMAT_GROUP_NAME :Group {COMMA}

View File

@ -448,13 +448,8 @@ static char *FormatTinyOrISODate(char *buff, Date date, StringID str, const char
YearMonthDay ymd;
ConvertDateToYMD(date, &ymd);
char day[3];
char month[3];
/* We want to zero-pad the days and months */
seprintf(day, lastof(day), "%02i", ymd.day);
seprintf(month, lastof(month), "%02i", ymd.month + 1);
int64 args[] = {(int64)(size_t)day, (int64)(size_t)month, ymd.year};
/* Day and month are zero-padded with ZEROFILL_NUM, hence the two 2s. */
int64 args[] = {ymd.day, 2, ymd.month + 1, 2, ymd.year};
StringParameters tmp_params(args);
return FormatString(buff, GetStringPtr(str), &tmp_params, last);
}