Problems with the date of modification of files on the flash drive inwindows

Discussion in 'Python' started by Aleksey, Jan 23, 2010.

  1. Aleksey

    Aleksey Guest

    Hi All,

    I write crossplatform program and have next problem under windows
    (under linux is all OK) :

    I'm trying to get the UTC modification date of files on the flash
    drive under windows. In the flash card system is FAT. In the winter
    time (2010 01 21) Date of modification:


    >>> op.getmtime('g:\\alex\\bag\\pybag.log')

    1263998652.0


    In the summer time (2010 07 21) Date of the modification on the hour
    (3600 sec) different from winter time:


    >>> op.getmtime('g:\\alex\\bag\\pybag.log')

    1263995052.0


    Also time zone is "GMT" but real is "OMST" and localtime is wrong. In
    windows "tm_isdst" is always "0".

    For files on the HDD with NTFS modification time is right.

    How I can get right GMT time for files in flash with FAT under
    windows?


    Winter for Windows
    ----------------------

    >>> time.altzone

    -3600
    >>> time.daylight

    0
    >>> time.localtime()

    time.struct_time(tm_year=2010, tm_mon=1, tm_mday=21, tm_hour=3,
    tm_min=32, tm_sec=42, tm_wday=3,
    tm_yday=21, tm_isdst=0)
    >>> time.gmtime()

    time.struct_time(tm_year=2010, tm_mon=1, tm_mday=21, tm_hour=3,
    tm_min=32, tm_sec=48, tm_wday=3,
    tm_yday=21, tm_isdst=0)
    >>> time.tzname

    ('GMT', '')
    >>> time.timezone

    0

    Summer for Windows
    -----------------------------

    >>> time.altzone

    -3600
    >>> time.daylight

    0
    >>> time.localtime()

    time.struct_time(tm_year=2010, tm_mon=7, tm_mday=21, tm_hour=2,
    tm_min=13, tm_sec=18, tm_wday=2,
    tm_yday=202, tm_isdst=0)
    >>> time.gmtime()

    time.struct_time(tm_year=2010, tm_mon=7, tm_mday=21, tm_hour=2,
    tm_min=13, tm_sec=26, tm_wday=2,
    tm_yday=202, tm_isdst=0)
    >>> time.tzname

    ('GMT', '')
    >>> time.timezone

    0


    From Linux for summer:
    ---------------------------------

    >>> time.altzone

    -25200
    >>> time.daylight

    1
    >>> time.localtime()

    time.struct_time(tm_year=2010, tm_mon=7, tm_mday=23, tm_hour=12,
    tm_min=7, tm_sec=24, tm_wday=4,
    tm_yday=204, tm_isdst=1)
    >>> time.gmtime()

    time.struct_time(tm_year=2010, tm_mon=7, tm_mday=23, tm_hour=5,
    tm_min=7, tm_sec=36, tm_wday=4,
    tm_yday=204, tm_isdst=0)
    >>> time.timezone

    -21600
    >>> time.tzname

    ('OMST', 'OMSST')


    From Linux for winter:
    ------------------------------------

    >>> time.altzone

    -25200
    >>> time.daylight

    1
    >>> time.localtime()

    time.struct_time(tm_year=2010, tm_mon=1, tm_mday=23, tm_hour=11,
    tm_min=8, tm_sec=26, tm_wday=5,
    tm_yday=23, tm_isdst=0)
    >>> time.gmtime()

    time.struct_time(tm_year=2010, tm_mon=1, tm_mday=23, tm_hour=5,
    tm_min=8, tm_sec=39, tm_wday=5,
    tm_yday=23, tm_isdst=0)
    >>> time.timezone

    -21600
    >>> time.tzname

    ('OMST', 'OMSST')
     
    Aleksey, Jan 23, 2010
    #1
    1. Advertisements

  2. Aleksey

    Nobody Guest

    Re: Problems with the date of modification of files on the flash drive in windows

    On Fri, 22 Jan 2010 21:23:37 -0800, Aleksey wrote:

    > I write crossplatform program and have next problem under windows
    > (under linux is all OK) :
    >
    > I'm trying to get the UTC modification date of files on the flash
    > drive under windows. In the flash card system is FAT.


    Timestamps stored on a FAT filesystem use an unspecified timezone. When a
    Windows PC writes a timestamp to a FAT filesystem, it stores the current
    local time. For devices such as cameras, the timestamp will be whatever's
    in the device's clock if it has one (even if it does, there's no
    guarantee that it's accurate), or some arbitrary value otherwise.

    When reading a timestamp, it's just used as-is, i.e. it's a local time
    with no timezone specified. There is no way to convert this value to UTC
    or to a specific timezone.

    If you're using FAT, timestamps are pretty much meaningless unless the
    device never travels between timezones (in which case, they'll probably
    be roughly correct or wrong by roughly an hour either way due to DST).

    When it comes to timezones, anything developed prior to NT
    basically pretends that they don't exist.
     
    Nobody, Jan 23, 2010
    #2
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.

Share This Page