当前位置: 首页>>代码示例>>Python>>正文


Python DateTime.mktime方法代码示例

本文整理汇总了Python中mx.DateTime.mktime方法的典型用法代码示例。如果您正苦于以下问题:Python DateTime.mktime方法的具体用法?Python DateTime.mktime怎么用?Python DateTime.mktime使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在mx.DateTime的用法示例。


在下文中一共展示了DateTime.mktime方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: toPython

# 需要导入模块: from mx import DateTime [as 别名]
# 或者: from mx.DateTime import mktime [as 别名]
 def toPython(self, value, state):
     if value is None:
         return None
     if isinstance(value, DateTimeType):
         return value
     if datetime_available: # convert datetime instance to mxDateTime
         if isinstance(value, datetime.datetime):
             return DateTime.DateTime(value.year, value.month, value.day,
                 value.hour, value.minute, value.second)
         elif isinstance(value, datetime.date):
             return DateTime.Date(value.year, value.month, value.day)
     try:
         stime = time.strptime(value, self.format)
     except:
         raise validators.InvalidField("expected an date/time string of the '%s' format in the DateTimeCol '%s', got %s instead" % \
             (self.format, self.name, type(value)), value, state)
     return DateTime.mktime(stime)
开发者ID:pacoqueen,项目名称:bbinn,代码行数:19,代码来源:col.py

示例2: to_python

# 需要导入模块: from mx import DateTime [as 别名]
# 或者: from mx.DateTime import mktime [as 别名]
 def to_python(self, value, state):
     if value is None:
         return None
     if isinstance(value, (DateTimeType, TimeType, sqlbuilder.SQLExpression)):
         return value
     if isinstance(value, datetime.datetime):
         return DateTime.DateTime(value.year, value.month, value.day,
             value.hour, value.minute, value.second)
     elif isinstance(value, datetime.date):
         return DateTime.Date(value.year, value.month, value.day)
     elif isinstance(value, datetime.time):
         return DateTime.Time(value.hour, value.minute, value.second)
     try:
         stime = time.strptime(value, self.format)
     except:
         raise validators.Invalid("expected a date/time string of the '%s' format in the DateTimeCol '%s', got %s %r instead" % \
             (self.format, self.name, type(value), value), value, state)
     return DateTime.mktime(stime)
开发者ID:xblaster,项目名称:scrutator,代码行数:20,代码来源:col.py

示例3: __init__

# 需要导入模块: from mx import DateTime [as 别名]
# 或者: from mx.DateTime import mktime [as 别名]
 def __init__(self,val=None):
     _timestamp.__init__(self,val)
     self.__mxdt = DateTime.mktime(self.__tval)
开发者ID:caglar10ur,项目名称:func,代码行数:5,代码来源:timestamp.py

示例4: __get_event

# 需要导入模块: from mx import DateTime [as 别名]
# 或者: from mx.DateTime import mktime [as 别名]
    def __get_event(self, model):
        
        event = model.value.copy()
        self.__convert(event)

        caption = ''     
        description = [] 
        starts = None   
        ends = None      

        if self.axis:

            f = self.axis[0]
            s = event[f]

            if isinstance(s, (tuple, list)): s = s[-1]

            caption = ustr(s)

            for f in self.axis[1:]:
                s = event[f]
                if isinstance(s, (tuple, list)): s = s[-1]

                description += [ustr(s)]

        starts = event.get(self.date_start)
        ends = event.get(self.date_delay) or 1.0
        span = 0

        if starts and ends:

            n = 0
            h = ends or 1

            if ends == self.day_length: span = 1

            if ends > self.day_length:
                n = ends / self.day_length
                h = ends % self.day_length

                n = int(math.floor(n))

                if n > 0:
                    if not h:
                        n = n - 1
                    span = n + 1
                    
            t=DateTime.mktime(starts)
            ends = time.localtime(t.ticks() + (h * 60 * 60) + (n * 24 * 60 * 60))


        if starts and self.date_stop:

            ends = event.get(self.date_stop)
            if not ends:
                ends = time.localtime(time.mktime(starts) + 60 * 60)

            tds = time.mktime(starts)
            tde = time.mktime(ends)

            if tds >= tde:
                tde = tds + 60 * 60
                ends = time.localtime(tde)

            n = (tde - tds) / (60 * 60)

            if n > self.day_length:
                span = math.floor(n / 24.)
        
        if not starts:
            return None
        
        color_key = event.get(self.color_field)
        if isinstance(color_key, list):
            color_key = tuple(color_key)
        color_info = self.colors.get(color_key)

        color = color_info and color_info[2] or 'black'

        description = ', '.join(description).strip()
        all_day = span > 0
        return TinyEvent(model=model,
                         caption=caption.strip(),
                         start=datetime(*starts[:7]), 
                         end=datetime(*ends[:7]), 
                         description=description, 
                         dayspan=span,
                         all_day=all_day,
                         color_info=color_info,
                         bg_color = (all_day or self.mode != 'month') and color or 'white',
                         text_color = (all_day or self.mode != 'month') and 'black' or color,
        )
开发者ID:gisce,项目名称:erpclient,代码行数:94,代码来源:parser.py


注:本文中的mx.DateTime.mktime方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。