PtokaX forum

Archive => Archived 4.0 boards => Finished Lua 4 scripts => Topic started by: [SLUT]Blackbirdxxw on 25 March, 2004, 12:53:41

Title: Clock Date Function
Post by: [SLUT]Blackbirdxxw on 25 March, 2004, 12:53:41
If your date is not showing correct add this to the clock function in :


function showclock()
   dato = date()
   _,_,mm,dd,yy,ttt,mmm = strfind(dato, "(%d+)/(%d+)/(%d+)%s(%d+):(%d+)")
   local ddd = date("%A")
   mm = tonumber(mm)
   dd = tonumber(dd)
   
   if dd == 1 or dd == 21 or dd == 31 then
      suf = "st"
   elseif dd == 2 or dd == 22 then
      suf = "nd"
   elseif dd == 3 or dd == 23 then
      suf = "rd"
   else
      suf = "th"
   end

.......................................................................

function dotime(user,data)
   dato = date()
   _,_,mm,dd,yy,ttt,mmm = strfind(dato, "(%d+)/(%d+)/(%d+)%s(%d+):(%d+)")
   local ddd = date("%A")
   mm = tonumber(mm)
   dd = tonumber(dd)

   if dd == 1 or dd == 21 or dd == 31 then
      suf = "st"
   elseif dd == 2 or dd == 22 then
      suf = "nd"
   elseif dd == 3 or dd == 23 then
      suf = "rd"
   else
      suf = "th"
   end
......................................................................
This will sort your date out

Green Greetz To All
Big Hi to MAster @ Magmar
Title:
Post by: Herodes on 13 July, 2004, 00:36:26
I was dipping into the Mean_Machine by Snowman and I came across this func ...

I would like to know what would cause the date not to display propertly ..

I cant seem of a logical excuse ...
Title:
Post by: blackwings on 13 July, 2004, 02:21:33
I use this script that shows the time in main and it shows the correct time. Because the time on the message it sends it times, is the same as the time stamp in DC. So maybe it isn't always wrong with how the script checks the time.
-- TimeBot by aMutex - 30.12.2002
BotName = #Clock"
TimeSpanInMinutes = 180
function Main()
SetTimer(TimeSpanInMinutes*60000)
StartTimer()
end
function OnTimer()
SendToAll(BotName, date("The time is %T in our hub local timezone."))
end
Title:
Post by: Herodes on 13 July, 2004, 13:32:10
Sure ... I'm cool with that ...
I still don't get it .. why would the date AND the time display "not show correct"? (as it is stated in this first post )
Title:
Post by: plop on 13 July, 2004, 14:43:26
QuoteOriginally posted by Herodes
Sure ... I'm cool with that ...
I still don't get it .. why would the date AND the time display "not show correct"? (as it is stated in this first post )
the only posible bug i know in this comes from the fact some ppl use the date() wrong.
many use time = date("%H")..:..date("%M").."."..date("%S").
but this can go wrong, best explained with an example.

it's 11:59.99 when you do date("%H"), this retrieves 11.
next the date("%M") is triggered, which should retrieve 59.
but if the time changed it can return 00.
the result is that time becomes 11:00, now thats an hour 2 late.

plop
Title:
Post by: Herodes on 13 July, 2004, 19:00:05
Hehe :D
 thank u plop ... it was a sneaky one ...

this is what "experience" and "clear thinking" is all about ...
now it is definately clear...