Mercurial > hg > openttd
changeset 10534:19d06033b87d draft
(svn r14791) -Add: the ability to make ISO dates with the string system (PhilSophus)
author | rubidium <rubidium@openttd.org> |
---|---|
date | Sat, 03 Jan 2009 00:56:16 +0000 |
parents | 53a8506c2079 |
children | 7af21a64b4a4 |
files | src/lang/english.txt src/strgen/strgen.cpp src/strings.cpp src/table/control_codes.h |
diffstat | 4 files changed, 11 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lang/english.txt +++ b/src/lang/english.txt @@ -3504,6 +3504,7 @@ STR_DATE_TINY :{RAW_STRING}-{RAW_STRING}-{NUM} STR_DATE_SHORT :{STRING} {NUM} STR_DATE_LONG :{STRING} {STRING} {NUM} +STR_DATE_ISO :{2:NUM}-{1:RAW_STRING}-{0:RAW_STRING} ########
--- a/src/strgen/strgen.cpp +++ b/src/strgen/strgen.cpp @@ -479,6 +479,7 @@ {"DATE_TINY", EmitSingleChar, SCC_DATE_TINY, 1, 0}, {"DATE_SHORT", EmitSingleChar, SCC_DATE_SHORT, 1, 0}, {"DATE_LONG", EmitSingleChar, SCC_DATE_LONG, 1, 0}, + {"DATE_ISO", EmitSingleChar, SCC_DATE_ISO, 1, 0}, {"SKIP", EmitSingleChar, SCC_SKIP, 1, 0},
--- a/src/strings.cpp +++ b/src/strings.cpp @@ -284,7 +284,7 @@ return FormatString(buff, GetStringPtr(STR_DATE_SHORT), args, 0, last); } -static char *FormatTinyDate(char *buff, Date date, const char *last) +static char *FormatTinyOrISODate(char *buff, Date date, StringID str, const char *last) { YearMonthDay ymd; ConvertDateToYMD(date, &ymd); @@ -296,7 +296,7 @@ snprintf(month, lengthof(month), "%02i", ymd.month + 1); int64 args[3] = { (int64)(size_t)day, (int64)(size_t)month, ymd.year }; - return FormatString(buff, GetStringPtr(STR_DATE_TINY), args, 0, last); + return FormatString(buff, GetStringPtr(str), args, 0, last); } static char *FormatGenericCurrency(char *buff, const CurrencySpec *spec, Money number, bool compact, const char *last) @@ -714,7 +714,12 @@ } case SCC_DATE_TINY: { // {DATE_TINY} - buff = FormatTinyDate(buff, GetInt32(&argv), last); + buff = FormatTinyOrISODate(buff, GetInt32(&argv), STR_DATE_TINY, last); + break; + } + + case SCC_DATE_ISO: { // {DATE_ISO} + buff = FormatTinyOrISODate(buff, GetInt32(&argv), STR_DATE_ISO, last); break; }