Exemple #1
0
    def formatDateTime(self, dateTime):
        now = timezoneUtils.nowutc().astimezone(self._timezone)

        if dateTime.date() == now.date():
            return _("today") + " " + formatTime(dateTime.time())
        elif dateTime.date() == (now + datetime.timedelta(days=1)).date():
            return _("tomorrow") + " " + formatTime(dateTime.time())
        elif dateTime < (now + datetime.timedelta(days=6)):
            return formatDateTime(dateTime, format="EEEE H:mm")
        elif dateTime.date().year == now.date().year:
            return formatDateTime(dateTime, format="d MMM")
        else:
            return formatDateTime(dateTime, format="d MMM yyyy")
Exemple #2
0
    def formatDateTime(self, dateTime):
        now = timezoneUtils.nowutc().astimezone(self._timezone)

        if dateTime.date() == now.date():
            return _("today") + " " + formatTime(dateTime.time())
        elif dateTime.date() == (now + datetime.timedelta(days=1)).date():
            return _("tomorrow") + " " + formatTime(dateTime.time())
        elif dateTime < (now + datetime.timedelta(days=6)):
            return formatDateTime(dateTime, format="%A %H:%M")
        elif dateTime.date().year == now.date().year:
            return formatDateTime(dateTime, format="%d %b")
        else:
            return formatDateTime(dateTime, format="%d %b %Y")
    def talkListText(cls, conf, talkList):
        text = []

        #we sort by start date
        talkList.sort(key = Contribution.contributionStartDateForSort)

        #we check is event is single day
        singleDayEvent = isSameDay(conf.getStartDate(), conf.getEndDate(), conf.getTimezone())

        for contribution in talkList:

            #1. speakers text
            speakerList = contribution.getSpeakerList()
            if speakerList:
                speakers = ', by ' + ", ".join([person.getFullName() for person in speakerList])
            else:
                speakers = ''

            #2. room and location text
            locationStr = MailTools.locationOrRoomToStr(contribution.getLocation())
            roomStr = MailTools.locationOrRoomToStr(contribution.getRoom())
            confLocationStr = MailTools.locationOrRoomToStr(conf.getLocation())
            confRoomStr = MailTools.locationOrRoomToStr(conf.getRoom())

            if locationStr == confLocationStr and roomStr == confRoomStr:
                locationText = ''
            else:
                if locationStr:
                    locationText = "Location: " + locationStr
                    if roomStr:
                        locationText += ', Room: ' + roomStr
                    else:
                        locationText += ', Room: not defined'
                else:
                    locationText = "Location: not defined"

                locationText = " (%s)" % locationText

            #3. dates text
            if not contribution.getStartDate():
                datesText = '(Not scheduled)'
            elif singleDayEvent and isSameDay(conf.getStartDate(), contribution.getStartDate(), conf.getTimezone()):
                datesText = formatTime(contribution.getAdjustedStartDate().time()) + ' (' + formatDuration(contribution.getDuration(), "hours_minutes") + ')'
            else:
                datesText = formatDateTime(contribution.getAdjustedStartDate(), showWeek = True) + ' (' + formatDuration(contribution.getDuration(), "hours_minutes") + ')'

            #4. returned result
            contributionLine = """•%s : <a href="%s">%s</a>%s (id: %s)%s""" % (
                datesText,
                urlHandlers.UHContributionDisplay.getURL(contribution),
                contribution.getTitle(),
                speakers,
                contribution.getId(),
                locationText
            )
            text.append(contributionLine)

        return text
 def talkListText(cls, conf, talkList):
     text = []
     
     #we sort by start date
     talkList.sort(key = Contribution.contributionStartDateForSort)
     
     #we check is event is single day
     singleDayEvent = isSameDay(conf.getStartDate(), conf.getEndDate(), conf.getTimezone())
     
     for contribution in talkList:
         
         #1. speakers text
         speakerList = contribution.getSpeakerList()
         if speakerList:
             speakers = ', by ' + ", ".join([person.getFullName() for person in speakerList])
         else:
             speakers = ''
         
         #2. room and location text
         locationStr = MailTools.locationOrRoomToStr(contribution.getLocation())
         roomStr = MailTools.locationOrRoomToStr(contribution.getRoom())
         confLocationStr = MailTools.locationOrRoomToStr(conf.getLocation())
         confRoomStr = MailTools.locationOrRoomToStr(conf.getRoom())
         
         if locationStr == confLocationStr and roomStr == confRoomStr:
             locationText = ''
         else:
             if locationStr:
                 locationText = "Location: " + locationStr
                 if roomStr:
                     locationText += ', Room: ' + roomStr
                 else:
                     locationText += ', Room: not defined'
             else:
                 locationText = "Location: not defined"
             
             locationText = " (%s)" % locationText
             
         #3. dates text
         if not contribution.getStartDate():
             datesText = '(Not scheduled)'
         elif singleDayEvent and isSameDay(conf.getStartDate(), contribution.getStartDate(), conf.getTimezone()):
             datesText = formatTime(contribution.getAdjustedStartDate().time()) + ' (' + formatDuration(contribution.getDuration(), "hours_minutes") + ')'
         else:
             datesText = formatDateTime(contribution.getAdjustedStartDate(), showWeek = True) + ' (' + formatDuration(contribution.getDuration(), "hours_minutes") + ')'
             
         #4. returned result
         contributionLine = """•%s : <a href="%s">%s</a>%s (id: %s)%s""" % (
             datesText,
             urlHandlers.UHContributionDisplay.getURL(contribution),
             contribution.getTitle(),
             speakers,
             contribution.getId(),
             locationText
         )
         text.append(contributionLine)
     
     return text