Changeset 1579:7146d114d459


Ignore:
Timestamp:
Oct 4, 2014, 6:20:42 PM (7 years ago)
Author:
Stefan Schwarzer <sschwarzer@…>
Branch:
default
amend_source:
a997511a593078923a6fe11f9e69e273b11652c7
Message:
Use `UNKNOWN_PRECISION` for pre-epoch datetimes.
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • ftputil/stat.py

    r1576 r1579  
    1 # Copyright (C) 2002-2013, Stefan Schwarzer <sschwarzer@sschwarzer.net>
     1# Copyright (C) 2002-2014, Stefan Schwarzer <sschwarzer@sschwarzer.net>
    22# and ftputil contributors (see `doc/contributors.txt`)
    33# See the file LICENSE for licensing terms.
     
    273273                st_mtime = self._mktime( (year-1, month, day,
    274274                                          hour, minute, 0, 0, 0, -1) )
     275        # If we had a datetime before the epoch, the resulting value
     276        # 0.0 doesn't tell us anything about the precision.
     277        if st_mtime == 0.0:
     278            st_mtime_precision = UNKNOWN_PRECISION
     279        #
    275280        if with_precision:
    276281            return st_mtime, st_mtime_precision
     
    484489        stat_result._st_target = None
    485490        # mtime precision in seconds
    486         stat_result._st_mtime_precision = MINUTE_PRECISION
     491        #  If we had a datetime before the epoch, the resulting value
     492        #  0.0 doesn't tell us anything about the precision.
     493        if st_mtime == 0.0:
     494            stat_result._st_mtime_precision = UNKNOWN_PRECISION
     495        else:
     496            stat_result._st_mtime_precision = MINUTE_PRECISION
    487497        return stat_result
    488498
  • test/test_stat.py

    r1578 r1579  
    1 # Copyright (C) 2003-2013, Stefan Schwarzer <sschwarzer@sschwarzer.net>
     1# Copyright (C) 2003-2014, Stefan Schwarzer <sschwarzer@sschwarzer.net>
    22# and ftputil contributors (see `doc/contributors.txt`)
    33# See the file LICENSE for licensing terms.
     
    165165        expected_stat_result = \
    166166          [33188, None, None, 1, "45854", "200", 4604, None,
    167            EPOCH, None, DAY_PRECISION, "index.html", None]
     167           EPOCH, None, UNKNOWN_PRECISION, "index.html", None]
    168168        # Make shallow copies to avoid converting the time tuple more
    169169        # than once in _test_valid_lines`.
     
    253253           "SYNCSOURCE", None],
    254254          [16640, None, None, None, None, None, None, None,
    255            EPOCH, None, MINUTE_PRECISION,
     255           EPOCH, None, UNKNOWN_PRECISION,
    256256           "SYNC", None],
    257257        ]
Note: See TracChangeset for help on using the changeset viewer.