Changeset - r10534:d6624b9bdf98
[Not reviewed]
master
0 4 0
rubidium - 15 years ago 2009-01-03 00:56:16
rubidium@openttd.org
(svn r14791) -Add: the ability to make ISO dates with the string system (PhilSophus)
4 files changed with 11 insertions and 3 deletions:
0 comments (0 inline, 0 general)
src/lang/english.txt
Show inline comments
 
@@ -3501,12 +3501,13 @@ STR_MEASURE_LENGTH_HEIGHTDIFF           
 
STR_MEASURE_AREA_HEIGHTDIFF                                     :{BLACK}Area: {NUM} x {NUM}{}Height difference: {NUM} m
 

	
 
############ Date formatting
 
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}
 

	
 
########
 

	
 
STR_FEEDER_CARGO_VALUE                                          :{BLACK}Transfer Credits: {LTBLUE}{CURRENCY}
 
STR_DRIVE_THROUGH_ERROR_ON_TOWN_ROAD                            :{WHITE}...this is a town owned road
 
STR_DRIVE_THROUGH_ERROR_DIRECTION                               :{WHITE}...road facing in the wrong direction
src/strgen/strgen.cpp
Show inline comments
 
@@ -476,12 +476,13 @@ static const CmdStruct _cmd_structs[] = 
 
	{"P", EmitPlural, 0, 0, C_DONTCOUNT}, // plural specifier
 
	{"G", EmitGender, 0, 0, C_DONTCOUNT}, // gender specifier
 

	
 
	{"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},
 

	
 
	{"STRING", EmitSingleChar, SCC_STRING, 1, C_CASE},
 
	{"RAW_STRING", EmitSingleChar, SCC_RAW_STRING_POINTER, 1, 0},
 

	
src/strings.cpp
Show inline comments
 
@@ -281,25 +281,25 @@ static char *FormatMonthAndYear(char *bu
 
	ConvertDateToYMD(date, &ymd);
 

	
 
	int64 args[2] = { STR_MONTH_JAN + ymd.month, ymd.year };
 
	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);
 

	
 
	char day[3];
 
	char month[3];
 
	/* We want to zero-pad the days and months */
 
	snprintf(day,   lengthof(day),   "%02i", ymd.day);
 
	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)
 
{
 
	/* We are going to make number absolute for printing, so
 
	 * keep this piece of data as we need it later on */
 
@@ -711,13 +711,18 @@ static char *FormatString(char *buff, co
 
				str = ParseStringChoice(str, gender, buff, &len);
 
				buff += len;
 
				break;
 
			}
 

	
 
			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;
 
			}
 

	
 
			case SCC_CARGO: { // {CARGO}
 
				/* Layout now is:
 
				 *   8bit   - cargo type
src/table/control_codes.h
Show inline comments
 
@@ -50,12 +50,13 @@ enum StringControlCode {
 
	SCC_FORCE,
 
	SCC_VELOCITY,
 

	
 
	SCC_DATE_TINY,
 
	SCC_DATE_SHORT,
 
	SCC_DATE_LONG,
 
	SCC_DATE_ISO,
 

	
 
	SCC_STRING1,
 
	SCC_STRING2,
 
	SCC_STRING3,
 
	SCC_STRING4,
 
	SCC_STRING5,
0 comments (0 inline, 0 general)