summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2009-01-03 00:56:16 +0000
committerrubidium <rubidium@openttd.org>2009-01-03 00:56:16 +0000
commitaff7feb767a4efa5221762b253fbe329ae65df10 (patch)
tree146df10fcdd46f6f9aa4ee97d861341567f8e83b
parent3a0d966ae408aecc0bdad3325c1cc75927d58e89 (diff)
downloadopenttd-aff7feb767a4efa5221762b253fbe329ae65df10.tar.xz
(svn r14791) -Add: the ability to make ISO dates with the string system (PhilSophus)
-rw-r--r--src/lang/english.txt1
-rw-r--r--src/strgen/strgen.cpp1
-rw-r--r--src/strings.cpp11
-rw-r--r--src/table/control_codes.h1
4 files changed, 11 insertions, 3 deletions
diff --git a/src/lang/english.txt b/src/lang/english.txt
index 68afbcf1d..3eedcec3b 100644
--- a/src/lang/english.txt
+++ b/src/lang/english.txt
@@ -3504,6 +3504,7 @@ STR_MEASURE_AREA_HEIGHTDIFF :{BLACK}Area: {N
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}
########
diff --git a/src/strgen/strgen.cpp b/src/strgen/strgen.cpp
index 53864716d..4f4008bf5 100644
--- a/src/strgen/strgen.cpp
+++ b/src/strgen/strgen.cpp
@@ -479,6 +479,7 @@ static const CmdStruct _cmd_structs[] = {
{"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},
diff --git a/src/strings.cpp b/src/strings.cpp
index 0117f7be3..2373a4c4e 100644
--- a/src/strings.cpp
+++ b/src/strings.cpp
@@ -284,7 +284,7 @@ static char *FormatMonthAndYear(char *buff, Date date, const char *last)
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 @@ static char *FormatTinyDate(char *buff, Date date, const char *last)
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 @@ static char *FormatString(char *buff, const char *str, const int64 *argv, uint c
}
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;
}
diff --git a/src/table/control_codes.h b/src/table/control_codes.h
index e951c6f16..2fc9be40d 100644
--- a/src/table/control_codes.h
+++ b/src/table/control_codes.h
@@ -53,6 +53,7 @@ enum StringControlCode {
SCC_DATE_TINY,
SCC_DATE_SHORT,
SCC_DATE_LONG,
+ SCC_DATE_ISO,
SCC_STRING1,
SCC_STRING2,