reduced dates #7
PopIt uses MongoDB's native Date objects, so it cannot use ISO 8601:2004 reduced dates.
The text was updated successfully, but these errors were encountered:
The approach in PopIt is (was :) ) to treat all dates as a range. This works well in that it can represent a specific date like 2 Mar 2012 (by using a range from midnight to the following midnight). It can also represent arbitrary ranges like 1 Jan 2012 to 30 April 2012.
However it has the following problems:
But the following advantages:
With respect to the advantages:
It has not, but it is realistic to expect that it will. Without this it won't be possible to represent "Q2 2012" or "late 2012" more accurately than just "2012". It would also not be possible to represent a particular week of the year if that week spanned two months. And using the ISO 8601 format of
For the Kenyan elections we would have been able to give a very specific range that the election should have occurred in according to the legislation.
Ascending sorts tend to be fine, the problem is that when you do descending sorts with partial dates the expected result is not just the reverse of the ascending. Take these dates as an example:
This sorting order could be contentious, but it is what we found to be the expected order when displaying the dates to the user. Having each partial date contain a definite high and low date for the range made sorting easier. Notably the Extended Date/Time Format (EDTF) 1.0 spec dodges the question completely.
That is a little messy, but using 'future' to distinguish between not known and not happened yet was useful. It is not deal though - if
Update: Just for clarity:
Default reverse sort order on strings:
Desired reverse sort order on string:
i.e. sort by precision in normal order, then reverse sort by string all the strings with the same precision
Regarding descending order of date strings.
This is acually not true. If 2000 is added to the values above it's not sorted last where it should be but right after 2001.
A working SQL solution for descending order is
Furthermore, I suggest to use * and | as internal values for past and future, respectivelly. They are sorted correctly (* < any date < |) both for ascending and descending order and remind asterisk and dagger commonly used for birth date and death date.