Changes between Version 1 and Version 4 of Ticket #134


Ignore:
Timestamp:
May 25, 2020, 7:54:31 PM (9 months ago)
Author:
schwa
Comment:

Reminder: If the user has write permissions for the current directory on the FTP server, they can call ftp_host.synchronize_times() to set the time shift automatically.

If that's not possible or desired and the server reports timestamps in the same timezone as for the client, the time shift can be set with

ftp_host.set_time_shift(
  round( (datetime.datetime.now() - datetime.datetime.utcnow()).seconds, -2 )
)

I thought about different approaches to make it even easier for users, for example, supporting a class attribute like initial_time_shift ("utc", "same_timezone_as_client", float) or a similar argument for the constructor. However, all these approaches add very little to the obvious implementations a user would/could do.

If the default time shift should be set on the class level, use

class MyFTPHost(ftputil.FTPHost):

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        my_initial_time_shift = ...
        self.set_time_shift(my_initial_time_shift)

If the default time shift should be set on the instance instance level, use

with FTPHost(...) as host:
    my_initial_time_shift = ...
    host.set_time_shift(my_initial_time_shift)
    ...

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #134

    • Property Status changed from assigned to closed
    • Property Resolution changed from to fixed
  • Ticket #134 – Description

    v1 v4  
    11For a long time, ftputil has assumed that FTP servers present dates and times in directory listings in "their" timezone. I think this is a problem for several reasons:
    22
    3 - ftputil can't know which timezone the server is in. Even if the user specifies a time shift, it's a constant value and may not apply to dates/times in the past.
     3- ftputil can't know which timezone the server is in. Even if the user specifies a time shift, it's a constant value and may not apply to dates/times in the past or in the .
    44
    55- Having a server use UTC for its timestamps makes sense because using a timezone may lead to skipped or double hours for daylight saving time switches. So I think the assumption is justified anyway that most servers will use UTC.