1
Vote

Recent Olson Data Changes Crash Public Domain

description

The 2009h update has the following change...
OLD: Rule\tJordan\t2002\tmax\t-\tMar\tlastFri\t0:00s\t1:00\tS
NEW: Rule\tJordan\t2002\tmax\t-\tMar\tlastThu\t24:00\t1:00\tS
 
The ParseTimeSpan function in DateTimeUtilities.cs chokes on this because TimeSpan.Parse can't handle "24:00".

comments

bbell2000 wrote Mar 19, 2011 at 3:12 PM

There are two ways to get around this issue. The first way is to edit tzdata\asia to apply year-specific rules for the years in which Apr 1 occurs on a Friday. This is the same approach used in tzdata\northamerica to get around the same issue in the Mont rules for 1927-1937.
# The 2006-to-max rules can be expressed more simply as
# Rule  Jordan  2002    max -   Mar lastThu 24:00   1:00    S
# The rules below avoid use of 24:00 through 2051
# (which TimeZone.Parse cant handle).
Rule    Jordan  2002    2004    -   Mar lastFri 0:00    1:00    S
Rule    Jordan  2003    only    -   Oct 24  0:00s   0   -
Rule    Jordan  2004    only    -   Oct 15  0:00s   0   -
Rule    Jordan  2005    only    -   Apr 1   0:00    1:00    S
Rule    Jordan  2005    only    -   Sep lastFri 0:00s   0   -
Rule    Jordan  2006    2010    -   Mar lastFri 0:00    1:00    S
Rule    Jordan  2006    max -   Oct lastFri 0:00s   0   -
Rule    Jordan  2011    only    -   Apr 1   0:00    1:00    S
Rule    Jordan  2012    2015    -   Mar lastFri 0:00    1:00    S
Rule    Jordan  2016    only    -   Apr 1   0:00    1:00    S
Rule    Jordan  2017    2021    -   Mar lastFri 0:00    1:00    S
Rule    Jordan  2022    only    -   Apr 1   0:00    1:00    S
Rule    Jordan  2023    2032    -   Mar lastFri 0:00    1:00    S
Rule    Jordan  2033    only    -   Apr 1   0:00    1:00    S
Rule    Jordan  2034    2038    -   Mar lastFri 0:00    1:00    S
Rule    Jordan  2039    only    -   Apr 1   0:00    1:00    S
Rule    Jordan  2040    2043    -   Mar lastFri 0:00    1:00    S
Rule    Jordan  2044    only    -   Apr 1   0:00    1:00    S
Rule    Jordan  2045    2049    -   Mar lastFri 0:00    1:00    S
Rule    Jordan  2050    only    -   Apr 1   0:00    1:00    S
Rule    Jordan  2051    max -   Mar lastFri 0:00    1:00    S
The second way is to change DateTimeUtilities.cs:
public static bool TryParseTimeSpan(string timeSpan, TimeSpanAssumption noColonAssumption, out TimeSpan result)
{
    if (timeSpan != null && timeSpan[0] == '+')
    {
        timeSpan = timeSpan.Substring(1);
    }

    timeSpan = ParseTimeSpanAssumptions(timeSpan, noColonAssumption);

    if (!TimeSpan.TryParse(timeSpan, out result))
    {
        timeSpan = timeSpan.Replace("24:00", "1.00:00");
        return TimeSpan.TryParse(timeSpan, out result);
    }

    return true;
}

public static TimeSpan ParseTimeSpan(string timeSpan, TimeSpanAssumption noColonAssumption)
{
    if (timeSpan != null && timeSpan[0] == '+')
    {
        timeSpan = timeSpan.Substring(1);
    }

    timeSpan = ParseTimeSpanAssumptions(timeSpan, noColonAssumption);

    TimeSpan result;
    if (!TimeSpan.TryParse(timeSpan, out result))
    {
        timeSpan = timeSpan.Replace("24:00", "1.00:00");
        result = TimeSpan.Parse(timeSpan);
    }

    return result;
}
Either way, it's a hack. YMMV.

mlmanfredi wrote Mar 23, 2011 at 3:24 PM

Thanks for the suggestion. My current workaround for the problem is to alter the original value from 24:00 to 23:59:59. I don't think the one second is going to make any difference for me.

wrote Feb 14, 2013 at 1:55 AM