ISO8601: Implemented ::dayNameShort and ::monthNameShort

- Added tests.
This commit is contained in:
Paul Beckingham 2015-11-01 18:01:24 -05:00
parent 9143d8b8e7
commit 7a48d25eaa
3 changed files with 80 additions and 13 deletions

View file

@ -1264,6 +1264,31 @@ std::string ISO8601d::monthName (int month)
return Lexer::ucFirst (months[month - 1]);
}
////////////////////////////////////////////////////////////////////////////////
// Static
std::string ISO8601d::monthNameShort (int month)
{
static const char* months[12] =
{
STRING_DATE_JANUARY,
STRING_DATE_FEBRUARY,
STRING_DATE_MARCH,
STRING_DATE_APRIL,
STRING_DATE_MAY,
STRING_DATE_JUNE,
STRING_DATE_JULY,
STRING_DATE_AUGUST,
STRING_DATE_SEPTEMBER,
STRING_DATE_OCTOBER,
STRING_DATE_NOVEMBER,
STRING_DATE_DECEMBER,
};
assert (month > 0);
assert (month <= 12);
return Lexer::ucFirst (months[month - 1]).substr (0, 3);
}
////////////////////////////////////////////////////////////////////////////////
// Static
std::string ISO8601d::dayName (int dow)
@ -1282,6 +1307,24 @@ std::string ISO8601d::dayName (int dow)
return Lexer::ucFirst (days[dow]);
}
////////////////////////////////////////////////////////////////////////////////
// Static
std::string ISO8601d::dayNameShort (int dow)
{
static const char* days[7] =
{
STRING_DATE_SUNDAY,
STRING_DATE_MONDAY,
STRING_DATE_TUESDAY,
STRING_DATE_WEDNESDAY,
STRING_DATE_THURSDAY,
STRING_DATE_FRIDAY,
STRING_DATE_SATURDAY,
};
return Lexer::ucFirst (days[dow]).substr (0, 3);
}
////////////////////////////////////////////////////////////////////////////////
// Static
int ISO8601d::dayOfWeek (const std::string& input)

View file

@ -67,7 +67,9 @@ public:
static int daysInMonth (int, int);
static int daysInYear (int);
static std::string monthName (int);
static std::string monthNameShort (int);
static std::string dayName (int);
static std::string dayNameShort (int);
static int dayOfWeek (const std::string&);
static int dayOfWeek (int, int, int);
static int monthOfYear (const std::string&);