def create(self):
     startDate, finishDate = self._data.getGroupStartFinishTime()
     startDateStruct = getTimeStructInLocal(startDate)
     finishDateStruct = getTimeStructInLocal(finishDate)
     startDateText = text_styles.main(
         backport.text(TOOLTIPS.MARATHON_DATE,
                       day=startDateStruct.tm_mday,
                       month=i18n.makeString(
                           MENU.datetime_months(startDateStruct.tm_mon)),
                       hour=startDateStruct.tm_hour,
                       minutes=i18n.makeString('%02d',
                                               startDateStruct.tm_min)))
     finishDateText = text_styles.main(
         backport.text(TOOLTIPS.MARATHON_DATE,
                       day=finishDateStruct.tm_mday,
                       month=i18n.makeString(
                           MENU.datetime_months(finishDateStruct.tm_mon)),
                       hour=finishDateStruct.tm_hour,
                       minutes=i18n.makeString('%02d',
                                               finishDateStruct.tm_min)))
     text = text_styles.main(
         backport.text(TOOLTIPS.MARATHON_SUBTITLE,
                       startDate=startDateText,
                       finishDate=finishDateText))
     return ('', text)
    def _packBlocks(self):
        items = super(RankedCalendarStepsTooltip, self)._packBlocks()
        blocks = [self._packHeaderBlock()]
        key = RANKED_BATTLES.RANKEDBATTLEVIEW_STATUSBLOCK_CALENDARPOPOVER_CYCLEITEM
        cycles = self.rankedController.getCurrentSeason().getAllCycles()
        for cycle in sorted(cycles.values()):
            currentCycle = False
            if cycle.status == CYCLE_STATUS.CURRENT:
                formatter = text_styles.main
                currentCycle = True
            else:
                formatter = text_styles.standard
            startDate = time_utils.getTimeStructInLocal(cycle.startDate)
            endDate = time_utils.getTimeStructInLocal(cycle.endDate)
            item = formatter(
                i18n.makeString(key,
                                cycleNumber=cycle.ordinalNumber,
                                day0='{:02d}'.format(startDate.tm_mday),
                                month0='{:02d}'.format(startDate.tm_mon),
                                day1='{:02d}'.format(endDate.tm_mday),
                                month1='{:02d}'.format(endDate.tm_mon)))
            if currentCycle:
                blocks.append(
                    formatters.packImageTextBlockData(
                        title=item,
                        img=RES_ICONS.MAPS_ICONS_LIBRARY_INPROGRESSICON,
                        imgPadding=formatters.packPadding(top=5),
                        txtPadding=formatters.packPadding(left=5)))
            else:
                blocks.append(
                    formatters.packTextBlockData(
                        text=item, padding=formatters.packPadding(left=20)))

        items.append(formatters.packBuildUpBlockData(blocks, 13))
        return items
Пример #3
0
 def __getCurrnetCycleString(self):
     key = RANKED_BATTLES.RANKEDBATTLEVIEW_STATUSBLOCK_CALENDARPOPOVER_CYCLEITEM
     cycles = self.__seasonInfo.getAllCycles()
     for cycle in sorted(cycles.values()):
         if cycle.status == CYCLE_STATUS.CURRENT:
             formatter = text_styles.main
             startDate = time_utils.getTimeStructInLocal(cycle.startDate)
             endDate = time_utils.getTimeStructInLocal(cycle.endDate)
             return formatter(i18n.makeString(key, cycleNumber=cycle.ordinalNumber, day0='{:02d}'.format(startDate.tm_mday), month0='{:02d}'.format(startDate.tm_mon), day1='{:02d}'.format(endDate.tm_mday), month1='{:02d}'.format(endDate.tm_mon)))
Пример #4
0
 def __getCycleListString(self):
     key = RANKED_BATTLES.RANKEDBATTLEVIEW_STATUSBLOCK_CALENDARPOPOVER_CYCLEITEM
     cycles = self.__seasonInfo.getAllCycles()
     result = []
     for cycle in sorted(cycles.values()):
         formatter = text_styles.main if cycle.status == CYCLE_STATUS.CURRENT else text_styles.standard
         startDate = time_utils.getTimeStructInLocal(cycle.startDate)
         endDate = time_utils.getTimeStructInLocal(cycle.endDate)
         result.append(formatter(i18n.makeString(key, cycleNumber=self.__currentCycle, day0='{:02d}'.format(startDate.tm_mday), month0='{:02d}'.format(startDate.tm_mon), day1='{:02d}'.format(endDate.tm_mday), month1='{:02d}'.format(endDate.tm_mon))))
    def _onLoading(self, engravingId):
        viewModel = self.getViewModel()
        dtHelper = BigWorld.player().dogTags
        with viewModel.transaction() as model:
            engravingComponent = dtHelper.getDogTagComponentForAccount(
                engravingId)
            engravingId = engravingComponent.compId
            skillRecords = sorted(dtHelper.getSkillData(engravingId),
                                  key=lambda e: e.date)
            indexMax = -1
            if skillRecords:
                maxValue = max(skillRecords[::-1], key=attrgetter('value'))
                if maxValue.value >= engravingComponent.componentDefinition.grades[
                        0]:
                    indexMax = skillRecords.index(maxValue)
            model.setHighlightedIndex(indexMax)
            monthNames = model.getMonthNames()
            monthlyValues = model.getMonthlyValues()
            for date, value in skillRecords:
                monthRes = self._getMonthRes(date[1])
                monthNames.addResource(monthRes)
                if value is not None:
                    monthlyValues.addReal(value)

            currentMonth = getTimeStructInLocal(
                getCurrentLocalServerTimestamp()).tm_mon
            model.setCurrentMonth(self._getMonthRes(currentMonth))
            model.setProgressNumberType(
                engravingComponent.componentDefinition.numberType.value)
        return
Пример #6
0
def formatDate(dateFormat, timestamp):
    """
    @param dateFormat: can be string of format or localization key
    @param timestamp: timestamp
    @return: formated date as string
    """
    return time.strftime(i18n.makeString(dateFormat),
                         time_utils.getTimeStructInLocal(timestamp))
Пример #7
0
def formatDate(dateFormat, timestamp):
    """
    @param dateFormat: can be string of format or localization key
    @param timestamp: timestamp
    @return: formated date as string
    """
    prefEnc = locale.getpreferredencoding()
    return time.strftime(
        i18n.makeString(dateFormat),
        time_utils.getTimeStructInLocal(timestamp)).decode(prefEnc)
Пример #8
0
 def _getConditions(self, svrEvents):
     subBlocks = []
     bonus = self.event.bonusCond
     battlesLeft, battlesCount, inrow = None, None, False
     battles = bonus.getConditions().find("battles")
     if battles is not None:
         battlesCount = battles._getTotalValue()
         if not self.event.isCompleted() and bonus.getGroupByValue() is None:
             progress = battles.getProgressPerGroup()
             if None in progress:
                 curProg, totalProg, _, _ = progress[None]
                 battlesLeft = totalProg - curProg
     bonusFmtConds = bonus.format(svrEvents, event=self.event)
     if len(bonusFmtConds):
         subBlocks.extend(formatters.indexing(bonusFmtConds))
     postBattleFmtConds = self.event.postBattleCond.format(svrEvents, event=self.event)
     if len(postBattleFmtConds):
         if len(bonusFmtConds):
             subBlocks.append(
                 formatters.packSeparator(label=i18n.makeString("#quests:details/conditions/postBattle/separator"))
             )
         subBlocks.extend(formatters.indexing(postBattleFmtConds))
     if bonus.isDaily():
         resetHourOffset = (time_utils.ONE_DAY - self._getDailyProgressResetTimeOffset()) / 3600
         if resetHourOffset >= 0:
             subBlocks.append(
                 formatters.packTextBlock(
                     label=formatters.formatYellow("#quests:details/conditions/postBattle/dailyReset")
                     % {
                         "time": time.strftime(
                             i18n.makeString("#quests:details/conditions/postBattle/dailyReset/timeFmt"),
                             time_utils.getTimeStructInLocal(time_utils.getTimeTodayForUTC(hour=resetHourOffset)),
                         )
                     }
                 )
             )
     result = []
     if len(subBlocks) or battlesCount:
         if not self.event.isGuiDisabled():
             result.append(
                 formatters.packConditionsBlock(battlesCount, battlesLeft, bonus.isInRow(), conditions=subBlocks)
             )
         else:
             result.append(formatters.packConditionsBlock(conditions=subBlocks))
     if bonus.getGroupByValue() is not None and not self.event.isGuiDisabled():
         progressesFmt = bonus.formatGroupByProgresses(svrEvents, self.event)
         if len(progressesFmt):
             result.append(
                 formatters.packTopLevelContainer(
                     i18n.makeString("#quests:details/conditions/groupBy/%s" % bonus.getGroupByValue()),
                     subBlocks=progressesFmt,
                     isResizable=len(progressesFmt) > 5,
                 )
             )
     return formatters.todict(result)
 def __getDateTimeText(dateTime):
     localDateTime = getTimeStructInLocal(dateTime)
     monthName = backport.text(
         R.strings.menu.dateTime.months.dyn('c_{}'.format(
             localDateTime.tm_mon))())
     dateTimeText = backport.text(
         R.strings.tutorial.techtree.nationDiscount.dateTime(),
         day=localDateTime.tm_mday,
         monthName=monthName,
         year=localDateTime.tm_year)
     return dateTimeText
Пример #10
0
def _getOfferStr(offer, getKey, epicCtrl=None):
    key, values = _parseRent(offer)
    if key == 'cycle':
        indexes = str(epicCtrl.getCycleOrdinalNumber(first(values)))
    elif key == 'cycles':
        indexes = [ epicCtrl.getCycleOrdinalNumber(value) for value in values ]
        indexes = '{}-{}'.format(min(indexes), max(indexes))
    else:
        _, endTimestamp = epicCtrl.getSeasonTimeRange()
        indexes = str(getTimeStructInLocal(endTimestamp).tm_year)
    return _ms(key=getKey(key), value=indexes)
 def __setDateLeftTime(self):
     gmTime = time_utils.getTimeStructInLocal(self.__endTime)
     monthName = i18n.makeString(MENU.datetime_months(gmTime.tm_mon))
     fmtValues = i18n.makeString(
         '%s %s %s' % (gmTime.tm_mday, monthName, gmTime.tm_year))
     tooltip = makeTooltip(
         header=TOOLTIPS.VEHICLEPREVIEW_SHOPPACK_DATETIMETOOLTIP_HEADER,
         body=i18n.makeString(
             TOOLTIPS.VEHICLEPREVIEW_SHOPPACK_DATETIMETOOLTIP_BODY,
             namePack=text_styles.neutral(self.__packTitle),
             date=fmtValues))
     self.as_updateLeftTimeS(formattedTime='', tooltip=tooltip)
 def __onCalendarDataSelected(self, event):
     timestamp = event.getTimestamp()
     if timestamp:
         self.__selectedDayStart, self.__selectedDayEnd = time_utils.getDayTimeBoundsForLocal(
             timestamp)
         self.__selectedDefencePeriodStart, self.__selectedDefencePeriodEnd = self.__selectedDayStart, self.__selectedDayEnd
         LOG_DEBUG(
             time.strftime(
                 'Attack time has been changed by user, %d.%m.%Y %H:%M',
                 time_utils.getTimeStructInLocal(timestamp)))
         self.__calculateDefencePeriod()
         self.__makeData()
 def _getDateTimeText(self, timestamp):
     localDateTime = getTimeStructInLocal(timestamp)
     monthName = backport.text(
         R.strings.menu.dateTime.months.dyn('c_{}'.format(
             localDateTime.tm_mon))())
     dateTimeText = backport.text(
         R.strings.marathon.vehiclePreview.tooltip.dateTime(),
         day=localDateTime.tm_mday,
         monthName=monthName,
         year=localDateTime.tm_year,
         hour=localDateTime.tm_hour,
         min='{min:02d}'.format(min=localDateTime.tm_min))
     return dateTimeText.replace(' ', ' ')
    def _packBlocks(self):
        items = super(RankedCalendarStepsTooltip, self)._packBlocks()
        blocks = [self.__packHeaderBlock()]
        key = R.strings.ranked_battles.rankedBattleView.statusBlock.calendarPopover.cycleItem(
        )
        currentSeason = self.rankedController.getCurrentSeason()
        cycles = currentSeason.getAllCycles()
        seasonName = currentSeason.getNumber()
        for cycle in sorted(cycles.values()):
            currentCycle = False
            if cycle.status == CycleStatus.CURRENT:
                formatter = text_styles.main
                currentCycle = True
            else:
                formatter = text_styles.standard
            startDate = time_utils.getTimeStructInLocal(cycle.startDate)
            endDate = time_utils.getTimeStructInLocal(cycle.endDate)
            item = formatter(
                backport.text(key,
                              cycleNumber=seasonName,
                              day0='{:02d}'.format(startDate.tm_mday),
                              month0='{:02d}'.format(startDate.tm_mon),
                              day1='{:02d}'.format(endDate.tm_mday),
                              month1='{:02d}'.format(endDate.tm_mon)))
            if currentCycle:
                blocks.append(
                    formatters.packImageTextBlockData(
                        title=item,
                        img=backport.image(
                            R.images.gui.maps.icons.library.inProgressIcon()),
                        imgPadding=formatters.packPadding(top=5),
                        txtPadding=formatters.packPadding(left=5)))
            blocks.append(
                formatters.packTextBlockData(
                    text=item, padding=formatters.packPadding(left=20)))

        items.append(formatters.packBuildUpBlockData(blocks, 13))
        return items
Пример #15
0
 def _getDailyResetStatus(self, resetLabelKey, labeFormatter):
     if self.event.bonusCond.isDaily():
         resetHourUTC = self._getDailyProgressResetTimeUTC(
         ) / time_utils.ONE_HOUR
         if resetHourUTC >= 0:
             return labeFormatter(resetLabelKey) % {
                 'time':
                 time.strftime(
                     i18n.makeString(
                         '#quests:details/conditions/postBattle/dailyReset/timeFmt'
                     ),
                     time_utils.getTimeStructInLocal(
                         time_utils.getTimeTodayForUTC(hour=resetHourUTC)))
             }
 def getFormattedStartFinishText(self):
     startDate, finishDate = self.__getGroupStartFinishTime()
     startDateStruct = getTimeStructInLocal(startDate)
     finishDateStruct = getTimeStructInLocal(finishDate)
     startDateText = text_styles.main(
         _ms(TOOLTIPS.BLOGGERS_DATE,
             day=startDateStruct.tm_mday,
             month=i18n.makeString(
                 MENU.datetime_months(startDateStruct.tm_mon)),
             hour=startDateStruct.tm_hour,
             minutes=i18n.makeString('%02d', startDateStruct.tm_min)))
     finishDateText = text_styles.main(
         _ms(TOOLTIPS.BLOGGERS_DATE,
             day=finishDateStruct.tm_mday,
             month=i18n.makeString(
                 MENU.datetime_months(startDateStruct.tm_mon)),
             hour=finishDateStruct.tm_hour,
             minutes=i18n.makeString('%02d', finishDateStruct.tm_min)))
     text = text_styles.main(
         _ms(TOOLTIPS.BLOGGERS_SUBTITLE,
             startDate=startDateText,
             finishDate=finishDateText))
     return (None, text)
Пример #17
0
 def __init__(self,
              intCD,
              rentType,
              nums=(0, ),
              price=MONEY_UNDEFINED,
              seasonType=0,
              renew=False):
     key = 'rentConfirmationRenew' if renew else 'rentConfirmation'
     super(RentConfirmDialogMeta,
           self).__init__(key,
                          scope=ScopeTemplates.LOBBY_SUB_SCOPE,
                          focusedID=DIALOG_BUTTON_ID.SUBMIT)
     vehicle = self.itemsCache.items.getItemByCD(intCD)
     if rentType == RentType.SEASON_CYCLE_RENT:
         if len(nums) > 1:
             key = 'cycles'
             indexes = [
                 self.epicController.getCycleOrdinalNumber(int(n))
                 for n in nums
             ]
             indexes = '{}-{}'.format(min(indexes), max(indexes))
         else:
             key = 'cycle'
             indexes = str(
                 self.epicController.getCycleOrdinalNumber(int(nums[0])))
     elif RentType.SEASON_RENT:
         key = 'season'
         _, endTimestamp = self.epicController.getSeasonTimeRange()
         indexes = str(getTimeStructInLocal(endTimestamp).tm_year)
     else:
         key = ''
         indexes = str(None)
         _logger.debug(
             'GameSeasonType %s with RentType %s is not supported',
             seasonType, rentType)
     stage = backport.text(
         R.strings.vehicle_preview.buyingPanel.offer.rent.name.dyn(key)(),
         value=indexes)
     event = backport.text(R.strings.arenas.type.epic.name.inQuotes())
     period = backport.text(R.strings.dialogs.rentConfirmation.period(),
                            stage=stage or 'Stage',
                            event=event or 'Event')
     self._messageCtx = {
         'name': vehicle.shortUserName or 'Vehicle',
         'period': text_styles.stats(period),
         'price': formatPrice(price, reverse=True, useIcon=True)
     }
     return
 def __setDateLeftTime(self):
     tm = time_utils.getTimeStructInLocal(self.__endTime)
     monthName = backport.text(
         R.strings.menu.dateTime.months.num(tm.tm_mon)())
     fmtValues = backport.text(R.strings.menu.dateTime.order(),
                               day=tm.tm_mday,
                               month=monthName,
                               year=tm.tm_year)
     tooltip = makeTooltip(
         header=backport.text(R.strings.tooltips.vehiclePreview.shopPack.
                              dateTimeTooltip.header()),
         body=backport.text(R.strings.tooltips.vehiclePreview.shopPack.
                            dateTimeTooltip.body(),
                            namePack=text_styles.neutral(self.__title),
                            date=fmtValues))
     self.as_setSetTitleTooltipS(tooltip)
     self.as_updateLeftTimeS(formattedTime='')
Пример #19
0
 def _getWeeklyResetStatus(self, resetLabelKey, labeFormatter):
     if self.event.bonusCond.isWeekly():
         day, resetSeconds = self._getWeeklyProgressResetTimeUTC()
         resetHourUTC = resetSeconds / time_utils.ONE_HOUR
         dayStr = i18n.makeString('#menu:dateTime/weekDays/full/' +
                                  str(day + 1)) + ', '
         if resetHourUTC >= 0:
             resetTime = time_utils.getTimeStructInLocal(
                 time_utils.getTimeTodayForUTC(hour=resetHourUTC))
             resetTime = time.struct_time(resetTime[:6] + (day, ) +
                                          resetTime[7:])
             return labeFormatter(resetLabelKey) % {
                 'time':
                 dayStr + time.strftime(
                     i18n.makeString(
                         '#quests:details/conditions/postBattle/weeklyReset/timeFmt'
                     ), resetTime)
             }
 def __makeSeasonTimeText(self):
     if self.__battlePass.isExtraChapter(self.__chapterID):
         endTimestamp = self.__battlePass.getChapterExpiration(
             self.__chapterID)
         endStringRes = _bpRes.progression.season.end.extra
     elif self.__battlePass.isSeasonFinished():
         endTimestamp = 0
         endStringRes = _bpRes.commonProgression.body.ended
     else:
         endTimestamp = self.__battlePass.getSeasonFinishTime()
         endStringRes = _bpRes.progression.season.end.normal
     endTime = time_utils.getTimeStructInLocal(endTimestamp)
     return backport.text(
         endStringRes(),
         seasonNum=int2roman(self.__battlePass.getSeasonNum()),
         endDay=endTime.tm_mday,
         endMonth=backport.text(
             R.strings.menu.dateTime.months.num(endTime.tm_mon)()),
         endTime=formatDate('%H:%M', endTimestamp))
Пример #21
0
 def __getDayMonth(timeStamp):
     timeStruct = time_utils.getTimeStructInLocal(timeStamp)
     return (timeStruct.tm_mday, timeStruct.tm_mon)
 def __onCalendarDataSelected(self, event):
     timestamp = event.getTimestamp()
     if timestamp:
         self.__selectedDayStart, self.__selectedDayEnd = time_utils.getDayTimeBoundsForLocal(timestamp)
         self.__selectedDefencePeriodStart, self.__selectedDefencePeriodEnd = self.__selectedDayStart, self.__selectedDayEnd
         LOG_DEBUG(time.strftime('Attack time has been changed by user, %d.%m.%Y %H:%M', time_utils.getTimeStructInLocal(timestamp)))
         self.__calculateDefencePeriod()
         self.__makeData()
Пример #23
0
 def _packConditions(self, svrEvents):
     subBlocks = []
     bonus = self.event.bonusCond
     battlesLeft, battlesCount, inrow = None, None, False
     battles = bonus.getConditions().find('battles')
     if battles is not None:
         battlesCount = battles._getTotalValue()
         if not self.event.isCompleted() and bonus.getGroupByValue() is None:
             progress = battles.getProgressPerGroup()
             if None in progress:
                 curProg, totalProg, _, _ = progress[None]
                 battlesLeft = totalProg - curProg
     bonusFmtConds = bonus.format(svrEvents, event=self.event)
     if len(bonusFmtConds):
         subBlocks.extend(formatters.indexing(bonusFmtConds))
     postBattleFmtConds = self.event.postBattleCond.format(svrEvents, event=self.event)
     if len(postBattleFmtConds):
         if len(bonusFmtConds):
             subBlocks.append(formatters.packSeparator(label=i18n.makeString('#quests:details/conditions/postBattle/separator')))
         subBlocks.extend(formatters.indexing(postBattleFmtConds))
     if bonus.isDaily():
         resetHourOffset = (time_utils.ONE_DAY - self._getDailyProgressResetTimeOffset()) / 3600
         if resetHourOffset >= 0:
             subBlocks.append(formatters.packTextBlock(label=formatters.formatYellow('#quests:details/conditions/postBattle/dailyReset') % {'time': time.strftime(i18n.makeString('#quests:details/conditions/postBattle/dailyReset/timeFmt'), time_utils.getTimeStructInLocal(time_utils.getTimeTodayForUTC(hour=resetHourOffset)))}))
     result = []
     if len(subBlocks) or battlesCount:
         if not self.event.isGuiDisabled():
             result.append(formatters.packConditionsBlock(battlesCount, battlesLeft, bonus.isInRow(), conditions=subBlocks))
         else:
             result.append(formatters.packConditionsBlock(conditions=subBlocks))
     if bonus.getGroupByValue() is not None and not self.event.isGuiDisabled():
         progressesFmt = bonus.formatGroupByProgresses(svrEvents, self.event)
         if len(progressesFmt):
             result.append(formatters.packTopLevelContainer(i18n.makeString('#quests:details/conditions/groupBy/%s' % bonus.getGroupByValue()), subBlocks=progressesFmt, isResizable=len(progressesFmt) > 5))
     return result
 def __getDateTimeText(self, dateTime):
     localDateTime = getTimeStructInLocal(dateTime)
     monthName = backport.text(R.strings.menu.dateTime.months.dyn('c_{}'.format(localDateTime.tm_mon))())
     dateTimeText = backport.text(R.strings.marathon.vehiclePreview.tooltip.dateTime(), day=localDateTime.tm_mday, monthName=monthName, year=localDateTime.tm_year, hour=localDateTime.tm_hour, min='{min:02d}'.format(min=localDateTime.tm_min))
     return self.__noWrapTextFormat(dateTimeText)
def formatDate(dateFormat, timestamp):
    return time.strftime(i18n.makeString(dateFormat),
                         time_utils.getTimeStructInLocal(timestamp))