Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-43057

mongo shell ISODate() doesn't throw when months and/or days are out of range

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Open
    • Priority: Minor - P4
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: Backlog
    • Component/s: Shell
    • Labels:
      None

      Description

      Actually I'm not sure if that's really a bug, though it does look like one to me.

      In the mongo shell:

      > ISODate("19990000")

      returns ISODate("1998-11-30T00:00:00Z")

      That is, 1999-01-01 would be 1 January 1999, then 1999-00-00 is 1 January 1999 minus one month minus one day, so 30 November 1998

      > ISODate("12345678")

      returns ISODate("1238-10-17T00:00:00Z")

      Because by the same reasoning, 1234-56-78 is 1234-01-01 plus 55 months and 77 days, which is 17 October 1238.

      The #Wikipedia page on ISO 8601 states that months and days must be between 01 and 12 and between 01 and 31 respectively. I couldn't find a source that states otherwise. If that's true, then "19990000" and "12345678" are both invalid date strings; as such I would expect the ISODate() function to throw an error just like it does for other invalid inputs.

       

        Attachments

          Activity

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              7 Start watching this issue

              Dates

              • Created:
                Updated: