Python time 模块,minute() 实例源码

我们从Python开源项目中,提取了以下50个代码示例,用于说明如何使用time.minute()

项目:piecewisecrf    作者:Vaan5    | 项目源码 | 文件源码
def get_expired_time(start_time):
    '''

    Returns expired time in HH:MM:SS format calculated relative to start_time

    Parameters
    ----------
    start_time : int
        Starting point in time


    '''
    curr_time = time.time()
    delta = curr_time - start_time
    hour = int(delta / 3600)
    delta -= hour * 3600
    minute = int(delta / 60)
    delta -= minute * 60
    seconds = delta
    return '%02d' % hour + ':%02d' % minute + ':%02d' % seconds
项目:dbf    作者:wenzhihong2003    | 项目源码 | 文件源码
def __new__(cls, year=None, month=0, day=0, hour=0, minute=0, second=0, microsecond=0):
        """year may be a datetime.datetime"""
        if year is None or year is Null:
            return cls._null_datetime
        ndt = object.__new__(cls)
        if isinstance(year, basestring):
            return DateTime.strptime(year)
        elif isinstance(year, DateTime):
            ndt._datetime = year._datetime
        elif isinstance(year, datetime.datetime):
            microsecond = year.microsecond // 1000 * 1000
            hour, minute, second = year.hour, year.minute, year.second
            year, month, day = year.year, year.month, year.day
            ndt._datetime = datetime.datetime(year, month, day, hour, minute, second, microsecond)
        elif year is not None:
            microsecond = microsecond // 1000 * 1000
            ndt._datetime = datetime.datetime(year, month, day, hour, minute, second, microsecond)
        return ndt
项目:dbf    作者:wenzhihong2003    | 项目源码 | 文件源码
def __new__(cls, hour=None, minute=0, second=0, microsecond=0):
        """
        hour may be a datetime.time or a str(Time)
        """
        if hour is None or hour is Null:
            return cls._null_time
        nt = object.__new__(cls)
        if isinstance(hour, basestring):
            hour = Time.strptime(hour)
        if isinstance(hour, Time):
            nt._time = hour._time
        elif isinstance(hour, (datetime.time)):
            microsecond = hour.microsecond // 1000 * 1000
            hour, minute, second = hour.hour, hour.minute, hour.second
            nt._time = datetime.time(hour, minute, second, microsecond)
        elif hour is not None:
            microsecond = microsecond // 1000 * 1000
            nt._time = datetime.time(hour, minute, second, microsecond)
        return nt
项目:dbf    作者:wenzhihong2003    | 项目源码 | 文件源码
def retrieve_vfp_datetime(bytes, fielddef, *ignore):
    """
    returns the date/time stored in bytes; dates <= 01/01/1981 00:00:00
    may not be accurate;  BC dates are nulled.
    """
    # two four-byte integers store the date and time.
    # millesecords are discarded from time
    if bytes == array('B', [0] * 8):
        cls = fielddef[EMPTY]
        if cls is NoneType:
            return None
        return cls()
    cls = fielddef[CLASS]
    time = unpack_long_int(bytes[4:])
    microseconds = (time % 1000) * 1000
    time = time // 1000                      # int(round(time, -3)) // 1000 discard milliseconds
    hours = time // 3600
    mins = time % 3600 // 60
    secs = time % 3600 % 60
    time = datetime.time(hours, mins, secs, microseconds)
    possible = unpack_long_int(bytes[:4])
    possible -= VFPTIME
    possible = max(0, possible)
    date = datetime.date.fromordinal(possible)
    return cls(date.year, date.month, date.day, time.hour, time.minute, time.second, time.microsecond)
项目:dbf    作者:wenzhihong2003    | 项目源码 | 文件源码
def update_vfp_datetime(moment, *ignore):
    """
    Sets the date/time stored in moment
    moment must have fields:
        year, month, day, hour, minute, second, microsecond
    """
    data = [0] * 8
    if moment:
        hour = moment.hour
        minute = moment.minute
        second = moment.second
        millisecond = moment.microsecond // 1000       # convert from millionths to thousandths
        time = ((hour * 3600) + (minute * 60) + second) * 1000 + millisecond
        data[4:] = update_integer(time)
        data[:4] = update_integer(moment.toordinal() + VFPTIME)
    return bytes(data)
项目:dbf    作者:wenzhihong2003    | 项目源码 | 文件源码
def __new__(cls, year=None, month=0, day=0, hour=0, minute=0, second=0, microsecond=0):
        """year may be a datetime.datetime"""
        if year is None or year is Null:
            return cls._null_datetime
        ndt = object.__new__(cls)
        if isinstance(year, basestring):
            return DateTime.strptime(year)
        elif isinstance(year, DateTime):
            ndt._datetime = year._datetime
        elif isinstance(year, datetime.datetime):
            microsecond = year.microsecond // 1000 * 1000
            hour, minute, second = year.hour, year.minute, year.second
            year, month, day = year.year, year.month, year.day
            ndt._datetime = datetime.datetime(year, month, day, hour, minute, second, microsecond)
        elif year is not None:
            microsecond = microsecond // 1000 * 1000
            ndt._datetime = datetime.datetime(year, month, day, hour, minute, second, microsecond)
        return ndt
项目:dbf    作者:wenzhihong2003    | 项目源码 | 文件源码
def retrieve_vfp_datetime(bytes, fielddef, *ignore):
    """
    returns the date/time stored in bytes; dates <= 01/01/1981 00:00:00
    may not be accurate;  BC dates are nulled.
    """
    # two four-byte integers store the date and time.
    # millesecords are discarded from time
    if bytes == array('B', [0] * 8):
        cls = fielddef[EMPTY]
        if cls is NoneType:
            return None
        return cls()
    cls = fielddef[CLASS]
    time = unpack_long_int(bytes[4:])
    microseconds = (time % 1000) * 1000
    time = time // 1000                      # int(round(time, -3)) // 1000 discard milliseconds
    hours = time // 3600
    mins = time % 3600 // 60
    secs = time % 3600 % 60
    time = datetime.time(hours, mins, secs, microseconds)
    possible = unpack_long_int(bytes[:4])
    possible -= VFPTIME
    possible = max(0, possible)
    date = datetime.date.fromordinal(possible)
    return cls(date.year, date.month, date.day, time.hour, time.minute, time.second, time.microsecond)
项目:dbf    作者:wenzhihong2003    | 项目源码 | 文件源码
def update_vfp_datetime(moment, *ignore):
    """
    Sets the date/time stored in moment
    moment must have fields:
        year, month, day, hour, minute, second, microsecond
    """
    data = [0] * 8
    if moment:
        hour = moment.hour
        minute = moment.minute
        second = moment.second
        millisecond = moment.microsecond // 1000       # convert from millionths to thousandths
        time = ((hour * 3600) + (minute * 60) + second) * 1000 + millisecond
        data[4:] = update_integer(time)
        data[:4] = update_integer(moment.toordinal() + VFPTIME)
    return bytes(data)
项目:dbf    作者:wenzhihong2003    | 项目源码 | 文件源码
def __new__(cls, year=None, month=0, day=0, hour=0, minute=0, second=0, microsecond=0):
        """year may be a datetime.datetime"""
        if year is None or year is Null:
            return cls._null_datetime
        ndt = object.__new__(cls)
        if isinstance(year, basestring):
            return DateTime.strptime(year)
        elif isinstance(year, (DateTime)):
            ndt._datetime = year._datetime
        elif isinstance(year, (datetime.datetime)):
            microsecond = year.microsecond // 1000 * 1000
            hour, minute, second = year.hour, year.minute, year.second
            year, month, day = year.year, year.month, year.day
            ndt._datetime = datetime.datetime(year, month, day, hour, minute, second, microsecond)
        elif year is not None:
            microsecond = microsecond // 1000 * 1000
            ndt._datetime = datetime.datetime(year, month, day, hour, minute, second, microsecond)
        return ndt
项目:dbf    作者:wenzhihong2003    | 项目源码 | 文件源码
def __new__(cls, hour=None, minute=0, second=0, microsecond=0):
        """
        hour may be a datetime.time or a str(Time)
        """
        if hour is None or hour is Null:
            return cls._null_time
        nt = object.__new__(cls)
        if isinstance(hour, basestring):
            hour = Time.strptime(hour)
        if isinstance(hour, (Time)):
            nt._time = hour._time
        elif isinstance(hour, (datetime.time)):
            microsecond = hour.microsecond // 1000 * 1000
            hour, minute, second = hour.hour, hour.minute, hour.second
            nt._time = datetime.time(hour, minute, second, microsecond)
        elif hour is not None:
            microsecond = microsecond // 1000 * 1000
            nt._time = datetime.time(hour, minute, second, microsecond)
        return nt
项目:dbf    作者:wenzhihong2003    | 项目源码 | 文件源码
def retrieve_vfp_datetime(bytes, fielddef, *ignore):
    """
    returns the date/time stored in bytes; dates <= 01/01/1981 00:00:00
    may not be accurate;  BC dates are nulled.
    """
    # two four-byte integers store the date and time.
    # millesecords are discarded from time
    if bytes == array('c', '\x00' * 8):
        cls = fielddef[EMPTY]
        if cls is NoneType:
            return None
        return cls()
    cls = fielddef[CLASS]
    time = unpack_long_int(bytes[4:])
    microseconds = (time % 1000) * 1000
    time = time // 1000                      # int(round(time, -3)) // 1000 discard milliseconds
    hours = time // 3600
    mins = time % 3600 // 60
    secs = time % 3600 % 60
    time = datetime.time(hours, mins, secs, microseconds)
    possible = unpack_long_int(bytes[:4])
    possible -= VFPTIME
    possible = max(0, possible)
    date = datetime.date.fromordinal(possible)
    return cls(date.year, date.month, date.day, time.hour, time.minute, time.second, time.microsecond)
项目:live_scoreboard    作者:ClysmiC    | 项目源码 | 文件源码
def __asyncRequestWeatherData(self):
        success = False

        self.lastRequestedWeatherQueryTime = time.time()

        while not success:
            if not self.__isAlive:
                return

            try:
                self.__weatherInfo = hourlyForecast(WEATHER_LOCATION[0], WEATHER_LOCATION[1], wundergroundApiKey)
                success = True
            except:
                success = False
                currTime = datetime.now()
                print("FAIL: Weather request at {:02d}:{:02d}:{:02d}".format(currTime.hour, currTime.minute, currTime.second))

        currTime = datetime.now()
        print("SUCCESS: Weather request at {:02d}:{:02d}:{:02d}".format(currTime.hour, currTime.minute, currTime.second))

        self.lastSuccessfulWeatherQueryTime = time.time()
        self.newWeatherDataAvailable = True
项目:live_scoreboard    作者:ClysmiC    | 项目源码 | 文件源码
def __asyncRequestDivisionData(self):        
        success = False

        self.lastRequestedDivisionQueryTime = time.time()

        while not success:
            if not self.__isAlive:
                return

            try:
                self.__divisionStandings = mlb.getDivisionStandings(DIVISION_OF_INTEREST)
                self.__wildcardStandings = mlb.getDivisionStandings(WILDCARD_DIVISION_OF_INTEREST)
                success = True
            except:
                currTime = datetime.now()
                print("FAIL: Standings request at {:02d}:{:02d}:{:02d}".format(currTime.hour, currTime.minute, currTime.second))
                success = False

        currTime = datetime.now()
        print("SUCCESS: Standings request at {:02d}:{:02d}:{:02d}".format(currTime.hour, currTime.minute, currTime.second))

        self.lastSuccessfulDivisionQueryTime = time.time()
        self.newDivisionDataAvailable = True
项目:jabbapylib3    作者:jabbalaci    | 项目源码 | 文件源码
def get_timestamp_from_year_to_second(separator=False, date=None):
    """A compact timestamp.

    Example: 20110523_234401 . date can be a datetime object.
    If date is not specified, the current date and time (now) will be used."""
    if date:
        now = date
    else:
        now = datetime.now()
    date = datetime.date(now)
    time = datetime.time(now)
    #return "%d-%02d-%02d @ %02dh%02d%02d" % (date.year, date.month, date.day, time.hour, time.minute, time.second)
    template = "{year}{month:02}{day:02}_{hour:02}{minute:02}{second:02}"
    if separator:
        template = "{year}_{month:02}_{day:02}_{hour:02}{minute:02}{second:02}"
    return template.format(year=date.year, month=date.month, day=date.day, hour=time.hour, minute=time.minute, second=time.second)
项目:piecewisecrf    作者:Vaan5    | 项目源码 | 文件源码
def get_time_string():
    '''

    Returns current time in day_month_HH-MM-SS/ format

    '''
    time = datetime.now()
    name = (str(time.day) + '_' + str(time.month) + '_%02d' % time.hour +
            '-%02d' % time.minute + '-%02d' % time.second + '/')
    return name
项目:piecewisecrf    作者:Vaan5    | 项目源码 | 文件源码
def get_time():
    '''

    Returns current time in HH:MM:SS format

    '''
    time = datetime.now()
    return '%02d' % time.hour + ':%02d' % time.minute + ':%02d' % time.second
项目:dbf    作者:wenzhihong2003    | 项目源码 | 文件源码
def combine(cls, date, time):
        if Date(date) and Time(time):
            return cls(date.year, date.month, date.day, time.hour, time.minute, time.second, time.microsecond)
        return cls()
项目:dbf    作者:wenzhihong2003    | 项目源码 | 文件源码
def time(self):
        if self:
            return Time(self.hour, self.minute, self.second, self.microsecond)
        return Time()
项目:dbf    作者:wenzhihong2003    | 项目源码 | 文件源码
def __add__(self, other):
        if self and isinstance(other, (datetime.timedelta)):
            t = self._time
            t = datetime.datetime(2012, 6, 27, t.hour, t.minute, t.second, t.microsecond)
            t += other
            return Time(t.hour, t.minute, t.second, t.microsecond)
        else:
            return NotImplemented
项目:dbf    作者:wenzhihong2003    | 项目源码 | 文件源码
def __repr__(self):
        if self:
            return "Time(%d, %d, %d, %d)" % (self.hour, self.minute, self.second, self.microsecond)
        else:
            return "Time()"
项目:dbf    作者:wenzhihong2003    | 项目源码 | 文件源码
def __sub__(self, other):
        if self and isinstance(other, (Time, datetime.time)):
            t = self._time
            t = datetime.datetime(2012, 6, 27, t.hour, t.minute, t.second, t.microsecond)
            o = datetime.datetime(2012, 6, 27, other.hour, other.minute, other.second, other.microsecond)
            return t - o
        elif self and isinstance(other, (datetime.timedelta)):
            t = self._time
            t = datetime.datetime(2012, 6, 27, t.hour, t.minute, t.second, t.microsecond)
            t -= other
            return Time(t.hour, t.minute, t.second, t.microsecond)
        else:
            return NotImplemented
项目:dbf    作者:wenzhihong2003    | 项目源码 | 文件源码
def replace(self, hour=None, minute=None, second=None, microsecond=None, delta_hour=0, delta_minute=0, delta_second=0):
        if not self:
            return self.__class__._null_time
        old_hour, old_minute, old_second, old_micro = self.hour, self.minute, self.second, self.microsecond
        hour = (hour or old_hour) + delta_hour
        minute = (minute or old_minute) + delta_minute
        second = (second or old_second) + delta_second
        microsecond = microsecond or old_micro
        while not (0 <= hour < 24) or not (0 <= minute < 60) or not (0 <= second < 60):
            while second < 0:
                minute -= 1
                second = 60 + second
            while second > 59:
                minute += 1
                second = second - 60
            while minute < 0:
                hour -= 1
                minute = 60 + minute
            while minute > 59:
                hour += 1
                minute = minute - 60
            while hour < 1:
                hour = 24 + hour
            while hour > 23:
                hour = hour - 24
        return Time(hour, minute, second, microsecond)
项目:dbf    作者:wenzhihong2003    | 项目源码 | 文件源码
def tofloat(self):
        "returns Time as a float"
        hour = self.hour
        minute = self.minute * (1.0 / 60)
        second = self.second * (1.0 / 3600)
        microsecond = self.microsecond * (1.0 / 3600000)
        return hour + minute + second + microsecond
项目:dbf    作者:wenzhihong2003    | 项目源码 | 文件源码
def __init__(self, year=None, month=None, day=None, hour=None, minute=None, second=None, microsecond=None):
        params = vars()
        self._mask = {}
        for attr in ('year', 'month', 'day', 'hour', 'minute', 'second', 'microsecond'):
            value = params[attr]
            if value is not None:
                self._mask[attr] = value
项目:dbf    作者:wenzhihong2003    | 项目源码 | 文件源码
def combine(cls, date, time):
        if Date(date) and Time(time):
            return cls(date.year, date.month, date.day, time.hour, time.minute, time.second, time.microsecond)
        return cls()
项目:dbf    作者:wenzhihong2003    | 项目源码 | 文件源码
def time(self):
        if self:
            return Time(self.hour, self.minute, self.second, self.microsecond)
        return Time()
项目:dbf    作者:wenzhihong2003    | 项目源码 | 文件源码
def __add__(self, other):
        if self and isinstance(other, (datetime.timedelta)):
            t = self._time
            t = datetime.datetime(2012, 6, 27, t.hour, t.minute, t.second, t.microsecond)
            t += other
            return Time(t.hour, t.minute, t.second, t.microsecond)
        else:
            return NotImplemented
项目:dbf    作者:wenzhihong2003    | 项目源码 | 文件源码
def __rsub__(self, other):
        if self and isinstance(other, (Time, datetime.time)):
            t = self._time
            t = datetime.datetime(2012, 6, 27, t.hour, t.minute, t.second, t.microsecond)
            other = datetime.datetime(2012, 6, 27, other.hour, other.minute, other.second, other.microsecond)
            other -= t
            return other
        else:
            return NotImplemented
项目:dbf    作者:wenzhihong2003    | 项目源码 | 文件源码
def __repr__(self):
        if self:
            return "Time(%d, %d, %d, %d)" % (self.hour, self.minute, self.second, self.microsecond)
        else:
            return "Time()"
项目:dbf    作者:wenzhihong2003    | 项目源码 | 文件源码
def __sub__(self, other):
        if self and isinstance(other, (Time, datetime.time)):
            t = self._time
            t = datetime.datetime(2012, 6, 27, t.hour, t.minute, t.second, t.microsecond)
            o = datetime.datetime(2012, 6, 27, other.hour, other.minute, other.second, other.microsecond)
            return t - o
        elif self and isinstance(other, (datetime.timedelta)):
            t = self._time
            t = datetime.datetime(2012, 6, 27, t.hour, t.minute, t.second, t.microsecond)
            t -= other
            return Time(t.hour, t.minute, t.second, t.microsecond)
        else:
            return NotImplemented
项目:dbf    作者:wenzhihong2003    | 项目源码 | 文件源码
def replace(self, hour=None, minute=None, second=None, microsecond=None, delta_hour=0, delta_minute=0, delta_second=0):
        if not self:
            return self.__class__._null_time
        old_hour, old_minute, old_second, old_micro = self.hour, self.minute, self.second, self.microsecond
        hour = (hour or old_hour) + delta_hour
        minute = (minute or old_minute) + delta_minute
        second = (second or old_second) + delta_second
        microsecond = microsecond or old_micro
        while not (0 <= hour < 24) or not (0 <= minute < 60) or not (0 <= second < 60):
            while second < 0:
                minute -= 1
                second = 60 + second
            while second > 59:
                minute += 1
                second = second - 60
            while minute < 0:
                hour -= 1
                minute = 60 + minute
            while minute > 59:
                hour += 1
                minute = minute - 60
            while hour < 1:
                hour = 24 + hour
            while hour > 23:
                hour = hour - 24
        return Time(hour, minute, second, microsecond)
项目:dbf    作者:wenzhihong2003    | 项目源码 | 文件源码
def __init__(self, year=None, month=None, day=None, hour=None, minute=None, second=None, microsecond=None):
        params = vars()
        self._mask = {}
        for attr in ('year', 'month', 'day', 'hour', 'minute', 'second', 'microsecond'):
            value = params[attr]
            if value is not None:
                self._mask[attr] = value
项目:dbf    作者:wenzhihong2003    | 项目源码 | 文件源码
def __repr__(self):
        items = []
        for attr in ('year', 'month', 'day', 'hour', 'minute', 'second', 'microsecond'):
            if attr in self._mask:
                items.append('%s=%s' % (attr, self._mask[attr]))
        return "Period(%s)" % ', '.join(items)
项目:dbf    作者:wenzhihong2003    | 项目源码 | 文件源码
def time(self):
        if self:
            return Time(self.hour, self.minute, self.second, self.microsecond)
        return Time()
项目:dbf    作者:wenzhihong2003    | 项目源码 | 文件源码
def __add__(self, other):
        if self and isinstance(other, (datetime.timedelta)):
            t = self._time
            t = datetime.datetime(2012, 6, 27, t.hour, t.minute, t.second, t.microsecond)
            t += other
            return Time(t.hour, t.minute, t.second, t.microsecond)
        else:
            return NotImplemented
项目:dbf    作者:wenzhihong2003    | 项目源码 | 文件源码
def __rsub__(self, other):
        if self and isinstance(other, (Time, datetime.time)):
            t = self._time
            t = datetime.datetime(2012, 6, 27, t.hour, t.minute, t.second, t.microsecond)
            other = datetime.datetime(2012, 6, 27, other.hour, other.minute, other.second, other.microsecond)
            other -= t
            return other
        else:
            return NotImplemented
项目:dbf    作者:wenzhihong2003    | 项目源码 | 文件源码
def __repr__(self):
        if self:
            return "Time(%d, %d, %d, %d)" % (self.hour, self.minute, self.second, self.microsecond)
        else:
            return "Time()"
项目:dbf    作者:wenzhihong2003    | 项目源码 | 文件源码
def replace(self, hour=None, minute=None, second=None, microsecond=None, delta_hour=0, delta_minute=0, delta_second=0):
        if not self:
            return self.__class__._null_time
        old_hour, old_minute, old_second, old_micro = self.hour, self.minute, self.second, self.microsecond
        hour = (hour or old_hour) + delta_hour
        minute = (minute or old_minute) + delta_minute
        second = (second or old_second) + delta_second
        microsecond = microsecond or old_micro
        while not (0 <= hour < 24) or not (0 <= minute < 60) or not (0 <= second < 60):
            while second < 0:
                minute -= 1
                second = 60 + second
            while second > 59:
                minute += 1
                second = second - 60
            while minute < 0:
                hour -= 1
                minute = 60 + minute
            while minute > 59:
                hour += 1
                minute = minute - 60
            while hour < 1:
                hour = 24 + hour
            while hour > 23:
                hour = hour - 24
        return Time(hour, minute, second, microsecond)
项目:dbf    作者:wenzhihong2003    | 项目源码 | 文件源码
def tofloat(self):
        "returns Time as a float"
        hour = self.hour
        minute = self.minute * (1.0 / 60)
        second = self.second * (1.0 / 3600)
        microsecond = self.microsecond * (1.0 / 3600000)
        return hour + minute + second + microsecond
项目:dbf    作者:wenzhihong2003    | 项目源码 | 文件源码
def __init__(self, year=None, month=None, day=None, hour=None, minute=None, second=None, microsecond=None):
        params = vars()
        self._mask = {}
        for attr in ('year', 'month', 'day', 'hour', 'minute', 'second', 'microsecond'):
            value = params[attr]
            if value is not None:
                self._mask[attr] = value
项目:dbf    作者:wenzhihong2003    | 项目源码 | 文件源码
def __repr__(self):
        items = []
        for attr in ('year', 'month', 'day', 'hour', 'minute', 'second', 'microsecond'):
            if attr in self._mask:
                items.append('%s=%s' % (attr, self._mask[attr]))
        return "Period(%s)" % ', '.join(items)
项目:live_scoreboard    作者:ClysmiC    | 项目源码 | 文件源码
def update(self):
        self.canvas.delete("updates")

        string1 = daysOfWeek[self.dateAndTime.weekday()] + ", " + months[self.dateAndTime.month] + " " + str(self.dateAndTime.day)

        if TWENTY_FOUR_HOUR_CLOCK:
            string2 = "{:02d}:{:02d}:{:02d}".format(self.dateAndTime.hour, self.dateAndTime.minute, self.dateAndTime.second)
        else:
            hour, suffix = toTwelveHourClock(self.dateAndTime)
            string2 = "{:02d}:{:02d}:{:02d} {:s}".format(hour, self.dateAndTime.minute, self.dateAndTime.second, suffix)

        self.canvas.create_text((self.width // 2, self.height * .30), text=string1, fill=fontColor, font=self.font, tags="updates")
        self.canvas.create_text((self.width // 2, self.height * .70), text=string2, fill=fontColor, font=self.font, tags="updates")
项目:live_scoreboard    作者:ClysmiC    | 项目源码 | 文件源码
def update(self):
        self.canvas.delete("updates")
        self.show()

        if self.game["status"] == "Pre":
            topString = "{:3s} @ {:3s}".format(self.game["away"]["name"], self.game["home"]["name"])

            ast = self.game["adjustedStartTime"]


            if TWENTY_FOUR_HOUR_CLOCK:
                botString = "{:s} {:d}, {:02d}:{:02d}".format(months[ast.month], ast.day, ast.hour, ast.minute)
            else:
                hour, suffix = toTwelveHourClock(ast)
                botString = "{:s} {:d}, {:02d}:{:02d} {:s}".format(months[ast.month], ast.day, hour, ast.minute, suffix)


            awayLogo = self.scaledLogos[self.game["away"]["name"]]
            homeLogo = self.scaledLogos[self.game["home"]["name"]]

            # Center logo
            awayLogoXOffset = (self.awayLogoRegion.width - awayLogo.width()) // 2
            awayLogoYOffset = (self.awayLogoRegion.height - awayLogo.height()) // 2

            homeLogoXOffset = (self.homeLogoRegion.width - homeLogo.width()) // 2
            homeLogoYOffset = (self.homeLogoRegion.height - homeLogo.height()) // 2

            lineY = self.lineYStart

            self.canvas.create_image((self.awayLogoRegion.left + awayLogoXOffset, self.awayLogoRegion.top + awayLogoYOffset), anchor=tk.NW, image=awayLogo, tags="updates")
            self.canvas.create_image((self.homeLogoRegion.left + homeLogoXOffset, self.homeLogoRegion.top + homeLogoYOffset), anchor=tk.NW, image=homeLogo, tags="updates")

            self.canvas.create_text((self.topX, lineY), anchor=tk.NW, text=topString, font=self.font, fill=fontColor, tags="updates")

            lineY += self.lineHeight

            self.canvas.create_text((self.botX, lineY), anchor=tk.NW, text=botString, font=self.font, fill=fontColor, tags="updates")
        else:
            self.canvas.create_text((self.width // 2, self.height //2), anchor=tk.CENTER, text="No games found...", font=self.font, fill=fontColor, tags="updates")
项目:Deploy_XXNET_Server    作者:jzp820927    | 项目源码 | 文件源码
def combine(self, date, time):
        return datetime(date.year, date.month, date.day, time.hour, time.minute, time.microsecond, time.tzinfo)
项目:Deploy_XXNET_Server    作者:jzp820927    | 项目源码 | 文件源码
def new_datetime(d):
    """
    Generate a safe datetime from a datetime.date or datetime.datetime object.
    """
    kw = [d.year, d.month, d.day]
    if isinstance(d, real_datetime):
        kw.extend([d.hour, d.minute, d.second, d.microsecond, d.tzinfo])
    return datetime(*kw)

# This library does not support strftime's "%s" or "%y" format strings.
# Allowed if there's an even number of "%"s because they are escaped.
项目:jabbapylib3    作者:jabbalaci    | 项目源码 | 文件源码
def get_time():
    """
    Current time (HHMM).

    The return value is a string.
    """
    now = datetime.now()
    time = datetime.time(now)
    return "{hour:02}{minute:02}".format(hour=time.hour, minute=time.minute)
项目:rarebot    作者:RaRe-Technologies    | 项目源码 | 文件源码
def prepLine(lineDict, mappings):
    result = []
    if lineDict['category'] in mappings['category']:
        result.append(mappings['category'].index(lineDict['category']))
    else:
        result.append(-1)

    if lineDict['behaviour'] in mappings['behaviour']:
        result.append(mappings['behaviour'].index(lineDict['behaviour']))
    else:
        result.append(-1)

    if lineDict['connection'] in mappings['connection']:
        result.append(mappings['connection'].index(lineDict['connection']))
    else:
        result.append(-1)

    day = datetime.datetime.fromtimestamp(lineDict['unix_timestamp']).weekday()
    time = datetime.datetime.fromtimestamp(lineDict['unix_timestamp']).time()
    seconds = time.hour*3600 + time.minute*60 + time.second
    result.append(day)
    result.append(seconds)
    #result.append(time.hour)

    if lineDict['safe_connection'] in mappings['safe_connection']:
        result.append(mappings['safe_connection'].index(lineDict['safe_connection']))
    else:
        result.append(-1)
    return [result] # wrap result in a list to be directly usable in model.predict (todo: test if it is necessary)
项目:partytime    作者:sunlightlabs    | 项目源码 | 文件源码
def _date_time_to_datetime(date, time=None):
    if not time:
        time = datetime.time()
    return datetime.datetime(date.year, date.month, date.day, time.hour, time.minute, time.second)
项目:live_scoreboard    作者:ClysmiC    | 项目源码 | 文件源码
def update(self):
        self.canvas.delete("updates")

        self.textY = 0
        lastDateLabelDay = None
        firstHour = True

        for hour in self.weather:
            time = hour["time"]
            if time.day != lastDateLabelDay:
                dayString = months[time.month] + " " + str(time.day)

                # New lines
                if lastDateLabelDay is not None:
                    self.textY += self.lineHeight

                self.textY += self.lineHeight

                dayTextOffset = self.font.measure("  ")
                textPosition = (max(0, self.textX - dayTextOffset), self.textY)
                self.canvas.create_text(textPosition, anchor=tk.NW, text=dayString, font=self.underlinedFont, fill=fontColor, tags="updates")

                self.textY += self.lineHeight * 1.2 # just a little extra padding here looks better
                lastDateLabelDay = time.day

            if TWENTY_FOUR_HOUR_CLOCK:
                hourString = " {:02d}:{:02d}".format(time.hour, time.minute) + " - " + "{:>3s}".format(hour["temp"]) + " F "
            else:
                timeHour, suffix = toTwelveHourClock(time)
                hourString = " {:02d}:{:02d} {:s}".format(timeHour, time.minute, suffix) + " - " + "{:>3s}".format(hour["temp"]) + " F "

            hourFontColor = fontColor
            if firstHour:
                hourFontColor = "black"

                # draw a yellowish highlight on the current hour
                highlightColor = '#FFFF99'

                highlightX1 = self.textX
                highlightY1 = self.textY - ((self.lineHeight - self.fontHeight) / 2)
                highlightX2 = highlightX1 + self.font.measure(hourString)
                highlightY2 = highlightY1 + self.lineHeight

                self.canvas.create_rectangle((highlightX1, highlightY1, highlightX2, highlightY2), fill=highlightColor, tags="updates")

            self.canvas.create_text((self.textX, self.textY), anchor=tk.NW, text=hourString, font=self.font, fill=hourFontColor, tags="updates")


            icon = self.weatherIcons[hour["condition"]]
            self.canvas.create_image((self.iconX, self.textY), anchor=tk.NW, image=icon, tags="updates")

            self.textY += self.lineHeight
            firstHour = False
项目:CoPilot-InfotainmentSystem    作者:Joelzeller    | 项目源码 | 文件源码
def update(self, *args):
        time_hour = time.strftime("%I") #time_hour

        if time_hour[0] == "0": #one digit format
            time_hour = " "+time_hour[1]

        time_minute = time.strftime("%M") #time_minute

        global time_second_mod
        time_second_mod = int(float(time_second_mod))+1
        if time_second_mod > 10000000: #doesnt allow this var to get too big
            time_second_mod = 0

        time_now = time_hour+":"+time_minute #create sting format (hour:minute)

        if clock == 1: #default - on main screens - top center
            self.font_size = 40 #50 for center
            self.pos = (345, 216) #0, 200 for center
            self.text = time_now

        if clock == 0: #shows nothing
            self.font_size = 60
            self.pos = (0,190)
            self.text = " "

        if clock == 2: #top left - larger - for info clock
            self.font_size = 140
            self.text = time_now
            self.pos = (-200,150)

        if clock == 3: #center - for worm clock
            self.font_size = 60
            self.pos = (0,36)
            self.text = time_now

        if clock == 4: #top right - for menu screens
            self.font_size = 40 #40
            self.pos = (345, 216) #212
            self.text = time_now


        #VARIABLE PRINTER
            #to use - comment out the normal clock == 1 if, and choose a type of var and uncomment

        #if clock == 1:
            #self.font_size = 30
            #self.pos = (0,190)
            #self.text = "%d" %time.hour #+ "%d" %WINDOWSDOWNON #for numbers
            #self.text = str(SettingsScreen.buttons.analogclockswitch.active) #for strings