【问题标题】:Getting the time in the format HH:MM:SS between the current time and a time from Trello以 HH:MM:SS 格式获取当前时间和来自 Trello 的时间之间的时间
【发布时间】:2019-03-26 23:31:07
【问题描述】:

我目前能够获得 Trello due date,给我这个字符串:

2018-10-22T16:00:00.000Z

我想以HH:MM:SS 格式作为字符串获取到那时为止的时间。

使用普通的 Lua,我想这不会太难,但是由于限制使用诸如 os.time 之类的东西,我对如何做到这一点感到很困惑。感谢您的帮助!

【问题讨论】:

    标签: lua trello roblox lua-patterns


    【解决方案1】:

    string.match 可以提取你的日期和时间,下面的代码会给你一个变量中的每个值来使用。参考:sting.match wiki

    str = "2018-10-22T16:00:00.000Z"
    -- Extract date
    local year, month, day = str:match("(%d+)-(%d+)-(%d+)")
    print(year, month, day) -- 2018, 10, 22
    -- Extract Time
    local hour, min, sec = str:match("(%d+):(%d+):(%d+)")
    print(hour, min, sec) -- 16, 00, 00
    -- or more like your requirement
    print(string.format('%.2d:%.2d:%.2d', hour, min, sec)) -- 16:00:00
    

    【讨论】:

    • 但我的问题是,我如何才能得到从现在到那时的剩余时间?
    • 我愿意:local tTimeOrg = TrelloAPI:GetCardsInList(ListID)[1]["due"] 然后调用function T:GetCardsInList(lid) local url if Private then getAddon() url="https://api.trello.com/1/lists/"..tostring(lid).."/cards"..addon else getAddon() url="https://api.trello.com/1/lists/"..tostring(lid).."/cards"..addon end local re=HS:GetAsync(url,true) local dat=HS:JSONDecode(re) return dat end
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-11-07
    • 2022-01-19
    • 2018-01-28
    相关资源
    最近更新 更多