system.py 文件源码

python
阅读 29 收藏 0 点赞 0 评论 0

项目:Python-Plex-Controller 作者: MoeFwacky 项目源码 文件源码
def timechecker(thing):
    thing = thing.lower()
    thing = thing.replace("now + ","now+")
    if ("now+" in thing):
        import datetime
        thing = thing.replace("now+","")
        if ("m" in thing):

                        thing = thing.replace("m","")
                        thing = int(thing)
                        now = datetime.datetime.now()
                        thing = str(now + datetime.timedelta(minutes = thing))
        elif ("h" in thing):
            thing = thing.replace("h","")
            thing = int(thing)
            now = datetime.datetime.now()
            thing = str(now + datetime.timedelta(hours = thing))

        thing = thing.split(" ")
        thing = thing[1]
        thing = thing.split(":")
        hr = thing[0]
        min = thing[1]
        thing = hr + ":" + min

    if (" am" in thing):
        thing = thing.replace(" am"," AM")
    if (" pm" in thing):
        thing = thing.replace(" pm"," PM")
    cck = thing
    cck = thing.split(":")
    cck = thing[0]
    if ((cck > 0) and ("am" not in thing.lower()) and ("pm" not in thing.lower())):
        #print ("Given 24hr time. Converting...")
        from datetime import datetime
        d = datetime.strptime(thing, "%H:%M")
        thedate = d.strftime("%-I:%M %p")
    else:
        thedate = thing
    return thedate
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号