當前位置: 首頁>>代碼示例>>Python>>正文


Python DateService.convertTime方法代碼示例

本文整理匯總了Python中semantic.dates.DateService.convertTime方法的典型用法代碼示例。如果您正苦於以下問題:Python DateService.convertTime方法的具體用法?Python DateService.convertTime怎麽用?Python DateService.convertTime使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在semantic.dates.DateService的用法示例。


在下文中一共展示了DateService.convertTime方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: handle_read

# 需要導入模塊: from semantic.dates import DateService [as 別名]
# 或者: from semantic.dates.DateService import convertTime [as 別名]
def handle_read(text, mic, profile):
    mic.say(random.choice([
        "I am contacting Apple. Please stand by.",
        "Opening that file. Please wait."
    ]))
    api = app_utils.iCloud(profile)
    rem = api.reminders
    listname = find_list(text, profile, rem)
    if not listname:
        mic.say(random.choice([
            "I'm sorry, I couldn't find that list",
            "That list does not seem to be availble. Please check!"
        ]))
        return

    service = DateService()
    ans = random.choice([
        "I've found the following entries: ",
        "Your " + listname + " list contains ",
        "These are the entries of the " + listname + " list "
    ])
    for i in range(len(rem.lists[listname])):
        reminder = rem.lists[listname][i]
        ans += str(i+1) + ') ' + reminder['title']
        if reminder['due']:
            ans += ', due at ' + service.convertTime(reminder['due'])
        ans += '.'

    ans += random.choice([
        "",
        "That's it.",
        "There is nothing else on your list."
    ])
    mic.say(ans)
開發者ID:yannickulrich,項目名稱:IRIS,代碼行數:36,代碼來源:reminders.py

示例2: handle

# 需要導入模塊: from semantic.dates import DateService [as 別名]
# 或者: from semantic.dates.DateService import convertTime [as 別名]
def handle(text, mic, profile):

    tz = getTimezone(profile)
    now = datetime.datetime.now(tz=tz)
    service = DateService()
    response = service.convertTime(now)
    mic.say("It is %s right now." % response)
開發者ID:jasonkuehl,項目名稱:jasper-modules,代碼行數:9,代碼來源:Time.py

示例3: handle

# 需要導入模塊: from semantic.dates import DateService [as 別名]
# 或者: from semantic.dates.DateService import convertTime [as 別名]
def handle(text, mic, profile):

    tz = getTimezone(profile)
    now = datetime.datetime.now(tz=tz)
    service = DateService()
    response = service.convertTime(now)
    root = Tk()
    root.wm_title("Mirror")
    w, h = root.winfo_screenwidth(), root.winfo_screenheight()
    root.overrideredirect(1)
    root.geometry("%dx%d+0+0" % (w, h))
    root.focus_set()
    root.bind("1", root.quit())
    root.config(background="#000000")

    mainFrame = Frame(root, width=w, height=h)
    mainFrame.grid(row=0, column=0, padx=10, pady=2)
    mainFrame.config(background="#000000")
    customFont = tkFont.Font(family="Helvetica", size=60)

    timeVar = StringVar()
    timeVar.set(response)
    weatherVar = StringVar()
    weatherVar.set("76°")
    timeLabel = Label(mainFrame, textvariable=timeVar, font=customFont, fg="white", bg="black")
    weatherLabel = Label(mainFrame, textvariable=weatherVar, font=customFont, fg="white", bg="black")
    timeLabel.place(relx=1, x=-2, y=2, anchor=NE)
    weatherLabel.place(relx=0, x=-2, y=2, anchor=NW)
    root.mainloop()
開發者ID:jqk1032,項目名稱:Reflekt,代碼行數:31,代碼來源:BootGUI.py

示例4: handle

# 需要導入模塊: from semantic.dates import DateService [as 別名]
# 或者: from semantic.dates.DateService import convertTime [as 別名]
def handle(mic):
    c=datetime.datetime.now()
    con = mdb.connect('localhost', 'root', 'whyte', 'jarvis')
    cur=con.cursor()
    cur.execute("select * from notif where date > '"+str(c)+"' order by date limit 5")
    temp=cur.fetchall()
    service = DateService()
    
    for item in temp:
    	time = service.convertTime(item[2])
    	mic.say(str(item[1])+" on "+str(time))
    con.close()
開發者ID:sudhinsr,項目名稱:jarvis,代碼行數:14,代碼來源:notifications.py

示例5: handle

# 需要導入模塊: from semantic.dates import DateService [as 別名]
# 或者: from semantic.dates.DateService import convertTime [as 別名]
def handle(text, sender, receiver, profile):
    """
        Reports the current time based on the user's timezone.

        Arguments:
        text -- user-input, typically transcribed speech
        mic -- used to interact with the user (for both input and output)
        profile -- contains information related to the user (e.g., phone number)
    """

    tz = getTimezone(profile)
    now = datetime.datetime.now(tz=tz)
    service = DateService()
    response = service.convertTime(now)
    sender.say("It is %s right now." % response)
開發者ID:clusterfudge,項目名稱:jasper-client,代碼行數:17,代碼來源:Time.py

示例6: handle

# 需要導入模塊: from semantic.dates import DateService [as 別名]
# 或者: from semantic.dates.DateService import convertTime [as 別名]
    def handle(self, text, teller, mic, profile):
        """
            Reports the current time based on the user's timezone.

            Arguments:
            text -- user-input, typically transcribed speech
            mic -- used to interact with the user (input)
            profile -- contains information related to the user (e.g., phone number)
        """

        tz = getTimezone(profile)
        now = datetime.datetime.now(tz=tz)
        service = DateService()
        response = service.convertTime(now)
        teller.say("Il est %s." % response)
開發者ID:KenN7,項目名稱:jasper-client,代碼行數:17,代碼來源:time.py

示例7: handle

# 需要導入模塊: from semantic.dates import DateService [as 別名]
# 或者: from semantic.dates.DateService import convertTime [as 別名]
def handle(text, mic, profile):
    """
        Reports the current date based on the user's location.

        Arguments:
        text -- user-input, typically transcribed speech
        mic -- used to interact with the user (for both input and output)
        profile -- contains information related to the user (e.g., phone
                   number)
    """

    tz = getTimezone(profile)
    now = datetime.datetime.now(tz=tz)
    service = DateService()
    response = service.convertTime(now)
    day = (time.strftime("%A")) 
    month = (time.strftime("%B"))   
    num_day = (time.strftime("%d"))  
    message = "It is " + day + "the " + num_day + "today, get over karishma" 
    mic.say(message)
開發者ID:cpatchava,項目名稱:brainiac,代碼行數:22,代碼來源:Alarm.py

示例8: handle

# 需要導入模塊: from semantic.dates import DateService [as 別名]
# 或者: from semantic.dates.DateService import convertTime [as 別名]
def handle(text, mic, profile):
    """
        Reports the current time based on the user's timezone.

        Arguments:
        text -- user-input, typically transcribed speech
        mic -- used to interact with the user (for both input and output)
        profile -- contains information related to the user (e.g., phone
                   number)
    """

    tz = getTimezone(profile)
    now = datetime.datetime.now(tz=tz)
    service = DateService()
    response = service.convertTime(now)
    d = datetime.datetime.strptime(response, "%I:%M %p")
    response = d.strftime("%H:%M")
    response = re.sub(r'00:', 'minuit ', response)
    response = re.sub(r'12:', 'midi ', response)
    mic.say("Il est %s." % response)
開發者ID:overflOw11,項目名稱:lola,代碼行數:22,代碼來源:Time.py

示例9: handle

# 需要導入模塊: from semantic.dates import DateService [as 別名]
# 或者: from semantic.dates.DateService import convertTime [as 別名]
def handle(text, mic, profile, wxbot=None):
    """
        Reports the current time based on the user's timezone.

        Arguments:
        text -- user-input, typically transcribed speech
        mic -- used to interact with the user (for both input and output)
        profile -- contains information related to the user (e.g., phone
                   number)
        wxBot -- wechat robot
    """

    tz = getTimezone(profile)
    now = datetime.datetime.now(tz=tz)
    service = DateService()
    response = service.convertTime(now)
    if "AM" in response:
        response = u"上午" + response.replace("AM", "")
    elif "PM" in response:
        response = u"下午" + response.replace("PM", "")
    mic.say(u"現在時間是 %s " % response)
開發者ID:jxgmy,項目名稱:dingdang-robot,代碼行數:23,代碼來源:Time.py

示例10: handle

# 需要導入模塊: from semantic.dates import DateService [as 別名]
# 或者: from semantic.dates.DateService import convertTime [as 別名]
def handle(self, text, mic, profile):
    """
        Reports the current time based on the user's timezone.

        Arguments:
        text -- user-input, typically transcribed speech
        mic -- used to interact with the user (for both input and output)
        profile -- contains information related to the user (e.g., phone
                   number)
    """

    tz = getTimezone(profile)
    now = datetime.datetime.now(tz=tz)
    service = DateService()
    response = service.convertTime(now)

    self.blittxt(response, 150, white, black)


    
    mic.say("It is %s right now master." % response)
    time.sleep(1)    
開發者ID:DarthToker,項目名稱:jasper-client,代碼行數:24,代碼來源:Time2.py

示例11: handle

# 需要導入模塊: from semantic.dates import DateService [as 別名]
# 或者: from semantic.dates.DateService import convertTime [as 別名]
def handle(mic):
    
    now = datetime.datetime.now()
    service = DateService()
    response = service.convertTime(now)
    mic.say("It is %s right now." % response)
開發者ID:sudhinsr,項目名稱:jarvis,代碼行數:8,代碼來源:Time.py

示例12: GUI

# 需要導入模塊: from semantic.dates import DateService [as 別名]
# 或者: from semantic.dates.DateService import convertTime [as 別名]
class GUI(threading.Thread):

  def __init__(self):

    self.profile_path = jasperpath.config('profile.yml')
    if os.path.exists(self.profile_path):
      with open(self.profile_path, 'r') as f:
        self.profile = yaml.safe_load(f)

    threading.Thread.__init__(self)
    self.start()

  def callback(self):
    self.root.quit()

  def task(self):
    self.tz = getTimezone(self.profile)
    self.now = datetime.datetime.now(tz=self.tz)
    self.service = DateService()
    self.response = self.service.convertTime(self.now)
    self.timeVar.set(self.response)
    self.numFiles = len([name for name in os.listdir(self.directory) if os.path.isfile(os.path.join(self.directory, name))])
    if self.numFiles > self.numFileHolder:
      self.showPicture()
      print ("OLD: " + str(self.numFileHolder) + "NEW: " + str(self.numFiles))
      self.numFileHolder = self.numFiles
    self.forecast = None
    if 'wmo_id' in self.profile:
      self.forecast = get_forcast_by_wmo_id(str(self.profile['wmo_id']))
    elif 'location' in self.profile:
      self.forecast = get_forecast_by_name(str(self.profile['location']))

    self.temp = self.forecast[0]['summary_detail']['value'][13:17] + unichr(176)
    self.weatherVar.set(self.temp) 
    self.root.after(2000, self.task)
  def showPicture(self):
    self.newest = max(glob.iglob('Pictures/*.jpg'), key = os.path.getctime)
    print ("NEWEST: " + self.newest)
    self.photo = ImageTk.PhotoImage(Image.open(self.newest))
    self.x = self.canvas.create_image(self.w/2, self.h/2, image=self.photo)
    self.canvas.itemconfigure(self.x, state=NORMAL)
    self.canvas.update_idletasks()
    time.sleep(3)
    self.canvas.itemconfigure(self.x, state=HIDDEN)
  def run(self):

    self.root = Tk()
    self.root.protocol("WM_DELETE_WINDOW", self.callback)
    self.w, self.h = self.root.winfo_screenwidth(), self.root.winfo_screenheight()
    #self.w, self.h = 500, 500
    self.root.overrideredirect(1)
    self.root.geometry("%dx%d+0+0" % (self.w, self.h))
    self.root.focus_set()
    self.root.bind("1", self.root.quit())
    self.root.config(background = "#000000")

    mainFrame = Frame(self.root, width=self.w, height=self.h)
    mainFrame.grid(row=0, column=0, padx=10, pady=2)
    mainFrame.config(background= "#000000")
    customFont = tkFont.Font(family="Helvetica", size=60)
    self.timeVar = StringVar()
    self.weatherVar = StringVar()
    self.canvas = Canvas(mainFrame, width=1080, height=1920, highlightthickness=0)
    timeLabel = Label(mainFrame, textvariable=self.timeVar, font=customFont, fg="white", bg="black")
    weatherLabel = Label(mainFrame, textvariable=self.weatherVar, font=customFont, fg="white", bg="black")
 
    self.canvas.config(background="#000000")
    self.canvas.place(relx=0.5, rely=0.5, anchor=CENTER)
    self.directory = '/home/pi/jasper/Pictures'
    self.numFileHolder = len([name for name in os.listdir(self.directory) if os.path.isfile(os.path.join(self.directory, name))])
    print "NUMFILEHOLDER: " + str(self.numFileHolder)
    timeLabel.place(relx=1, x=-2, y=2, anchor=NE)
    weatherLabel.place(relx=0, x=-2, y=2, anchor=NW)
    self.root.after(2000, self.task)
    self.root.mainloop()
開發者ID:jqk1032,項目名稱:Reflekt,代碼行數:77,代碼來源:GUI.py


注:本文中的semantic.dates.DateService.convertTime方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。