2019独角兽企业重金招聘Python工程师标准>>>
今天接到运营需求:"查询从当日0点 - 当前时间的所有战绩"
于是一个生成凌晨与午夜时间戳的函数应运而生!哎....大家随意看看吧....
-- 返回今日凌晨与午夜时间
local function time( ... )local os_time = os.timelocal str = os.date("%Y-%m-%d", os_time())local early_morning = {hour=0, min=0, sec=0}local midnight = {hour=23, min=59, sec=59}string.gsub(str, "(%d+)-(%d+)-(%d+)", function(year, month, day)midnight["year"] = yearearly_morning["year"] = yearmidnight["month"] = monthearly_morning["month"] = monthmidnight["day"] = dayearly_morning["day"] = dayend)return os_time(early_morning), os_time(midnight)
end