MCPcopy Create free account
hub / github.com/OpenApoc/OpenApoc / getShortDateString

Method getShortDateString

game/state/gametime.cpp:97–122  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

95}
96
97UString GameTime::getShortDateString() const
98{
99 std::stringstream ss;
100 if (DATE_SHORT_FORMAT == nullptr)
101 {
102 apoc_date_facet *dateFacet = new apoc_date_facet("%E %B, %Y");
103 DATE_SHORT_FORMAT = new std::locale(std::locale::classic(), dateFacet);
104
105 std::vector<std::string> months = {tr("January"), tr("February"), tr("March"),
106 tr("April"), tr("May"), tr("June"),
107 tr("July"), tr("August"), tr("September"),
108 tr("October"), tr("November"), tr("December")};
109 dateFacet->long_month_names(months);
110
111 std::vector<std::string> days = {
112 tr("1st"), tr("2nd"), tr("3rd"), tr("4th"), tr("5th"), tr("6th"), tr("7th"),
113 tr("8th"), tr("9th"), tr("10th"), tr("11th"), tr("12th"), tr("13th"), tr("14th"),
114 tr("15th"), tr("16th"), tr("17th"), tr("18th"), tr("19th"), tr("20th"), tr("21st"),
115 tr("22nd"), tr("23rd"), tr("24th"), tr("25th"), tr("26th"), tr("27th"), tr("28th"),
116 tr("29th"), tr("30th"), tr("31st")};
117 dateFacet->longDayNames(days);
118 }
119 ss.imbue(*DATE_SHORT_FORMAT);
120 ss << getPtime(this->ticks).date();
121 return ss.str();
122}
123
124UString GameTime::getWeekString() const { return format("%s %d", tr("Week"), getWeek()); }
125

Callers 1

createMessageRowMethod · 0.80

Calls 3

trFunction · 0.85
getPtimeFunction · 0.85
longDayNamesMethod · 0.80

Tested by

no test coverage detected