Issue #61 new

test_distance_of_time_in_words fails before a leap year

Andrey Rahmatullin
created an issue

self.assertEqual("1 year", distance_of_time_in_words(0, 31536000)) fails now with "AssertionError: '1 year' != '11 months and 30 days'" because 31536000 is 365 days, and one full year from now is 366 days.

Comments (6)

  1. Mike Orr

    Fixed in 68639fc711eb. The test tests the interval between "now" and "a year from now". This fails if this year or next year is a leap year. Adjusted the test to first try it as a non-leap year, then if that fails to try it again as a leap year.

  2. David Malcolm

    Debian's bug tracker entry for this notes that distance_of_time_in_words returns different values depending on the current time (and timezone):

    $ export TZ=Europe/Warsaw
    $ for d in 01-01 03-01 03-02 03-27 04-02 10-30; do faketime "2011-$d UTC" python -c 'import as d; print d.distance_of_time_in_words(0, 31536000)'; done
    1 year
    11 months and 28 days
    11 months and 30 days
    11 months, 30 days and 1 hour
    11 months and 29 days
    11 months, 29 days and 23 hours

    FWIW, I'm also tracking this downstream for Fedora, as

  3. Log in to comment