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.
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.
That'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.
I 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. :D
I'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.
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.
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.
Any 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. :(
There 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?
0
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.
0
time() would be an excellent solution, but I need the server time instead of the local time.
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!
0
Thank you both for your quick answers!
Edit: Perhaps I wasn't, unfortunately. :(
0
0
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.
0
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.
0
0
Out of curiousity, are functions stored in tables considered global unless they're pointing to a local function such as:
Or do they inherit the local property from the table itself? Would this also apply to functions passed as an argument to another function?
0
0
Why is he wrong, though?
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?
0
Or:
Or, would the speed be equal? Also, would the first method be more memory efficient than the second method?