• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python time.strftime函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中time.strftime函数的典型用法代码示例。如果您正苦于以下问题:Python strftime函数的具体用法?Python strftime怎么用?Python strftime使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: create_statement

    def create_statement(self, cr, uid, line_invoice, partner, amount, journal, date_bank=None, account_id=None):
        bank_stmt_id = self.acc_bank_stmt_model.create(
            cr, uid, {"journal_id": journal, "date": date_bank or time.strftime("%Y") + "-07-01"}
        )

        bank_stmt_line_id = self.acc_bank_stmt_line_model.create(
            cr,
            uid,
            {
                "name": "payment",
                "statement_id": bank_stmt_id,
                "partner_id": partner,
                "amount": amount,
                "date": date_bank or time.strftime("%Y") + "-07-01",
            },
        )

        val = {
            "credit": amount > 0 and amount or 0,
            "debit": amount < 0 and amount * -1 or 0,
            "name": line_invoice and line_invoice.name or "cash flow",
        }

        if line_invoice:
            val.update({"counterpart_move_line_id": line_invoice.id})

        if account_id:
            val.update({"account_id": account_id})

        self.acc_bank_stmt_line_model.process_reconciliation(cr, uid, bank_stmt_line_id, [val])

        move_line_ids_complete = self.acc_bank_stmt_model.browse(cr, uid, bank_stmt_id).move_line_ids

        return move_line_ids_complete
开发者ID:meswapnilwagh,项目名称:odoo-adr,代码行数:34,代码来源:common.py


示例2: recommender

def recommender( recom_count = 25, test_times = 100, hotNode_degree = 60, year_sta = 2011):
    '''
    进行推荐实验,计算结果存储在txt文件中
    @edge_del       随机删掉的边数
    @recom_count    推荐列表大小
    @test_times     实验次数
    @hotNode_degree 定义热点最小邻居数
    '''
    file_input = open('/home/zhenchentl/out.txt','w+')
    file_input_re = open('/home/zhenchentl/out_re.txt','w+')
    file_input.write('recom_count:' + str(recom_count) + '\n')
    file_input.write('test_times:' + str(test_times) + '\n')
    file_input.write('hotNode_degree:' + str(hotNode_degree) + '\n')

    file_input.write('befor get graph time:' + time.strftime('%Y-%m-%d-%H-%M-%S', \
            time.localtime(time.time())) + '\n')
    print 'befor get graph time:' + time.strftime('%Y-%m-%d-%H-%M-%S', \
            time.localtime(time.time()))
    '''get the graph based on the coauhtor relationship'''
    mD = DigraphByYear()
    mDigraph = mD.getDigraph()
    getGraphAttr(mDigraph, file_input)
    file_input.write('after get graph time:' + time.strftime('%Y-%m-%d-%H-%M-%S', \
            time.localtime(time.time())) + '\n')
    print 'after get graph time:' + time.strftime('%Y-%m-%d-%H-%M-%S', \
            time.localtime(time.time()))
    recom_count = 5
    while(recom_count <= 100):
        exp_recom(mDigraph, file_input,file_input_re,recom_count)
        recom_count += 5
    file_input.close()
    file_input_re.close()
开发者ID:helloworld163,项目名称:MVCWalker,代码行数:32,代码来源:main.py


示例3: saveVerbrauchsData

def saveVerbrauchsData(v_wp,v_sz,zs_wp,zs_sz,interval):
  y = time.strftime('%Y', time.localtime())
  m = time.strftime('%m', time.localtime())
  d = time.strftime('%d', time.localtime())
  f = open("/var/lib/heatpumpMonitor/verbrauch.%s-%s-%s" %(y,m,d) , 'a')
  f.write("%s %04d %04d %d %d %d\n" % (time.strftime('%Y %m %d %a %H %H:%M:%S', time.localtime()), v_wp, v_sz, zs_wp,      zs_sz, interval))
  f.close
开发者ID:franke1276,项目名称:heatpump,代码行数:7,代码来源:heatpumpMonitor.py


示例4: delete

    def delete(self, thema, id, beitragID=None):
        discussionpath = "./data/themen/" + thema + "/" + id + ".json"
        with open(discussionpath, "r") as discussionfile:
            discussion = json.load(discussionfile)

        if beitragID == None:
            if discussion["Status"] == "deleted":
                discussion["Status"] = " "
            else:
                discussion["Status"] = "deleted"

            discussion["Bearbeiter"] = cherrypy.session["Benutzername"]
            discussion["Bearbeitet"] = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
        else:
            for post in discussion["Beitraege"]:
                if post["ID"] == beitragID:
                    if post["Status"] == "deleted":
                        post["Status"] = " "
                    else:
                        post["Status"] = "deleted"
                    post["Bearbeiter"] = cherrypy.session["Benutzername"]
                    post["Bearbeitet"] = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())

        with open(discussionpath, "w") as discussionfile:
            json.dump(discussion, discussionfile, indent=4)
开发者ID:fr34kyn01535,项目名称:PyForum,代码行数:25,代码来源:datenbank.py


示例5: run_once

    def run_once(self, test_name):
        if test_name == 'setup':
            return
        #
        # We need to be sure we run this on the right target machines
        # as this is really quite destructive!
        #
        if not os.uname()[1] in self.valid_clients:
            return

        date_start = time.strftime("%Y-%m-%d")
        time_start = time.strftime("%H%M")

        output = ''
        #
        # Test 3 different I/O schedulers:
        #
        for iosched in ['cfq', 'deadline', 'noop']:
            #
            # Test 5 different file systems, across 20+ tests..
            #
            os.chdir(self.fio_tests_dir)
            cmd = './test.sh'
            cmd += ' -d ' + self.dev + '1 -m 8G -S -s ' + iosched + ' -f ext2,ext3,ext4,xfs,btrfs'
            cmd += ' -D ' + date_start + ' -T ' + time_start
            output += utils.system_output(cmd, retain_output=True)

        #
        # Move the results from the src tree into the autotest results tree where it will automatically
        # get picked up and copied over to the jenkins server.
        #
        os.rename(os.path.join(self.srcdir, 'fs-test-proto'), os.path.join(self.resultsdir, 'fs-test-proto'))
开发者ID:kissiel,项目名称:autotest-client-tests,代码行数:32,代码来源:ubuntu_fs_fio_perf.py


示例6: createTestWorkspace

    def createTestWorkspace(self):
        """ Create a workspace for testing against with ideal log values
        """
        from mantid.simpleapi import CreateWorkspace
        from mantid.simpleapi import AddSampleLog
        from time import gmtime, strftime,mktime
        import numpy as np

        # Create a matrix workspace
        x = np.array([1.,2.,3.,4.])
        y = np.array([1.,2.,3.])
        e = np.sqrt(np.array([1.,2.,3.]))
        wksp = CreateWorkspace(DataX=x, DataY=y,DataE=e,NSpec=1,UnitX='TOF')

        # Add run_start
        tmptime = strftime("%Y-%m-%d %H:%M:%S", gmtime(mktime(gmtime())))
        AddSampleLog(Workspace=wksp,LogName='run_start',LogText=str(tmptime))

        tsp_a=kernel.FloatTimeSeriesProperty("SensorA")
        tsp_b=kernel.FloatTimeSeriesProperty("SensorB")
        tsp_c=kernel.FloatTimeSeriesProperty("SensorC")
        for i in arange(25):
            tmptime = strftime("%Y-%m-%d %H:%M:%S", gmtime(mktime(gmtime())+i))
            tsp_a.addValue(tmptime, 1.0*i*i)
            tsp_b.addValue(tmptime, 2.0*i*i)
            tsp_c.addValue(tmptime, 3.0*i*i)

        wksp.mutableRun()['SensorA']=tsp_a
        wksp.mutableRun()['SensorB']=tsp_b
        wksp.mutableRun()['SensorC']=tsp_c

        return wksp
开发者ID:mducle,项目名称:mantid,代码行数:32,代码来源:ExportSampleLogsToCSVFileTest.py


示例7: cmd_list

  def cmd_list(self, args):
    """
    @G%(name)[email protected] - @B%(cmdname)[email protected]
      list timers and the plugins they are defined in
      @[email protected]: list
    """
    tmsg = []

    match = args['match']

    tmsg.append('Local time is: %s' % time.strftime('%a %b %d %Y %H:%M:%S',
                                                    time.localtime()))

    tmsg.append('%-20s : %-13s %-9s %-8s %s' % ('Name', 'Defined in',
                                                'Enabled', 'Fired', 'Next Fire'))
    for i in self.timerlookup:
      if not match or match in i:
        timerc = self.timerlookup[i]
        tmsg.append('%-20s : %-13s %-9s %-8s %s' % (
            timerc.name, timerc.plugin.sname,
            timerc.enabled, timerc.timesfired,
            time.strftime('%a %b %d %Y %H:%M:%S',
                          time.localtime(timerc.nextcall))))

    return True, tmsg
开发者ID:endavis,项目名称:bastproxy,代码行数:25,代码来源:timers.py


示例8: handle

 def handle(self, data, fulltext, tokens, slackclient, channel, user):
     slackclient.post_message(channel, 'UTC: `' + time.strftime('%Y/%m/%d-%H:%M:%S', time.gmtime(self._epoch)) + '`')
     if self._additional_location and 'modules.google_tz_handler' in sys.modules:
         handler_module = sys.modules['modules.google_tz_handler']
         handler_class = getattr(handler_module, 'google_tz_handler')
         handler_instance = handler_class(self._config)
         slackclient.post_message(channel, self._additional_location + ': `' + time.strftime('%Y/%m/%d-%H:%M:%S', time.gmtime(handler_instance.get_raw_local_time(handler_instance.get_cities(self._additional_location.replace(' ', '+'))[0], self._epoch))) + '`')
开发者ID:bkchan,项目名称:slacker,代码行数:7,代码来源:epoch_handler.py


示例9: do_export

        def do_export(_):
            left_idx = g_pool.seek_control.trim_left
            right_idx = g_pool.seek_control.trim_right
            export_range = left_idx, right_idx + 1  # exclusive range.stop
            export_ts_window = pm.exact_window(g_pool.timestamps, (left_idx, right_idx))

            export_dir = os.path.join(g_pool.rec_dir, "exports")
            export_dir = next_export_sub_dir(export_dir)

            os.makedirs(export_dir)
            logger.info('Created export dir at "{}"'.format(export_dir))

            export_info = {
                "Player Software Version": str(g_pool.version),
                "Data Format Version": meta_info["Data Format Version"],
                "Export Date": strftime("%d.%m.%Y", localtime()),
                "Export Time": strftime("%H:%M:%S", localtime()),
                "Frame Index Range:": g_pool.seek_control.get_frame_index_trim_range_string(),
                "Relative Time Range": g_pool.seek_control.get_rel_time_trim_range_string(),
                "Absolute Time Range": g_pool.seek_control.get_abs_time_trim_range_string(),
            }
            with open(os.path.join(export_dir, "export_info.csv"), "w") as csv:
                write_key_value_file(csv, export_info)

            notification = {
                "subject": "should_export",
                "range": export_range,
                "ts_window": export_ts_window,
                "export_dir": export_dir,
            }
            g_pool.ipc_pub.notify(notification)
开发者ID:pupil-labs,项目名称:pupil,代码行数:31,代码来源:player.py


示例10: exec_cmd_servers

def exec_cmd_servers(username):
    print '\nInput the \033[32mHost IP(s)\033[0m,Separated by Commas, q/Q to Quit.\n'
    while True:
        hosts = raw_input('\033[1;32mip(s)>: \033[0m')
        if hosts in ['q', 'Q']:
            break
        hosts = hosts.split(',')
        hosts.append('')
        hosts = list(set(hosts))
        hosts.remove('')
        ip_all, ip_all_dict = ip_all_select(username)
        no_perm = set(hosts)-set(ip_all)
        if no_perm:
            print "You have NO PERMISSION on %s..." % list(no_perm)
            continue
        print '\nInput the \033[32mCommand\033[0m , The command will be Execute on servers, q/Q to quit.\n'
        while True:
            cmd = raw_input('\033[1;32mCmd(s): \033[0m')
            if cmd in ['q', 'Q']:
                break
            exec_log_dir = os.path.join(log_dir, 'exec_cmds')
            if not os.path.isdir(exec_log_dir):
                os.mkdir(exec_log_dir)
                os.chmod(exec_log_dir, 0777)
            filename = "%s/%s.log" % (exec_log_dir, time.strftime('%Y%m%d'))
            f = open(filename, 'a')
            f.write("DateTime: %s User: %s Host: %s Cmds: %s\n" %
                    (time.strftime('%Y/%m/%d %H:%M:%S'), username, hosts, cmd))
            for host in hosts:
                remote_exec_cmd(host, username, cmd)
开发者ID:Nexpro,项目名称:jumpserver,代码行数:30,代码来源:jumpserver.py


示例11: strftime

def strftime(dt, fmt):
    if dt.year >= 1900:
        return super(type(dt), dt).strftime(fmt)
    illegal_formatting = _illegal_formatting.search(fmt)
    if illegal_formatting:
        msg = 'strftime of dates before 1900 does not handle {0}'
        raise TypeError(msg.format(illegal_formatting.group(0)))

    year = dt.year
    # for every non-leap year century, advance by
    # 6 years to get into the 28-year repeat cycle
    delta = 2000 - year
    off = 6 * (delta // 100 + delta // 400)
    year += off

    # move to around the year 2000
    year += ((2000 - year) // 28) * 28
    timetuple = dt.timetuple()
    s1 = time.strftime(fmt, (year,) + timetuple[1:])
    sites1 = _findall(s1, str(year))

    s2 = time.strftime(fmt, (year + 28,) + timetuple[1:])
    sites2 = _findall(s2, str(year + 28))

    sites = []
    for site in sites1:
        if site in sites2:
            sites.append(site)

    s = s1
    syear = "%04d" % (dt.year,)
    for site in sites:
        s = s[:site] + syear + s[site + 4:]
    return s
开发者ID:bessl,项目名称:faker-1,代码行数:34,代码来源:datetime_safe.py


示例12: banIP

def banIP(IP, dport, service, timer = BANTIMER):
    """Returns 1 if IP is already BANNED/UNBANNED
       Returns 0 if BANNED/UNBANNED successfully
    """

    print 'banIP:'
    if (IP, service) in bannedIPs:
        print 'IP:' + IP + 'is already BANNED'
        logging.info('IP:' + IP + 'is already BANNED')
        return 1
    else:
        ip = bannedIP(IP, time.time(), service, timer)
        chain = iptc.Chain(iptc.Table(iptc.Table.FILTER), "INPUT")
        ip.rule = iptc.Rule(chain=chain)
        ip.rule.src = ip.IP + "/255.255.255.255"
        ip.rule.protocol = "tcp"
        ip.rule.target = iptc.Target(ip.rule, "REJECT")
        ip.rule.target.reject_with = "icmp-admin-prohibited"
        match = iptc.Match(ip.rule,"tcp")
        match.dport = dport
        ip.rule.add_match(match)
        bannedIPs[(ip.IP, service)] = ip
        chain.insert_rule(ip.rule)
        print 'IP:' + ip.IP + ' BANNED at ' + time.strftime("%b %d %H:%M:%S")
        logging.info('IP:' + ip.IP + ' BANNED at ' + time.strftime("%b %d %H:%M:%S"))
        resp = {"action": BANNEDIP, "data":{"IP":ip.IP, "time":time.strftime("%b %d %H:%M:%S", time.localtime(ip.time)), "timer":ip.timer, "service":ip.service}}
        server.send_message_to_all(json.dumps(resp))
开发者ID:vpshastry,项目名称:systemsecurity,代码行数:27,代码来源:ips.py


示例13: set_filter_date

    def set_filter_date(self):

        dialog = xbmcgui.Dialog()
        if self.start_date == '':
            self.start_date = str(datetime.datetime.now())[:10]
        if self.end_date == '':
            self.end_date = str(datetime.datetime.now())[:10]

        try:
            d = dialog.numeric(1, common.getstring(30117) ,strftime("%d/%m/%Y",strptime(self.start_date,"%Y-%m-%d")) )
            if d != '':    
                self.start_date = strftime("%Y-%m-%d",strptime(d.replace(" ","0"),"%d/%m/%Y"))
            else:
                self.start_date =''
            common.log('', str(self.start_date))
            
            d = dialog.numeric(1, common.getstring(30118) ,strftime("%d/%m/%Y",strptime(self.end_date,"%Y-%m-%d")) )
            if d != '':
                self.end_date = strftime("%Y-%m-%d",strptime(d.replace(" ","0"),"%d/%m/%Y"))
            else:
                self.end_date =''
            common.log('', str(self.end_date))
        except:
            pass

        if self.start_date != '' or self.end_date != '':
            self.getControl( BUTTON_DATE ).setLabel( self.start_date + ' ... ' + self.end_date )
        else:
            self.getControl( BUTTON_DATE ).setLabel( common.getstring(30164) )
        self.getControl( BUTTON_DATE ).setVisible(False)
        self.getControl( BUTTON_DATE ).setVisible(True)        
开发者ID:Perilin,项目名称:plugin.image.mypicsdb,代码行数:31,代码来源:filterwizard.py


示例14: lastlogExit

 def lastlogExit(self):
     starttime = time.strftime("%a %b %d %H:%M", time.localtime(self.logintime))
     endtime = time.strftime("%H:%M", time.localtime(time.time()))
     duration = utils.durationHuman(time.time() - self.logintime)
     f = file("%s/lastlog.txt" % self.env.cfg.get("honeypot", "data_path"), "a")
     f.write("root\tpts/0\t%s\t%s - %s (%s)\n" % (self.clientIP, starttime, endtime, duration))
     f.close()
开发者ID:RyanKung,项目名称:cowrie,代码行数:7,代码来源:protocol.py


示例15: _format_data

 def _format_data(self, start_time, timestamp, name, units, values):
     fields = _fields[:]
     file_timestamp = time.strftime('%Y%m%d%H%M',time.gmtime(start_time))
     value_timestamp = time.strftime('%Y%m%d%H%M',time.gmtime(timestamp))
     fields[_field_index['units']] = units
     fields[_field_index['commodity']] = self.commodity
     meter_id = name + '|1'
     if units:
         meter_id += '/%s' % units
     fields[_field_index['meter_id']] = meter_id
     fields[_field_index['receiver_id']] = ''
     fields[_field_index['receiver_customer_id']] = self.customer_name + '|' + self.account_name
     fields[_field_index['timestamp']] = file_timestamp
     # interval put into "MMDDHHMM" with MMDD = 0000
     fields[_field_index['interval']] = '0000%02d%02d' % (self.period / 3600, (self.period % 3600) / 60)
     fields[_field_index['count']] = str(len(values))
     value_sets =  []
     for value in values:
         try:
             value = '%f' % value
             protocol_text = ''
         except ValueError:
             value = ''
             protocol_text = 'N'
         value_set = (value_timestamp, protocol_text, value)
         value_sets.append(string.join(value_set, ','))
         value_timestamp = ''
     fields[_field_index['interval_data']] = string.join(value_sets, ',')
     return string.join(fields, ',')
开发者ID:mcruse,项目名称:monotone,代码行数:29,代码来源:cmep_formatter.py


示例16: watchRunFolder

def watchRunFolder(run,sleep):
    """
    Args:
    run -> A folder that contains an RTAcomplete.txt

    Method: The file will be polled every hour. If the first line is not the same as the last time it checked it will kick out and run the rest
            of the BCL pipeline
    """

    RTAcomplete = run +"/RTAComplete.txt"
    iteration = 0

    while True:

        if not os.path.isfile(RTAcomplete):
            print("Real Time Analysis has not begun yet. Time: %s" % time.strftime("%m-%d-%y %H:%M:%S",time.localtime()))
        
        else:
            with open(RTAcomplete,"r") as input_file:
                first_line = input_file.readline().strip()

                if not first_line:
                    print("Real Time Analysis in process. Time %s" % time.strftime("%m-%d-%y %H:%M:%S",time.localtime()))

                else:
                    print("Checked file at %s and the RTAComplete.txt shows that RTA has finished" % time.strftime("%m-%d-%y %H:%M:%S",time.localtime()))
                    print("Moving on to Bcl Analysis")
                    break

        time.sleep(sleep)
开发者ID:joenery,项目名称:BclPipeline,代码行数:30,代码来源:BclPipeline.py


示例17: FullTextQuery

def FullTextQuery(calendar_service):
    print 'Full text query for events on Primary Calendar: \'%s\'' % (q)
    query = GServ.CalendarEventQuery(calendar, 'private', 'full', q)
    query.start_min = date       #  calling date to set the beginning of query range for the present day
    query.start_max = endDate    #  calling endDate to limit the query range to the next 14 days. change tmedelta(days) to set the range
    query.singleevents = 'true'  #  enables creation of repeating events
    query.orderBy = 'startTime'  #  sort by event start time
    query.sortorder = 'a'        #  sort order: ascending
    feed = calendar_service.CalendarQuery(query)
    for i, an_event in enumerate(feed.entry):
        for a_when in an_event.when:
            print " "
            print an_event.title.text ,"Scheduled:",i,"For:",time.strftime('%d-%m-%Y %H:%M',time.localtime(tf_from_timestamp(a_when.start_time))),"Current Time:",time.strftime('%d-%m-%Y %H:%M')
            if time.strftime('%d-%m-%Y %H:%M',time.localtime(tf_from_timestamp(a_when.start_time))) == time.strftime('%d-%m-%Y %H:%M'):
                print "Waking you up!"
                print "---" 
                songfile = random.choice(os.listdir(mp3_path)) #  choosing by random an .mp3 file from direcotry
                print "Now Playing:", songfile
                                                               #  plays the MP3 in it's entierty. As long as the file is longer 
                                                               #  than a minute it will only be played once:
                command ="mpg321" + " " + mp3_path + "'"+songfile+"'"+ " -g 100" 
                print command
                os.system(command)                             #  plays the song
            else:
                print "Wait for it..."                         #  the event's start time is not the system's current time
开发者ID:lucaschain,项目名称:SimpleGoogleAlarmClock,代码行数:25,代码来源:wakeup.py


示例18: assignmentsHTML

def assignmentsHTML():
	html = ""
	bytes = 0
	for i in assignments:
		fdata = os.stat(i[1])
		# Get last modified date, and format to DOS format
		mdate = time.strftime("%m-%d-%y", time.localtime(fdata.st_mtime))
		# Get last modified time, and format to DOS format
		mtime = time.strftime("%I", time.localtime(fdata.st_mtime)).strip("0") + \
		        time.strftime(":%M", time.localtime(fdata.st_mtime)) + \
		        time.strftime("%p", time.localtime(fdata.st_mtime)).lower()[0]
		# Get file size, and format to DOS format
		fsize = '{:,}'.format(fdata.st_size)
		elem = '{}{:>13}{:>9}{:>8}'.format(a('{:<21}'.format(i[0]), i[1]), fsize, mdate, mtime)
		html = html + elem + "\n"

		bytes = bytes + os.path.getsize(i[1])

	files = len(assignments)
	free = 8589869056 - bytes

        html = html + '{:>18} file(s){:>14,} bytes\n'.format(files, bytes)
        html = html + '{:>40} bytes free\n'.format('{:,}'.format(free))


	return html
开发者ID:Rybec,项目名称:cs313,代码行数:26,代码来源:assignments.py


示例19: _fix_review_dates

    def _fix_review_dates(self, item):
        ''' Convert dates so ES detect them '''


        for date_field in ['timestamp','createdOn','lastUpdated']:
            if date_field in item.keys():
                date_ts = item[date_field]
                item[date_field] = time.strftime('%Y-%m-%dT%H:%M:%S',
                                                  time.localtime(date_ts))
        if 'patchSets' in item.keys():
            for patch in item['patchSets']:
                pdate_ts = patch['createdOn']
                patch['createdOn'] = time.strftime('%Y-%m-%dT%H:%M:%S',
                                                   time.localtime(pdate_ts))
                if 'approvals' in patch:
                    for approval in patch['approvals']:
                        adate_ts = approval['grantedOn']
                        approval['grantedOn'] = \
                            time.strftime('%Y-%m-%dT%H:%M:%S',
                                          time.localtime(adate_ts))
        if 'comments' in item.keys():
            for comment in item['comments']:
                cdate_ts = comment['timestamp']
                comment['timestamp'] = time.strftime('%Y-%m-%dT%H:%M:%S',
                                                     time.localtime(cdate_ts))
开发者ID:pombredanne,项目名称:GrimoireELK,代码行数:25,代码来源:gerrit.py


示例20: _createSearchRequest

    def _createSearchRequest(self, search=None, tags=None,
                             notebooks=None, date=None,
                             exact_entry=None, content_search=None):

        request = ""
        if notebooks:
            for notebook in tools.strip(notebooks.split(',')):
                if notebook.startswith('-'):
                    request += '-notebook:"%s" ' % tools.strip(notebook[1:])
                else:
                    request += 'notebook:"%s" ' % tools.strip(notebook)

        if tags:
            for tag in tools.strip(tags.split(',')):

                if tag.startswith('-'):
                    request += '-tag:"%s" ' % tag[1:]
                else:
                    request += 'tag:"%s" ' % tag

        if date:
            date = tools.strip(date.split('-'))
            try:
                dateStruct = time.strptime(date[0] + " 00:00:00", "%d.%m.%Y %H:%M:%S")
                request += 'created:%s ' % time.strftime("%Y%m%d", time.localtime(time.mktime(dateStruct)))
                if len(date) == 2:
                    dateStruct = time.strptime(date[1] + " 00:00:00", "%d.%m.%Y %H:%M:%S")
                request += '-created:%s ' % time.strftime("%Y%m%d", time.localtime(time.mktime(dateStruct) + 60 * 60 * 24))
            except ValueError, e:
                out.failureMessage('Incorrect date format in --date attribute. '
                                   'Format: %s' % time.strftime("%d.%m.%Y", time.strptime('19991231', "%Y%m%d")))
                return tools.exitErr()
开发者ID:khapota,项目名称:geeknote,代码行数:32,代码来源:geeknote.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python time.strptime函数代码示例发布时间:2022-05-27
下一篇:
Python time.split函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap