Changeset 851:b98050aeebf9


Ignore:
Timestamp:
05/21/17 07:42:00 (7 years ago)
Author:
István Váradi <ivaradi@…>
Branch:
default
Phase:
public
Message:

The time editor can return a timestamp.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/mlx/gui/common.py

    r850 r851  
    99import os
    1010import time
     11import calendar
    1112
    1213#-----------------------------------------------------------------------------
     
    338339        tm = time.gmtime(timestamp)
    339340        self.set_text("%02d:%02d" % (tm.tm_hour, tm.tm_min))
     341
     342    def getTimestampFrom(self, timestamp):
     343        """Get the timestamp by replacing the hour and minute from the given
     344        timestamp with what is set in this widget."""
     345        tm = time.gmtime(timestamp)
     346        ts = calendar.timegm((tm.tm_year, tm.tm_mon, tm.tm_mday,
     347                              self.hour, self.minute, 0,
     348                              tm.tm_wday, tm.tm_yday, tm.tm_isdst))
     349
     350        if ts > (timestamp + (16*60*60)):
     351            ts -= 24*60*60
     352        elif (ts + 16*60*60) < timestamp:
     353            ts += 24*60*60
     354
     355        return ts
    340356
    341357    def _focusOutEvent(self, widget, event):
Note: See TracChangeset for help on using the changeset viewer.