Unfortunately, I need date and time information based on the current server time, so I cannot use date() or time(). This would be a non-issue but the database has syncing features so having different returns for people in different time zones will cause issues.
Edit: With that said, is there a way to retrieve seconds from the server time? CalendarGetDate() can return the correct date information, and GetGameTime() returns the hour and minute - but I do not see anything for seconds. It's not a big issue, but exact time would be lovely.
- Registered User
Member for 12 years, 4 months, and 29 days
Last active Fri, Oct, 4 2013 21:32:26
- 0 Followers
- 11 Total Posts
- 0 Thanks
Apr 2, 2010Thank you all for your very informative answers.Posted in: Lua Code Discussion
Quote from OrionShock*b/c chrome won't let me edit my post..
using time() instead of date() is better because you can feed the values from time() into date(). when you use date() you can feed in any display format you want.
Dump: value=date("%c", time())
time() would be an excellent solution, but I need the server time instead of the local time.
Quote from FarmbuyerThat's because 0>3 is false, and so the comparison need go no further.
You have a string, not a number, and strings are compared alphabetically one character at a time. (Well, lexigraphically, actually, but the distinction is a fine one here.) That means the same number of digits for each category; whether that be 1 or 2 or 4, it must be the same for both left and right sides. You have a leading zero on one side but not on the other, so everything stops at the very first "digit" character.
Like others have said, by making the format uniform and always largest-unit to smallest-unit, alphabetical sorting becomes numeric sorting, and all these problems just go away.
For single digit hours: GetGameTime() returns without a leading zero, and I had not taken that into account. Thank you for the in-depth explanation, though. =)
I'm going to go with the YYYY-MM-DD hh:mm:ss format, which I had completely overlooked since I'm so used to MM-DD-YYYY format.
Thanks again, everyone!
Apr 2, 2010I had only tested the comparisons with the forward slashes as delimiters for the dates before I made this thread. It seems that I was over-complicating the issue. :DPosted in: Lua Code Discussion
Thank you both for your quick answers!
Edit: Perhaps I wasn't, unfortunately. :(
"04:01:2010 12:00:00" > "3:30:2010 12:00:00" => false
Apr 1, 2010I think I'll just use colons as the delimiter.Posted in: Lua Code Discussion
"04/01/2010" > "04/02/2010" => false "04/03/2010" > "04/02/2010" => true "04/03/2010" > "04/05/2010" => false "04/03/2010" > "04/05/2009" => false "07:58:59" > "8:00:00" => false "07:58:59" > "08:00:00" => false "09:58:59" > "08:00:00" => true "08:00:01" > "08:00:00" => true "08:00:01" > "08:00:02" => false "24:00:01" > "08:24:02" => true "15:03:04" == "15:03:04" => true "15:03:04" == "15:03:05" => false "15:03:04" < "15:03:05" => true "15:03:04" > "15:03:05" => false "15:03:04" >= "15:03:05" => false "15:03:04" <= "15:03:05" => true "04:01:2010" > "04:02:2010" => false "04:01:2010" > "04:00:2010" => true "04:01:2010 3:52:25" > "04:01:2010 3:53:25" => false "04:01:2010 3:52:25" < "04:01:2010 3:53:25" => true "04:01:2010 3:52:25" < "04:01:2010 3:52:25" => false "04:01:2010 3:52:25" < "04:01:2010 3:52:26" => true
Apr 1, 2010I've created a loot database addon for my guild, and they would prefer for it to be sorted by date. The problem is that I have not found any way to compare dates in lua.Posted in: Lua Code Discussion
local Timestamp = date("%m/%d/%Y " .. GetGameTime() .. ":%M:%S") local Month, Day, Year, Hour, Minute, Second = string.match(Timestamp, "(%w-)/(%w-)/(%w-) (%w-):(%w-):(%w-)$")
Is there something I overlooked in my search, or is the above one of the methods I may need to employ in order to achieve this? =)
Edit: After some experimenting in game, it seems I may have created this thread prematurely. Comparing strings of time seems to return accurate bool values, but comparing dates did not.
Feb 20, 2010_ForgeUser1217404 posted a message on [Grid] Modules: Threat,RaidIcons,MTs / Indicators: Text3,SideIconsPosted in: Grid & Grid2
I'm already using the latest version of Grid (r1282) and the latest version of GridIndicatorSideIcons (r49). I tried r48 of GridIndicatorSideIcons as well, but it did not change anything.
Feb 17, 2010_ForgeUser1217404 posted a message on [Grid] Modules: Threat,RaidIcons,MTs / Indicators: Text3,SideIconsAny chance of getting GridIndicatorSideIcons fixed to work with the latest version of Grid? I tried to debug it myself, but switching to r48 or tinkering with the newer module support method did not seem to change its decision to not show at all. :(Posted in: Grid & Grid2
Jan 8, 2010I've noticed some authors have their own approach to how they handle functions.Posted in: Lua Code Discussion
local AddOn = CreateFrame("Frame") function AddOn:Function() end
Out of curiousity, are functions stored in tables considered global unless they're pointing to a local function such as:
local AddOn = CreateFrame("Frame") local function Function() end AddOn.Function = Function
Or do they inherit the local property from the table itself? Would this also apply to functions passed as an argument to another function?
local AddOn = CreateFrame("Frame") local function Function() end AddOn:SetScript("Whatever", Function)
local AddOn = CreateFrame("Frame") AddOn:SetScript("Whatever", function() end)
Nov 8, 2009Posted in: Lua Code DiscussionQuote from ArrowmasterNo you are wrong.
Why is he wrong, though?
Quote from FlickorThere would be two reasons why you should use the local variable outside the function:
1. If that function is called VERY often (like from a onupdate script or a heavy event like CLEU or UNIT_AURA)
2. If you are going to use the same variable in multiple functions or somewhere else in your code.
I'm aware of the purpose for declaring it outside or inside of the function. I'm not aware of the actual amount of time/memory I would save by doing one or the other. I'm assuming the time will be negligible, but would the memory be? Am I assuming incorrectly? Pie or cake?
Nov 8, 2009I've been curious about this for a while now. Assuming scope is not an issue, would it be faster to do:Posted in: Lua Code Discussion
local Variable1, Variable2 local function Func() Variable1 = something... Variable2 = something else... end
local function Func() local Variable1 = something... local Variable2 = something else... end
Or, would the speed be equal? Also, would the first method be more memory efficient than the second method?
- To post a comment, please login or register a new account.