daily pastebin goal
28%
SHARE
TWEET

Untitled

a guest Dec 17th, 2018 78 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /++
  2.     Array of the long names of each month.
  3.   +/
  4. private immutable string[12] longMonthNames = [
  5.     "January",
  6.     "February",
  7.     "March",
  8.     "April",
  9.     "May",
  10.     "June",
  11.     "July",
  12.     "August",
  13.     "September",
  14.     "October",
  15.     "November",
  16.     "December"
  17. ];
  18.  
  19. /++
  20.     Array of the short (three letter) names of each month.
  21.   +/
  22. private immutable string[12] shortMonthNames = [
  23.     "Jan",
  24.     "Feb",
  25.     "Mar",
  26.     "Apr",
  27.     "May",
  28.     "Jun",
  29.     "Jul",
  30.     "Aug",
  31.     "Sep",
  32.     "Oct",
  33.     "Nov",
  34.     "Dec"
  35. ];
  36.  
  37. string monthToString(Month month, bool useLongName = true)
  38. {
  39.     if (month < Month.jan || month > Month.dec)
  40.     {
  41.         throw new DateTimeException("Invalid month: " ~ to!string(month));
  42.     }
  43.  
  44.     if(useLongName == true)
  45.     {
  46.         return longMonthNames[month - Month.jan];
  47.     }
  48.     else
  49.     {
  50.         return shortMonthNames[month - Month.jan];
  51.     }
  52. }
  53.  
  54. string evenSimplerString(DateTime dt)
  55. {
  56.     return xformat("%02d %s %04d", dt.day(), monthToString(dt.month(), true), dt.year());
  57. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top