예제 #1
0
def strDateToUTCTimeStr(cr, uid, str_date, context):
    timestamp = util.strToTime(util.dateToTimeStr(str_date))
    converted = datetime_field.context_timestamp(cr,
                                                 uid,
                                                 timestamp=timestamp,
                                                 context=context)
    converted = util.strToTime(util.timeToStr(converted))
    diff = (converted - timestamp)
    utcTimestamp = timestamp - diff
    return util.timeToStr(utcTimestamp)
예제 #2
0
    def evalStr(self, value):
        if self.evalContext is None:
            t = self.dt and util.strToTime(self.dt) or datetime.now()
            t = datetime_field.context_timestamp(self.cr,
                                                 self.uid,
                                                 timestamp=t,
                                                 context={"tz": self.tz})
            sequences = {
                'year': '%Y',
                'month': '%m',
                'day': '%d',
                'y': '%y',
                'doy': '%j',
                'woy': '%W',
                'weekday': '%w',
                'h24': '%H',
                'h12': '%I',
                'min': '%M',
                'sec': '%S'
            }
            self.evalContext = {
                key: t.strftime(sequence)
                for key, sequence in sequences.iteritems()
            }

        if value:
            return value % self.evalContext

        return value
예제 #3
0
def strToLocalTimeFormat(cr, uid, str_time, format, context):
    # Convert datetime values to the expected client/context timezone
    timestamp = util.strToTime(str_time)
    converted = datetime_field.context_timestamp(cr,
                                                 uid,
                                                 timestamp=timestamp,
                                                 context=context)
    return util.dateFormat(converted, format)
예제 #4
0
def strToLocalDateStr(cr, uid, str_time, context):
    # Convert datetime values to the expected client/context timezone
    timestamp = util.strToTime(str_time)
    converted = datetime_field.context_timestamp(cr,
                                                 uid,
                                                 timestamp=timestamp,
                                                 context=context)
    return util.timeToDateStr(converted)
예제 #5
0
def strTimeToUTCTimeStr(cr, uid, timestamp, context):
    context_tz = context and context.get('tz') or None
    tz_name = None
    if context_tz:
        tz_name = context_tz
    else:
        registry = openerp.modules.registry.RegistryManager.get(cr.dbname)
        user = registry['res.users'].browse(cr, SUPERUSER_ID, uid)
        tz_name = user.tz

    if not tz_name:
        return timestamp

    tz = pytz.timezone(tz_name)
    l_timestamp = tz.localize(util.strToTime(timestamp))
    l_timestamp = l_timestamp.astimezone(pytz.utc)
    return util.timeToStr(l_timestamp)
예제 #6
0
def getSchema1(request, tags, deadline):
    '''
		Schema for typical task
	'''
    return {
       'task': request.form["tf"],\
       'type':request.form["type_of_task"],\
       'description': request.form["descr"],\
       'date': datetime.datetime.utcnow(),\
       'mark':0,\
       'complete':0,\
       'priority':priorityToNumber(request.form["priority_field"]),\
       'deadline': deadline,\
       'tags': tags,
       'isworking': False,
       'startworktime': datetime.datetime.utcnow(),
       'starttime': strToTime(request.form["starttime"]),
       'worktime': request.form['worktime'],
       'id': genTaskId(),
       'toycron': False,
       'comments': []
      }
예제 #7
0
def prepare_to_greedy(data):
	result = []
	for d in data:
		result.append((strToTime(d['starttime']), 
			strToTime(d['endtime']), int(d['deadline'])))
	return result
예제 #8
0
def prepare_to_greedy(data):
    result = []
    for d in data:
        result.append((strToTime(d['starttime']), strToTime(d['endtime']),
                       int(d['deadline'])))
    return result