--[[
ģƣLuaԴӿڲ
ģ鹦ܣĳЩLuaԴĽӿڣܵ쳣ʱ
ģ޸ʱ䣺2017.02.14
]]

--LuaԴos.timeӿ
local oldostime = os.time

--[[
safeostime
  װԶos.timeӿ
  
		tڱûд룬ʹϵͳǰʱ
ֵtʱ1970110ʱ00
]]
function safeostime(t)
	return oldostime(t) or 0
end

--LuaԴos.timeӿָԶsafeostimeӿ
os.time = safeostime

--LuaԴos.dateӿ
local oldosdate = os.date

--[[
safeosdate
  װԶos.dateӿ
  
		sʽ
		t1970110ʱ00
ֵοLuaԴos.dateӿ˵
]]
function safeosdate(s,t)
    if s == "*t" then
        return oldosdate(s,t) or {year = 2012,
                month = 12,
                day = 11,
                hour = 10,
                min = 9,
                sec = 0}
    else
        return oldosdate(s,t)
    end
end

--LuaԴos.dateӿָԶsafeosdateӿ
os.date = safeosdate

--LuaԴjson.decodeӿ
if json and json.decode then oldjsondecode = json.decode end

--[[
safejsondecode
  װԶjson.decodeӿ
  
		sjsonʽַ
ֵ
		һֵΪjsonַtable
		ڶֵΪ(trueʾɹfalseʧ)
		ֵѡֻеڶֵΪfalseʱ壩ʾϢ
]]
function safejsondecode(s)
	local result,info = pcall(oldjsondecode,s)
	if result then
		return info,true
	else
		return {},false,info
	end
end

--LuaԴjson.decodeӿָԶsafejsondecodeӿ
if json and json.decode then json.decode = safejsondecode end

