Esempio n. 1
0
 def weekagoDate(self):
     """返回一周前的日期,年月日格式"""
     weekago = topicdate.getdayofday(-7)
     translation_service = getToolByName(self.context,'translation_service')
     weekagotoday = translation_service.translate(
                                               'a_week_ago_date',
                                               domain='emc.kb',
                                               mapping={'year': weekago.year,'month':weekago.month,
                                                        'day':weekago.day},
                                               context=self.context,
                                               default=u"${year}年${month}月${day}日")
     return weekagotoday
Esempio n. 2
0
    def fetchdatedisplay(self):
        """  默认返回为 一周前的日子-今天的日期,
        参数为30,返回30天前的日期-今天的日期,
        参数为0,返回ALL,
        返回为字符串类型 """
        
#        st2 = self.request["QUERY_STRING"]
#        
#        """默认为7天"""
#        if len(st2) == 0:
#            days = 7
#        else:
#            st = st2.split("=")
#            try:
#                 days = int(st[1])
#            except:
#                 return _(u"All")
#            if days == 0:
#                return _(u"All")
        days = self.currentDateNum()
        if days == 0:
            message = translate(Message(ALL_DAY),
                                context=self.request)
            return message
        
        ago = topicdate.getdayofday(-days)
        today = unicode(time.strftime("%Y年%m月%d日",time.localtime()),"utf-8")
        translation_service = getToolByName(self.context,'translation_service')
        agotoday = translation_service.translate(
                                                  'ago_date',
                                                  domain='emc.kb',
                                                  mapping={'year': ago.year,'month':ago.month,
                                                           'day':ago.day},
                                                  context=self.context,
                                                  default=u"${year}年${month}月${day}日")
        return "%s----%s"%(agotoday,today)