Daylight savings and getmtime
chris.cavalaria at free.fr
Fri Jan 28 18:19:18 EST 2005
> I'we written a simple web deployment program which scans for the
> changes made to local copy of web site. Changed files are than
> packaged into a zip file and deployed to web server.
> Now here's the catch. Changes are computed using (1) log file from the
> last deployment and (2) local file system. Log file contains
> datestamps (integers) returned from os.path.getmtime(f) function at
> the time of last deployment. So i'm comparing two getmtime() values.
> The problem is when Daylight saving kicks in: suddenly all local files
> are reported as older than they were at the time of deployment.
> How do I compensate for this?
Never use the local time, always use GMT ( UTC ) time instead.
Since it seems os.path.getmtime already gives UTC time, onemust wonder if
your OS isn't broken in some way ;) If you can't solve that problem, then
use a simple md5sum of the files instead. md5sum isn't that slow to compute
and it gives better results than timestanps.
Or use a specialised tool like rsync which does a very good job for that.
More information about the Python-list