def isTimeFormat(self): try: time.strptime(self.start_time, '%H:%M') time.strptime(self.finish_time, '%H:%M') return True except ValueError: return False
def caltime(date1, date2): date1 = time.strptime(date1, "%Y%m%d%H%M%S") date2 = time.strptime(date2, "%Y%m%d%H%M%S") date1 = datetime.datetime(date1[0], date1[1], date1[2], date1[3], date1[4], date1[5]) date2 = datetime.datetime(date2[0], date2[1], date2[2], date2[3], date2[4], date2[5]) return abs((date2 - date1).total_seconds())
def strTimeProp(start, end, format, prop): """Get a time at a proportion of a range of two formatted times. start and end should be strings specifying times formated in the given format (strftime-style), giving an interval [start, end]. prop specifies how a proportion of the interval to be taken after start. The returned time will be in the specified format. """ stime = time.mktime(time.strptime(start, format)) etime = time.mktime(time.strptime(end, format)) ptime = stime + prop * (etime - stime) return time.strftime(format, time.localtime(ptime))
def get_gld_info(self, name): temp_type = request.env['syt.oa.gld'].sudo().search([('name', '=', name.lstrip())]) copy_users = request.env['syt.oa.gld'].sudo().search([ ('copy_users.user_id', '=', request.session['uid']) ]) temp_type_list = [] if temp_type: for value in temp_type: temp_item = {} temp_item['name'] = value.name # 单号 temp_item['company_name'] = value.company_id.name # 公司 temp_item['dept'] = value.dept # 部门 temp_item['id'] = value.create_uid.id # 创建员工ID temp_item['user_name'] = value.create_uid.name # 创建员工姓名 timeArray = time.strptime(str(value.create_date), "%Y-%m-%d %H:%M:%S") timeStamp = int(time.mktime(timeArray)) create_time = timeStamp + 8 * 60 * 60 # 加8个小时 timeArray = time.localtime(create_time) otherStyleTime = time.strftime("%Y-%m-%d %H:%M:%S", timeArray) temp_item['write_date'] = otherStyleTime # 创建更新时间 temp_item['state'] = value.state # 状态 temp_item['subject'] = value.subject # 标题 temp_item['content'] = value.content # 正文 if copy_users: temp_item['copy_users'] = 'yes' # 区别 判断是抄送人还是审批人 else: temp_item['copy_users'] = 'no' # 区别 判断是抄送人还是审批人 temp_type_list.append(temp_item) return JSONEncoder().encode(temp_type_list)
def get_hourAndweek(date): date = time.strptime(date, "%Y%m%d%H%M%S") week = int(datetime.datetime(date[0], date[1], date[2]).strftime('%w')) date = datetime.datetime(date[0], date[1], date[2], date[3], date[4], date[5]) hour = date.hour return hour, week
def get_sns(self, gld_name): temp_list = [] gld = request.env['syt.oa.gld'].sudo().search([('name', '=', gld_name) ]) message = request.env['mail.message'].sudo().search([ ('res_id', '=', gld.id), ('model', '=', 'syt.oa.gld') ]) if message: for value in message: temp_item = {} employee = request.env['hr.employee'].sudo().search([ ('user_id', '=', int(value.create_uid)) ]) # temp_item['operator'] = employee.name # 操作人 temp_item['id'] = employee.id # 员工id temp_item['name'] = employee.name # 操作人 temp_item['email'] = employee.work_email # 员工邮箱 temp_item['body'] = str(value.body).replace("<p>", "").replace( "</p>", "") # 内容 timeArray = time.strptime(str(value.create_date), "%Y-%m-%d %H:%M:%S") timeStamp = int(time.mktime(timeArray)) create_time = timeStamp + 8 * 60 * 60 # 加8个小时 timeArray = time.localtime(create_time) otherStyleTime = time.strftime("%Y-%m-%d %H:%M:%S", timeArray) temp_item['time'] = otherStyleTime # 更新时间 temp_list.append(temp_item) return JSONEncoder().encode(temp_list)
def calendar_listing(request, ref_type, year, month, day): context = RequestContext(request) tt = time.strptime('%s-%s-%s' % (year, month, day), '%s-%s-%s' % ('%Y', '%m', '%d')) formatted_date = datetime.date(*tt[:3]) if ref_type == "fp": try: date_listings = Event.objects.filter( start_date__year=formatted_date.year, start_date__day=formatted_date.day, start_date__month=formatted_date.month, status=True) except: date_listings = None return render_to_response("announce/fp_listing.html", { "date_listings": date_listings, "date": formatted_date, }, context) if ref_type == "widget": try: events = Event.objects.filter( start_date__year=formatted_date.year, start_date__day=formatted_date.day, start_date__month=formatted_date.month, status=True) except: events = [] try: jobs = Job.objects.filter(deadline__year=formatted_date.year, deadline__day=formatted_date.day, deadline__month=formatted_date.month, status=True) except: jobs = [] try: opportunities = Opportunity.objects.filter( deadline__year=formatted_date.year, deadline__day=formatted_date.day, deadline__month=formatted_date.month, status=True) except: opportunities = [] date_listings = sorted(chain(events, opportunities, jobs)) # except: # date_listings = None return render_to_response("announce/widget_listing.html", { "date_listings": date_listings, "date": formatted_date, }, context)
def getTimeOClockOfToday(year, month, day): import time t = time.localtime(time.time()) time1 = time.mktime( time.strptime(time.strftime('%Y-%m-%d 00:00:00', t), '%Y-%m-%d %H:%M:%S')) return int(time1)
def find_mongo(db, startDate, endDate): try: pattern = '%Y%m%d/%H%M' startDateTS = int(time.mktime(time.strptime(startDate, pattern))) * 1000 endDateTS = int(time.mktime(time.strptime(endDate, pattern))) * 1000 result = db.mesowest.find( {"timestamp": { "$lt": endDateTS, "$gte": startDateTS }}) for document in result: print "Result from mongodb" print(document) return result except Exception as e: logging.warning(e)
def deleteDicc(self): lista = [] formato = '%Y-%m-%d %H:%M:%S' for clave in self.Dicc: valor = self.Dicc[clave][1] print(valor) if time.strptime(valor, formato) <= time.gmtime(time.time()): lista.append(clave) for usuario in lista: del self.Dicc[usuario]
def friendtime(dt,format='%Y-%m-%d %H:%M'): '''时间友好显示化''' t = time.localtime(time.time()) today = time.mktime(time.strptime(time.strftime('%Y-%m-%d 00:00:00', t),'%Y-%m-%d %H:%M:%S')) yestoday = today - 3600*24 if dt > today: return u'今天' + time.strftime('%H:%M',time.localtime(dt)) if dt > yestoday and dt < today: return u'昨天' + time.strftime('%H:%M',time.localtime(dt)) return time.strftime(format,time.localtime(dt))
def GetProjectsLastUpdate(self): self.Connect() self.cursor.execute('SELECT lastupdate FROM settings WHERE id = 1') lu = self.cursor.fetchone() if (lu[0] == None) or (lu[0] ==''): self.Disconnect() return None else: #dt = datetime.datetime.strptime(lu[0], '%Y-%m-%d %H:%M:%S.%f') dt = datetime.fromtimestamp(time.mktime(time.strptime(lu[0], '%Y-%m-%d %H:%M:%S.%f'))) self.Disconnect() return dt
def GetProjectsLastUpdate(self): self.Connect() self.cursor.execute('SELECT lastupdate FROM settings WHERE id = 1') lu = self.cursor.fetchone() if (lu[0] == None) or (lu[0] == ''): self.Disconnect() return None else: #dt = datetime.datetime.strptime(lu[0], '%Y-%m-%d %H:%M:%S.%f') dt = datetime.fromtimestamp( time.mktime(time.strptime(lu[0], '%Y-%m-%d %H:%M:%S.%f'))) self.Disconnect() return dt
def getOrdersArrayResult(year, month, day): a = "%d-%d-%d 00:00:00" % (year, month, day) startTime = time.mktime(time.strptime(a, '%Y-%m-%d %H:%M:%S')) endTime = startTime + 60 * 60 * 24 - 1 i = 1 url = 'http://www.shanxinhui.com/user/manager/listuseroutgo/p/1.html' request_result = session.get(url, headers=headers, allow_redirects=False) html = request_result.text prefectHtml = html.replace('</td>\n</td>', '</td>') soup = BeautifulSoup(prefectHtml, "html.parser") # soup = BeautifulSoup(login_page.text, "html.parser") # print(soup.find("table")) rowsNumber = soup.find("span", class_="rows") print('----') print(rowsNumber.string) print('----') non_decimal = re.compile(r'[^\d.]+') number = non_decimal.sub('', rowsNumber.string) pageNumber = int(int(number) / 18) + 1 print(int(pageNumber) + 1) n = 1 while n < pageNumber + 1: getHTML(n) n += 1 global allOrders gggArray = [] for dict in allOrders: if dict[3] > startTime and dict[3] < endTime: gggArray.append(dict) print(dict[3]) newArray = [] for array in gggArray: order, newArray = orderById(array[0], newArray) order.number1 = str(int(array[1]) + int(order.number1)) order.number2 = str(int(array[2]) + int(order.number2)) exculeExcel(newArray)
def getHTML(page): url = 'http://www.shanxinhui.com/user/manager/listuseroutgo/p/%d.html' % page request_result = session.get(url, headers=headers, allow_redirects=False) print('html result -------') print(request_result.text) print('html result -------end') html = request_result.text prefectHtml = html.replace('</td>\n</td>', '</td>') soup = BeautifulSoup(prefectHtml, "html.parser") rows = soup.find("table").find_all("tr") dict = {'id': [1, 2]} array = [dict] table = soup.find("table") result = makelist(table) result.pop() result.pop(0) newReuslt = [] for tempArray in result: print(tempArray[5]) newReuslt.append([]) typeString = tempArray[1] timeString = tempArray[5] t_obj = time.strptime(timeString, "%Y-%m-%d %H:%M:%S") ts = time.mktime(t_obj) numberString = tempArray[2] accountString = tempArray[3] newReuslt[-1].insert(0, accountString) if typeString == '善种子': newReuslt[-1].insert(1, numberString) else: newReuslt[-1].insert(1, '0') if typeString == '善心币': newReuslt[-1].insert(2, numberString) else: newReuslt[-1].insert(2, '0') newReuslt[-1].insert(3, ts) print(newReuslt) global allOrders allOrders = allOrders + newReuslt
def insert_bulk_mongo_mesonet(db, data, timestamp): ''' Mesowest header 'STN YYMMDD/HHMM MNET SLAT SLON SELV TMPF SKNT DRCT GUST PMSL ALTI DWPF RELH WTHR P24I' Mesonet header '# id,name,mesonet,lat,lon,elevation,agl,cit,state,country,active' Matching: # id (0) -> STN lat (3) -> SLAT long (4) -> SLON elevation (5) -> SELV ''' for d in data: print d values = d.split(',') # Convert time from 20180316_2145 to 20180316/2145 timestamp.replace('_', '/') #dateTimeObject = datetime.datetime.strptime(values[1], '%Y%m%d/%H%M') #print dateTimeObject pattern = '%Y%m%d/%H%M' time_t = int(time.mktime(time.strptime(timestamp, pattern))) * 1000 print time_t input_data = { "STN":values[0], "timestamp":time_t, "MNET": "NULL", "SLAT":values[3], "SLON":values[4], "SELV":values[5], "TMPF":"NULL", "SKNT":"NULL", "DRCT":"NULL", "GUST":"NULL", "PMSL":"NULL", "ALTI":"NULL", "DWPF":"NULL", "RELH":"NULL", "WTHR":"NULL", "P24I":"NULL" } #print input_data result = db.mesowest.insert_one(input_data) print 'One post: {0}'.format(result.inserted_id)
def update_days(self, tweets): #print tweets for tweet in tweets: #print tweet time_string = re.search(self.time_pattern, tweet).group() post_time = time.strptime(time_string, self.ISOTIMEFORMAT) day = int((time.mktime(post_time) - time.mktime(self.start_time)) / 86400) term_list = self.get_terms( tweet ) #print "day = ", day self.day_cnt_list[ day ] += 1 self.day_doc_list[ day ].update( term_list )
def get_list(self, user_id, value, copy_users): temp_item = {} temp_item['user_id'] = user_id # user_id temp_item['id'] = value.create_uid.id # 创建员工ID temp_item['user_name'] = value.create_uid.name # 创建员工姓名 temp_item['name'] = value.name # 单号 temp_item['company_name'] = value.company_id.name # 公司 temp_item['dept'] = value.subject # 标题 timeArray = time.strptime(str(value.write_date), "%Y-%m-%d %H:%M:%S") timeStamp = int(time.mktime(timeArray)) create_time = timeStamp + 8 * 60 * 60 # 加8个小时 timeArray = time.localtime(create_time) otherStyleTime = time.strftime("%Y-%m-%d %H:%M:%S", timeArray) temp_item['write_date'] = otherStyleTime # 创建更新时间 temp_item['state'] = value.state # 状态 if copy_users: temp_item['copy_users'] = 'yes' # 区别 判断是抄送人还是审批人 else: temp_item['copy_users'] = 'no' # 区别 判断是抄送人还是审批人 return temp_item
def getTweetCountByDate(self,queryargs): """ :param queryargs: :return: """ categories = queryargs.getlist('categoryID') print "categories:", categories tweetCatCount = [] arguments = queryargs.copy() for category in categories: arguments['categoryID'] = category (success, result) = self.getTweets(arguments) #print 'tweetsresult',result catCount = {"key": category, "values":[]} countDict = {} for tweet in result['tweets']: timestamp = tweet['timestamp'] #date = datetime.datetime.fromtimestamp(timestamp/1000).strftime("%B %d, %Y") date = datetime.datetime.fromtimestamp(timestamp/1000).strftime("%d-%b-%y") #print "date:", date if date in countDict.keys(): countDict[date] = countDict[date]+1 else: countDict[date] = 1 for key,value in countDict.items(): key = key+":00:00:00" print "key::", key import time key = time.strptime(key, "%d-%b-%y:%H:%M:%S") key = time.mktime(key) pair = [key,value] catCount['values'].append(pair) tweetCatCount.append(catCount) print "TweetCatCount:::",tweetCatCount return True, tweetCatCount
def exif_getdate(filename): """ Rename <old_filename> with the using the date/time created or modified for the new file name""" created_time = os.path.getctime(filename) modify_time = os.path.getmtime(filename) # f = open(filename, 'rb') try: tags = exif.parse(filename) except UnboundLocalError: print "No EXIF data available for ", file tags = {} exif_time = 0 try: tags['DateTimeOriginal'] exif_time = str(tags['DateTimeOriginal']) exif_time = int( time.mktime(time.strptime(exif_time, "%Y:%m:%d %H:%M:%S"))) except (KeyError, ValueError): print 'No EXIF DateTimeOriginal for ', file exif_time = 0 if created_time < modify_time: local_time = time.localtime(created_time) else: local_time = time.localtime(modify_time) if exif_time: if exif_time < local_time: local_time = time.localtime(exif_time) date_time_name = time.strftime(DATE_FORMAT, local_time) #print 'Created Time = ', created_time #print 'Modified Time = ', modify_time #print 'EXIF Time = ', exif_time #print 'Time Used = ', local_time return date_time_name
def friendtimeV2(timestamp,isTimestamp=True): if not isTimestamp: timestamp = time.mktime(time.strptime(str(timestamp),'%Y-%m-%d %H:%M:%S')) return friendtime(timestamp) it = int(timestamp) + 8*3600 #return datetime.fromtimestamp(it).strftime('%Y-%m-%d %H:%M:%S') if (int(time.time())-it)<31536000: time1 = datetime.fromtimestamp(it) time_diff = (datetime.utcnow() + timedelta(hours =+ 8)) - time1 days = time_diff.days if days: if days > 60: return u'%s月前' % (days / 30) if days > 30: return u'1月前' if days > 14: return u'%s周前' % (days / 7) if days > 7: return u'1周前' if days > 1: return u'%s 天前' % days return u'1天前' seconds = time_diff.seconds if seconds > 7200: return u'%s小时前' % (seconds / 3600) if seconds > 3600: return u'1小时前' if seconds > 120: return u'%s分钟前' % (seconds / 60) if seconds > 60: return u'1分钟前' if seconds > 1: return u'%s秒前' %seconds return u'%s秒前' % seconds else: return datetime.fromtimestamp(it).strftime('%Y-%m-%d %H:%M:%S')
def get_opinion(self, name, shuzi): opinion = request.env['syt.oa.gld.opinion'].sudo().search([ ('gld_id', '=', name) ]) if opinion: opinion_list = [] for value in opinion: item = {} item['id'] = value.approver.id item['name'] = value.approver.name item['opinion'] = value.opinion timeArray = time.strptime(str(value.appov_date), "%Y-%m-%d %H:%M:%S") timeStamp = int(time.mktime(timeArray)) create_time = timeStamp + 8 * 60 * 60 # 加8个小时 timeArray = time.localtime(create_time) otherStyleTime = time.strftime("%Y-%m-%d %H:%M:%S", timeArray) item['time'] = otherStyleTime item['dept'] = value.approver.department_id.name item['company'] = value.approver.company_id.name opinion_list.append(item) return JSONEncoder().encode(opinion_list) else: return "2"
def isLogin(): # 通过查看用户个人信息来判断是否已经登录 print(session.cookies) print('----->') print(session.cookies) print('----->') url = "https://www.baidu.com/" login_page = session.get(url, headers=headers, allow_redirects=True) print(login_page.status_code) print(login_page.text) url = "http://www.shanxinhui.com/user/manager/listuseroutgo/p/1.html" login_page = session.get(url, headers=headers, allow_redirects=False) print(login_page.status_code) print(login_page.text) text = '2016-11-09 10:09:25' t_obj = time.strptime(text, "%Y-%m-%d %H:%M:%S") ts = time.mktime(t_obj) print(t_obj) # y = datetime.strptime(text, '%Y-%m-%d ') # z = datetime.now() # time_tuple = t_obj.timetuple() print(ts)
def calendar_listing(request, ref_type, year, month, day): context = RequestContext(request) tt = time.strptime('%s-%s-%s' % (year, month, day),'%s-%s-%s' % ('%Y', '%m', '%d')) formatted_date = datetime.date(*tt[:3]) if ref_type == "fp": try: date_listings = Event.objects.filter( start_date__year = formatted_date.year, start_date__day = formatted_date.day, start_date__month = formatted_date.month, status=True ) except: date_listings = None return render_to_response("announce/fp_listing.html", { "date_listings":date_listings, "date":formatted_date, } ,context) if ref_type == "widget": try: events = Event.objects.filter( start_date__year = formatted_date.year, start_date__day = formatted_date.day, start_date__month = formatted_date.month, status=True ) except: events = [] try: jobs = Job.objects.filter( deadline__year = formatted_date.year, deadline__day = formatted_date.day, deadline__month = formatted_date.month, status=True ) except: jobs = [] try: opportunities = Opportunity.objects.filter( deadline__year = formatted_date.year, deadline__day = formatted_date.day, deadline__month = formatted_date.month, status=True ) except: opportunities = [] date_listings = sorted(chain(events, opportunities, jobs)) # except: # date_listings = None return render_to_response("announce/widget_listing.html", { "date_listings":date_listings, "date":formatted_date, }, context)
#风机编号为2位数时使用 q = [] for i in zhengdong: s = i date_time = datetime.datetime(year=int(s[17:21]), month=int(s[21:23]), day=int(s[23:25]), hour=int(s[26:28]), minute=int(s[28:30]), second=int(s[30:32])) q.append(date_time.strftime("%Y-%m-%d %H:%M:%S")) #震动信号的时间chuo w = [] import time for i in q: timestamp = int(time.mktime(time.strptime(i, "%Y-%m-%d %H:%M:%S"))) w.append(timestamp) w_scada = data_cancha.loc[:, 'timestape_max'] scada = [] # 对应震动信号的scada数据 zd = [] # 震动信号 for i in w: #读出scada的时间点 down = int(i / 600) * 600 up = (int(i / 600) * 600) + 600 for j in data_cancha.loc[:, 'timestape_max']: if j >= down and j <= up: scada.append(data_cancha[data_cancha.loc[:, 'timestape_max'] == j]) zd.append(int(i)) y1 = pd.concat(scada, axis=0) #符合条件的scada数据
def _lm_to_epoch(self, last_modified_time): # TODO(tierney): May not be useful anymore. return timegm(time.strptime(last_modified_time.replace("Z", ''), u"%Y-%m-%dT%H:%M:%S.000"))
def get_time_stamp(time_str): # 将字符串格式时间转换成时间戳 time_stamp = time.strptime(time_str, '%Y-%m-%d %H:%M:%S') time_stamp = int(time.mktime(time_stamp)) # 获取秒级时间戳 return time_stamp
def to_python(self, value): if self.format == self.FORMAT_EPOCH_SECONDS: return datetime.fromtimestamp(value) else: return time.strptime(value, self.format)
def command_log(*args): if len(args) > 2: raise Exception( "Too many arguments: [ip] [time period in s] (optional parameter)") ip = '' max_ago = float('inf') if len(args) >= 1: ip = args[0] if len(args) == 2: max_ago = float(args[1]) from pyparsing import Word, alphas, Suppress, Combine, nums, string, Optional, Regex, ParseException # define line in (sys)log month = Word(string.uppercase, string.lowercase, exact=3) integer = Word(nums) serverDateTime = Combine(month + " " + integer + " " + integer + ":" + integer + ":" + integer) hostname = Word(alphas + nums + "_" + "-") daemon = Word(alphas + nums + "/" + "-" + "_") + Optional(Suppress("[") + integer + Suppress("]")) + Suppress(":") message = Regex(".*") bnf = serverDateTime + hostname + daemon + message from collections import deque import re, time last_access = {} tail_n = 100 for line in deque(open(logfile_path), tail_n): try: fields = bnf.parseString(line) except ParseException: continue else: m = re.search('requests (\d{1,3}.\d{1,3}.\d{1,3}.\d{1,3})', fields[-1]) if m: #print fields[0], m.group(1) cur = time.localtime() # guess year... st = time.strptime(fields[0] + " %s" % cur.tm_year, "%b %d %H:%M:%S %Y") if st > cur: # ok, re-guess st = time.strptime(fields[0] + " %s" % (cur.tm_year - 1), "%b %d %H:%M:%S %Y") if (st > cur): raise Exception("HMF logfile seems too old!?!") last_access[m.group(1)] = st ips = [key for key in last_access.keys() if ip in key] access_in_period = [((time.mktime(cur) - time.mktime(t)) <= max_ago) for r, t in last_access.items()] if ips and any(access_in_period): print "Previous accesses:" for (resource, timestamp), state in zip(last_access.items(), access_in_period): if not state: continue if not resource in ips: continue print "\t%s was accessed on %s (%.1fs ago)" % ( resource, time.asctime(timestamp), time.mktime(cur) - time.mktime(timestamp)) return EXIT_FAILURE return EXIT_SUCCESS
def parse_local_dt(s): tt = time.strptime(s, '%Y-%m-%d %H:%M:%S')[0:6] return normalize( datetime(tt[0], tt[1], tt[2], tt[3], tt[4], tt[5], 0, local_tz()))
def createTimeStamp(datestr, format="%Y-%m-%d %H:%M:%S"): return time.mktime(time.strptime(datestr, format))
def format_openerp_time(optime): """get the time from openerp string and set in the f*****g outlook way""" opformat = "%m/%d/%y %H:%M:%S" return datetime( *time.strptime(optime, opformat)[0:6]).strftime("%Y-%m-%d %H:%M:%S")
problem = True removedlist.append(subj) if len(removedlist) > 0: insert(y['timestamp'], key, title, auth, y['comment'], rev, "subjects deleted") # Check for removed fields if ("/works/" in key or "/books/" in key) and rev > 1 and not problem: removedfields = [] for field in previousitem: if field == 'id': continue if previousitem[field] != "" and previousitem[field] != [] and previousitem[field] != {} and not currentitem.has_key(field): removedfields.append(field) if not problem: try: t1 = time.strptime(previousitem['last_modified']['value'], '%Y-%m-%dT%H:%M:%S.%f') except ValueError: t1 = time.strptime(previousitem['last_modified']['value'], '%Y-%m-%d %H:%M:%S.%f') try: t2 = time.strptime(currentitem['last_modified']['value'], '%Y-%m-%dT%H:%M:%S.%f') except ValueError: t2 = time.strptime(currentitem['last_modified']['value'], '%Y-%m-%d %H:%M:%S.%f') t3 = calendar.timegm(t1) t4 = calendar.timegm(t2) lastedit = t3 - t4 if lastedit > 600 or lastedit < -600: problem = True if problem: logstring += "Status: fields %s removed from %s\n" % (removedfields, key) insert(y['timestamp'], key, title, auth, y['comment'], rev, "fields removed")
def datetime_format(time_string): format = "%m/%d/%Y %H:%M:%S" return time.strptime(time_string, format)
def isTimeFormat(self,input): try: time.strptime(input, '%H:%M') return True except ValueError: return False
def parse_local_dt(s): tt = time.strptime(s, '%Y-%m-%d %H:%M:%S')[0:6] return normalize(datetime(tt[0], tt[1], tt[2], tt[3], tt[4], tt[5], 0, local_tz()))
def format_openerp_time(optime): """get the time from openerp string and set in the f*****g outlook way""" opformat = "%m/%d/%y %H:%M:%S" return datetime(*time.strptime(optime, opformat)[0:6]).strftime("%Y-%m-%d %H:%M:%S")