Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Other Discussions
  3. The Weird and The Wonderful
  4. In the words of Sallah -- bad dates

In the words of Sallah -- bad dates

Scheduled Pinned Locked Moved The Weird and The Wonderful
csharpannouncement
6 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    PIEBALDconsult
    wrote on last edited by
    #1

    Some date routines I found swept under the rug. How they got into the code-base I don't know, but there was only one C# developer on the project when I joined, so I waited until he left.

    // Return a string to display a DateTime object
    // as DTZ: YYYYMMDDTHHMMSSZ = 20110101T070000Z
    public static string GetDTZ(DateTime inDT)
    {
    string rString = "";

    rString += inDT.Year;
    rString += FixDigits(inDT.Month, 2);
    rString += FixDigits(inDT.Day, 2);
    rString += "T";
    rString += FixDigits(inDT.Hour, 2);
    rString += FixDigits(inDT.Minute, 2);
    rString += FixDigits(inDT.Second, 2);
    rString += "Z";

    return rString;
    }// end GetDTZ

    // Return the name of the month that corresponds to a digit 1-12
    public static string GetMonthName(int inMonth)
    {
    string[] months = { "", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" };
    return months[inMonth % 13];
    }// endGetMonthName

    // Return a text version of an integer from 1-99
    public static string GetDateName(int inNumber)
    {
    string[] nos = {"", "first", "second", "third", "fourth", "fifth", "sixth", "seventh", "eighth", "nineth",
    "tenth", "eleventh", "twelfth", "thirteeth", "fourteenth", "fifteenth", "sixteenth", "seventeenth", "eighteenth", "nineteenth",
    "twenty", "twenty first", "twenty second", "twenty third", "twenty fourth", "twenty fifth", "twenty sixth", "twenty seventh", "twenty eigth", "twenty ninth",
    "thirty", "thirty first", "thirty second", "thirty third", "thirty fourth", "thirty fifth", "thirty sixth", "thirty seventh", "thirty eigth", "thirty ninth",
    "forty", "forty first", "forty second", "forty third", "forty fourth", "forty fifth", "forty sixth", "forty seventh", "forty eigth", "forty ninth",
    "fi

    M B 2 Replies Last reply
    0
    • P PIEBALDconsult

      Some date routines I found swept under the rug. How they got into the code-base I don't know, but there was only one C# developer on the project when I joined, so I waited until he left.

      // Return a string to display a DateTime object
      // as DTZ: YYYYMMDDTHHMMSSZ = 20110101T070000Z
      public static string GetDTZ(DateTime inDT)
      {
      string rString = "";

      rString += inDT.Year;
      rString += FixDigits(inDT.Month, 2);
      rString += FixDigits(inDT.Day, 2);
      rString += "T";
      rString += FixDigits(inDT.Hour, 2);
      rString += FixDigits(inDT.Minute, 2);
      rString += FixDigits(inDT.Second, 2);
      rString += "Z";

      return rString;
      }// end GetDTZ

      // Return the name of the month that corresponds to a digit 1-12
      public static string GetMonthName(int inMonth)
      {
      string[] months = { "", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" };
      return months[inMonth % 13];
      }// endGetMonthName

      // Return a text version of an integer from 1-99
      public static string GetDateName(int inNumber)
      {
      string[] nos = {"", "first", "second", "third", "fourth", "fifth", "sixth", "seventh", "eighth", "nineth",
      "tenth", "eleventh", "twelfth", "thirteeth", "fourteenth", "fifteenth", "sixteenth", "seventeenth", "eighteenth", "nineteenth",
      "twenty", "twenty first", "twenty second", "twenty third", "twenty fourth", "twenty fifth", "twenty sixth", "twenty seventh", "twenty eigth", "twenty ninth",
      "thirty", "thirty first", "thirty second", "thirty third", "thirty fourth", "thirty fifth", "thirty sixth", "thirty seventh", "thirty eigth", "thirty ninth",
      "forty", "forty first", "forty second", "forty third", "forty fourth", "forty fifth", "forty sixth", "forty seventh", "forty eigth", "forty ninth",
      "fi

      M Offline
      M Offline
      Member 9986689 PandaLion98
      wrote on last edited by
      #2

      string[] days = {"", "1st", "2nd", "3rd", "4th", "5th", "6th", "7th", "8th", "9th", "10th", "11th", "12th", "13th", "14th", "15th", "16th",
      "17th", "18th", "19th", "20th", "21th", "22nd", "23rd", "24th", "25th", "26th", "27th", "28th", "29th", "30th", "31st", "32nd"};

      32nd day? But how? :confused:

      P Kornfeld Eliyahu PeterK L 3 Replies Last reply
      0
      • M Member 9986689 PandaLion98

        string[] days = {"", "1st", "2nd", "3rd", "4th", "5th", "6th", "7th", "8th", "9th", "10th", "11th", "12th", "13th", "14th", "15th", "16th",
        "17th", "18th", "19th", "20th", "21th", "22nd", "23rd", "24th", "25th", "26th", "27th", "28th", "29th", "30th", "31st", "32nd"};

        32nd day? But how? :confused:

        P Offline
        P Offline
        PIEBALDconsult
        wrote on last edited by
        #3

        How 'bout "21th" ?

        1 Reply Last reply
        0
        • M Member 9986689 PandaLion98

          string[] days = {"", "1st", "2nd", "3rd", "4th", "5th", "6th", "7th", "8th", "9th", "10th", "11th", "12th", "13th", "14th", "15th", "16th",
          "17th", "18th", "19th", "20th", "21th", "22nd", "23rd", "24th", "25th", "26th", "27th", "28th", "29th", "30th", "31st", "32nd"};

          32nd day? But how? :confused:

          Kornfeld Eliyahu PeterK Offline
          Kornfeld Eliyahu PeterK Offline
          Kornfeld Eliyahu Peter
          wrote on last edited by
          #4

          Room for future extensions...

          I'm not questioning your powers of observation; I'm merely remarking upon the paradox of asking a masked man who he is. (V) תפסיק לספר לה' כמה הצרות שלך גדולות, תספר לצרות שלך כמה ה' גדול!

          "It never ceases to amaze me that a spacecraft launched in 1977 can be fixed remotely from Earth." ― Brian Cox

          1 Reply Last reply
          0
          • P PIEBALDconsult

            Some date routines I found swept under the rug. How they got into the code-base I don't know, but there was only one C# developer on the project when I joined, so I waited until he left.

            // Return a string to display a DateTime object
            // as DTZ: YYYYMMDDTHHMMSSZ = 20110101T070000Z
            public static string GetDTZ(DateTime inDT)
            {
            string rString = "";

            rString += inDT.Year;
            rString += FixDigits(inDT.Month, 2);
            rString += FixDigits(inDT.Day, 2);
            rString += "T";
            rString += FixDigits(inDT.Hour, 2);
            rString += FixDigits(inDT.Minute, 2);
            rString += FixDigits(inDT.Second, 2);
            rString += "Z";

            return rString;
            }// end GetDTZ

            // Return the name of the month that corresponds to a digit 1-12
            public static string GetMonthName(int inMonth)
            {
            string[] months = { "", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" };
            return months[inMonth % 13];
            }// endGetMonthName

            // Return a text version of an integer from 1-99
            public static string GetDateName(int inNumber)
            {
            string[] nos = {"", "first", "second", "third", "fourth", "fifth", "sixth", "seventh", "eighth", "nineth",
            "tenth", "eleventh", "twelfth", "thirteeth", "fourteenth", "fifteenth", "sixteenth", "seventeenth", "eighteenth", "nineteenth",
            "twenty", "twenty first", "twenty second", "twenty third", "twenty fourth", "twenty fifth", "twenty sixth", "twenty seventh", "twenty eigth", "twenty ninth",
            "thirty", "thirty first", "thirty second", "thirty third", "thirty fourth", "thirty fifth", "thirty sixth", "thirty seventh", "thirty eigth", "thirty ninth",
            "forty", "forty first", "forty second", "forty third", "forty fourth", "forty fifth", "forty sixth", "forty seventh", "forty eigth", "forty ninth",
            "fi

            B Offline
            B Offline
            Brisingr Aerowing
            wrote on last edited by
            #5

            :doh: I will be blunt about this: that guy was an idiot.

            What do you get when you cross a joke with a rhetorical question? --- The metaphorical solid rear-end expulsions have impacted the metaphorical motorized bladed rotating air movement mechanism.

            1 Reply Last reply
            0
            • M Member 9986689 PandaLion98

              string[] days = {"", "1st", "2nd", "3rd", "4th", "5th", "6th", "7th", "8th", "9th", "10th", "11th", "12th", "13th", "14th", "15th", "16th",
              "17th", "18th", "19th", "20th", "21th", "22nd", "23rd", "24th", "25th", "26th", "27th", "28th", "29th", "30th", "31st", "32nd"};

              32nd day? But how? :confused:

              L Offline
              L Offline
              Lutoslaw
              wrote on last edited by
              #6

              Just in case...

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups