【发布时间】: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
我目前能够获得 Trello due date,给我这个字符串:
2018-10-22T16:00:00.000Z
我想以HH:MM:SS 格式作为字符串获取到那时为止的时间。
使用普通的 Lua,我想这不会太难,但是由于限制使用诸如 os.time 之类的东西,我对如何做到这一点感到很困惑。感谢您的帮助!
【问题讨论】:
标签: lua trello roblox lua-patterns
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