Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /++
- Array of the long names of each month.
- +/
- private immutable string[12] longMonthNames = [
- "January",
- "February",
- "March",
- "April",
- "May",
- "June",
- "July",
- "August",
- "September",
- "October",
- "November",
- "December"
- ];
- /++
- Array of the short (three letter) names of each month.
- +/
- private immutable string[12] shortMonthNames = [
- "Jan",
- "Feb",
- "Mar",
- "Apr",
- "May",
- "Jun",
- "Jul",
- "Aug",
- "Sep",
- "Oct",
- "Nov",
- "Dec"
- ];
- string monthToString(Month month, bool useLongName = true)
- {
- if (month < Month.jan || month > Month.dec)
- {
- throw new DateTimeException("Invalid month: " ~ to!string(month));
- }
- if(useLongName == true)
- {
- return longMonthNames[month - Month.jan];
- }
- else
- {
- return shortMonthNames[month - Month.jan];
- }
- }
- string evenSimplerString(DateTime dt)
- {
- return xformat("%02d %s %04d", dt.day(), monthToString(dt.month(), true), dt.year());
- }
Add Comment
Please, Sign In to add comment