Changeset 9afeb6 in indico


Ignore:
Timestamp:
03/24/11 17:35:04 (2 years ago)
Author:
Pedro Ferreira <jose.pedro.ferreira@…>
Branches:
master, burotel, hello-world-walkthrough, ipv6, v0.98-series, v0.98.2, v0.98.3, v0.98b1, v0.98b2, v0.99, 051b2622c51afb171a1dedb46a0df4fbb0cbd02e, 0da0c1403bae8e51d8229f460181c71b9e6dda72
Children:
bd2819
Parents:
d3adf1
Message:

[IMP] UTC vs local timestamp issue

  • Made it clear that we have been doing it wrong;
  • Changed livesync interface so that it shows the right date/time;
Location:
indico
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • indico/ext/livesync/chrome.py

    r2a802b r9afeb6  
    173173 
    174174    def _tsToDate(self, ts, granularity): 
    175         return datetime.datetime.utcfromtimestamp(ts * granularity) 
     175        return datetime.datetime.fromtimestamp(ts * granularity) 
    176176 
    177177    def _calculateTrackData(self, smanager): 
  • indico/util/date_time.py

    rdfc79a r9afeb6  
    1919## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. 
    2020 
    21 import time, pytz 
     21import time, pytz, calendar 
    2222 
    2323from MaKaC.common.timezoneUtils import nowutc 
    2424 
     25 
     26def utc_timestamp(datetimeVal): 
     27    return int(calendar.timegm(datetimeVal.utctimetuple())) 
     28 
     29 
     30## ATTENTION: Do not use this one for new developments ## 
     31# It is flawed, as even though the returned value is DST-safe, 
     32# it is in the _local timezone_, meaning that the number of seconds 
     33# returned is the one for the hour with the same "value" for the 
     34# local timezone. 
     35 
    2536def int_timestamp(datetimeVal, tz = pytz.timezone('UTC')): 
     37    """ 
     38    Returns the number of seconds from the local epoch to the UTC time 
     39    """ 
    2640    return int(time.mktime(datetimeVal.astimezone(tz).timetuple())) 
     41 
     42## 
Note: See TracChangeset for help on using the changeset viewer.