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

    • Type: Icon: Bug Bug
    • Resolution: Won't Fix
    • Priority: Icon: Minor - P4 Minor - P4
    • None
    • Affects Version/s: None
    • Component/s: Shell
    • Labels:
    • Server Tooling & Methods
    • ALL

      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.

       

            Assignee:
            backlog-server-stm Backlog - Server Tooling and Methods (STM) (Inactive)
            Reporter:
            ab@3tsoftwarelabs.com Andreu B
            Votes:
            0 Vote for this issue
            Watchers:
            8 Start watching this issue

              Created:
              Updated:
              Resolved: