Пример #1
0
def FormatDateTime(value, **kwargs):
    formatStringList = []
    if kwargs.get('dateFormat', 'short') in ('full', 'long', 'medium', 'short'):
        formatStringList.append('%Y.%m.%d')
    timeFormat = kwargs.get('timeFormat', 'short')
    if timeFormat in ('full', 'long', 'medium'):
        formatStringList.append('%H:%M:%S')
    elif timeFormat == 'short':
        formatStringList.append('%H:%M')
    formatString = ' '.join(formatStringList)
    if isinstance(value, long):
        value = value + eveLocalization.GetTimeDelta() * const.SEC
        year, month, weekday, day, hour, minute, second, msec = blue.os.GetTimeParts(value)
        day_of_year = 1
        is_daylight_savings = -1
        value = (year,
         month,
         day,
         hour,
         minute,
         second,
         weekday,
         day_of_year,
         is_daylight_savings)
    elif isinstance(value, (time.struct_time, tuple)):
        value = calendar.timegm(value)
        value = time.gmtime(value + eveLocalization.GetTimeDelta())
    elif isinstance(value, float):
        value = time.gmtime(value + eveLocalization.GetTimeDelta())
    else:
        logger.LogTraceback('datetime only accepts blue time or Python time as values, but we received a ', type(value).__name__, '.')
        return None
    return PrepareLocalizationSafeString(time.strftime(formatString, value), 'time')
Пример #2
0
 def IsInNextEventsWindow(self, eventYear, eventMonth):
     now = blue.os.GetWallclockTime(
     ) + eveLocalization.GetTimeDelta() * const.SEC
     nowYear, nowMonth = util.GetYearMonthFromTime(now)
     if eventYear == nowYear:
         return eventMonth in (nowMonth, nowMonth + 1)
     if eventYear == nowYear + 1:
         return nowMonth == const.calendarDecember and eventMonth == const.calendarJanuary
     return False
Пример #3
0
    def FetchNextEvents(self, monthsAhead = 1):
        now = blue.os.GetWallclockTime() + eveLocalization.GetTimeDelta() * const.SEC
        year, month, wd, day, hour, minute, sec, ms = blue.os.GetTimeParts(now)
        nextEvents = self.FetchNextEventsDict(month, year, now)
        for i in xrange(monthsAhead):
            monthsFromNow = i + 1
            y, m = self.GetBrowsedMonth(monthsFromNow, year, month)
            nextMonthEvents = self.FetchNextEventsDict(m, y, now)
            nextEvents.update(nextMonthEvents)

        return nextEvents
Пример #4
0
 def IsInNextEventsWindow(self, eventYear, eventMonth):
     """
         Determines if the event datetime is in the current month or next month.
         If so, then the event should be shown in Latest Update / Upcoming Events
         lists.
     """
     now = blue.os.GetWallclockTime() + eveLocalization.GetTimeDelta() * const.SEC
     nowYear, nowMonth = util.GetYearMonthFromTime(now)
     if eventYear == nowYear:
         return eventMonth in (nowMonth, nowMonth + 1)
     if eventYear == nowYear + 1:
         return nowMonth == const.calendarDecember and eventMonth == const.calendarJanuary
     return False
Пример #5
0
    def GetMyNextEvents(self, monthsAhead=1):
        events = self.GetEventsNextXMonths(monthsAhead)
        showTag = self.GetActiveTags()
        myNextEvents = {}
        now = blue.os.GetWallclockTime(
        ) + eveLocalization.GetTimeDelta() * const.SEC
        for eventID, eventKV in events.iteritems():
            if self.IsOnToDoList(now,
                                 eventKV) and (showTag is None
                                               or showTag & eventKV.flag != 0):
                myNextEvents[eventID] = eventKV

        return myNextEvents
Пример #6
0
    def GetMyNextEvents(self, monthsAhead = 1):
        """
            Get the next events you have in the next _monthsAhead_ months (current month + _monthsAhead_)
            This only includes events you havent replied to or have accepted
        """
        events = self.GetEventsNextXMonths(monthsAhead)
        showTag = self.GetActiveTags()
        myNextEvents = {}
        now = blue.os.GetWallclockTime() + eveLocalization.GetTimeDelta() * const.SEC
        for eventID, eventKV in events.iteritems():
            if self.IsOnToDoList(now, eventKV) and (showTag is None or showTag & eventKV.flag != 0):
                myNextEvents[eventID] = eventKV

        return myNextEvents
Пример #7
0
    def GetMyChangedEvents(self, monthsAhead = 1):
        """
            Get all the events that have not been processed (no reply)
            Returns a dictionary where key is the eventID and the value is the eventKV
        """
        events = self.GetEventsNextXMonths(monthsAhead)
        showTag = self.GetActiveTags()
        changedEvents = {}
        now = blue.os.GetWallclockTime() + eveLocalization.GetTimeDelta() * const.SEC
        for eventID, eventKV in events.iteritems():
            if self.IsInUpdateEventsList(now, eventKV) and (showTag is None or showTag & eventKV.flag != 0):
                changedEvents[eventID] = eventKV

        return changedEvents
Пример #8
0
def ParseTime(time, isInterval=False):
    if time is None or time == '':
        return
    try:
        tp = time.split(':', 2)
        time = int(tp[0]) * const.HOUR + int(tp[1]) * const.MIN
        if len(tp) == 3:
            time = time + int(tp[2]) * const.SEC
        if not isInterval and boot.region == 'optic':
            time -= eveLocalization.GetTimeDelta() * const.SEC
            if time < 0:
                time += 24 * const.HOUR
        return time
    except:
        raise UserError('InvalidTime', {'time': time})
Пример #9
0
def ParseTime(time, isInterval=False):
    """
    Parses a time string into a Blue time. Returns None if 'time' is None or empty
    string, raises InvalidDate if the string is incorrectly formatted or a Blue time
    if successfull.
    
    'time' is a string with these parts: "[h:m]" or "[h:m:s]"
    """
    if time is None or time == '':
        return
    try:
        tp = time.split(':', 2)
        time = int(tp[0]) * const.HOUR + int(tp[1]) * const.MIN
        if len(tp) == 3:
            time = time + int(tp[2]) * const.SEC
        if not isInterval and boot.region == 'optic':
            time -= eveLocalization.GetTimeDelta() * const.SEC
            if time < 0:
                time += 24 * const.HOUR
        return time
    except:
        raise UserError('InvalidTime', {'time': time})
Пример #10
0
def GetTimeDeltaSeconds(*args, **kwargs):
    return eveLocalization.GetTimeDelta(*args, **kwargs)
Пример #11
0
def GetTimeParts(datetime, utc=False):
    if not utc and datetime % const.DAY and boot.region == 'optic':
        datetime += eveLocalization.GetTimeDelta() * const.SEC
    return blue.os.GetTimeParts(datetime)
Пример #12
0
def GetTimeOffsetInHours():
    try:
        import eveLocalization
        return int(eveLocalization.GetTimeDelta() / 3600)
    except ImportError:
        return 0
Пример #13
0
 def IsInPastFromBlueTime(self, then, now=None, *args):
     if now is None:
         now = blue.os.GetWallclockTime(
         ) + eveLocalization.GetTimeDelta() * const.SEC
     inPast = now > then
     return inPast