Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local modf=math.modf
- local floor=math.floor
- local concat=table.concat
- local format=string.format
- --Date--
- local weekds={"Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"}
- local months={"January","February","March","April","May","June","July","August","September","October","November","December"}
- local daysny={31,28,31,30,31,30,31,31,30,31,30,31}
- local daysly={31,29,31,30,31,30,31,31,30,31,30,31}
- local secs_day=86400
- local function th(n)
- local f=n%10
- local g=n%100
- if f==1 and g~=11 then
- return n.."st"
- elseif f==2 and g~=12 then
- return n.."nd"
- elseif f==3 and g~=13 then
- return n.."rd"
- else
- return n.."th"
- end
- end
- local function tod(pdy,showsec)
- local hr,phr=modf(pdy*24)
- local mn,pmn=modf(phr*60)
- local sec,ms=modf(pmn*60)
- local hrmn=format("%d:%02i",(hr-1)%12+1,mn)..(hr<12 and "AM" or "PM")
- if showsec then
- return hrmn..format(";%02is",sec)
- else
- return hrmn
- end
- end
- local function Date(Unix,abbr)
- local loldays=Unix/secs_day
- local days=loldays
- local ycount=1970
- local mcount=1
- repeat
- if ycount%400==0 or ycount%100~=0 and ycount%4==0 then
- if days>=daysly[mcount] then
- days=days-daysly[mcount]
- else break end
- elseif days>=daysny[mcount] then
- days=days-daysny[mcount]
- else break end
- mcount=mcount+1
- if mcount>#months then
- mcount=1
- ycount=ycount+1
- end
- until ycount>1e4 --just in case
- local d,t=modf(days)
- return concat({tod(t,true),weekds[floor(loldays+3)%7+1],months[mcount],th(d+1),ycount}," ")
- end
- --------
- print(Date(1340197939))
- if tick then
- print(Date(tick()))
- elseif os then
- print(Date(os.time()-8*3600))--PST
- end
Add Comment
Please, Sign In to add comment