Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r83564 - trunk/tools/regression/xsl_reports
From: steven_at_[hidden]
Date: 2013-03-25 15:38:59


Author: steven_watanabe
Date: 2013-03-25 15:38:59 EDT (Mon, 25 Mar 2013)
New Revision: 83564
URL: http://svn.boost.org/trac/boost/changeset/83564

Log:
Stop treating UTC as local time.
Text files modified:
   trunk/tools/regression/xsl_reports/boost_wide_report.py | 26 ++++++++++++++++++++++----
   1 files changed, 22 insertions(+), 4 deletions(-)

Modified: trunk/tools/regression/xsl_reports/boost_wide_report.py
==============================================================================
--- trunk/tools/regression/xsl_reports/boost_wide_report.py (original)
+++ trunk/tools/regression/xsl_reports/boost_wide_report.py 2013-03-25 15:38:59 EDT (Mon, 25 Mar 2013)
@@ -50,11 +50,10 @@
 
 def get_date( words ):
     date = words[ 5: -1 ]
- t = time.localtime()
 
     month_names = [ "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" ]
 
- year = time.localtime()[0] # If year is not secified is it the current year
+ year = time.gmtime()[0] # If year is not secified is it the current year
     month = month_names.index( date[0] ) + 1
     day = int( date[1] )
     hours = 0
@@ -90,7 +89,7 @@
     result = []
     for file_path in glob.glob( os.path.join( dir, "*.zip" ) ):
         if os.path.isfile( file_path ):
- mod_time = time.localtime( os.path.getmtime( file_path ) )
+ mod_time = time.gmtime( os.path.getmtime( file_path ) )
             mod_time = ( mod_time[0], mod_time[1], mod_time[2], mod_time[3], mod_time[4], mod_time[5], 0, 0, mod_time[8] )
             # no size (for now)
             result.append( file_info( os.path.basename( file_path ), None, mod_time ) )
@@ -104,6 +103,25 @@
             return dd
     return None
 
+# Proof:
+# gmtime(result) = time_tuple
+# mktime(gmtime(result)) = mktime(time_tuple)
+# correction = mktime(gmtime(result)) - result
+# result = mktime(time_tuple) - correction
+def mkgmtime(time_tuple):
+ # treat the tuple as if it were local time
+ local = time.mktime(time_tuple)
+ # calculate the correction to get gmtime
+ old_correction = 0
+ correction = time.mktime(time.gmtime(local)) - local
+ result = local
+ # iterate until the correction doesn't change
+ while correction != old_correction:
+ old_correction = correction
+ correction = time.mktime(time.gmtime(result)) - result
+ result = local - correction
+ return result
+
 def diff( source_dir_content, destination_dir_content ):
     utils.log( "Finding updated files" )
     result = ( [], [] ) # ( changed_files, obsolete_files )
@@ -362,7 +380,7 @@
             f.retrbinary( 'RETR %s' % source, result.write )
             result.close()
             mod_date = find_by_name( source_content, source ).date
- m = time.mktime( mod_date )
+ m = mkgmtime( mod_date )
             os.utime( os.path.join( destination, source ), ( m, m ) )
 
         for obsolete in d[1]:


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk