Hello, I and some others are modifying the ical google calendar skin. They managed to get the time to mostly correctly display.
I have found that the 0's in the am hours and the difference between am and pm seem to be confused.
I have posted the skin for reference but the line looks like this:
Queue['Item'..i..'Time'] = Item.Date and os.date('%I:%M -', Item.Date) or ''
The %#I:%M crashes rainmeter...
It is currently April 24th, 2024, 11:06 am
lua time is interpreted in an odd way in this skin no 0 on AM hours = nope? [solved]
-
- Posts: 1366
- Joined: September 7th, 2020, 2:24 pm
- Location: QLD, Australia
lua time is interpreted in an odd way in this skin no 0 on AM hours = nope? [solved]
You do not have the required permissions to view the files attached to this post.
Last edited by CodeCode on October 18th, 2020, 11:48 pm, edited 1 time in total.
ƈǟռ'ȶ ʄɨӼ ɨȶ ɨʄ ɨȶ ǟɨռ'ȶ ɮʀօӄɛ - ʊռʟɛֆֆ ɨȶ ɨֆ ɨռ ƈօɖɛ.
-
- Rainmeter Sage
- Posts: 16164
- Joined: October 11th, 2010, 6:27 pm
- Location: Gheorgheni, Romania
Re: lua time is interpreted in an odd way in this skin no 0 on AM hours = nope?
It does work well for me. The times shown as 00:00 with the %H:%M format, is shown as 12:00 - AM if I switch to the %I:%M - %p format.
Note that the # parameter is not valid in lua. It is in Rainmeter, however in lua it isn't, so you can't use it. That's why Rainmeter crashes...
-
- Developer
- Posts: 22629
- Joined: April 19th, 2009, 11:02 pm
- Location: Fort Hunt, Virginia, USA
Re: lua time is interpreted in an odd way in this skin no 0 on AM hours = nope?
Correct. To duplicate the functionality of the # character in Lua, you would use string.gsub() to remove the leading 0:
string.gsub() can support two forms:
newString = string.gsub(oldString, regular expression search pattern, replacement)
newString = oldString:gsub(regular expression search pattern, replacement)
So this would also work, no real advantage either way, your preference... I kinda prefer this:
http://lua-users.org/wiki/StringLibraryTutorial
Code: Select all
function Update()
someTime = string.gsub(os.date('%I:%M:%S', 1603005001),'^0','')
print(someTime)
end
newString = string.gsub(oldString, regular expression search pattern, replacement)
newString = oldString:gsub(regular expression search pattern, replacement)
So this would also work, no real advantage either way, your preference... I kinda prefer this:
Code: Select all
function Update()
someTime = os.date('%I:%M:%S', 1603005001):gsub('^0','')
print(someTime)
end
-
- Rainmeter Sage
- Posts: 16164
- Joined: October 11th, 2010, 6:27 pm
- Location: Gheorgheni, Romania
Re: lua time is interpreted in an odd way in this skin no 0 on AM hours = nope?
As most (or hope I'm not wrong if I say all) functions in lua.
-
- Developer
- Posts: 22629
- Joined: April 19th, 2009, 11:02 pm
- Location: Fort Hunt, Virginia, USA
Re: lua time is interpreted in an odd way in this skin no 0 on AM hours = nope?
Yes, as long as we are talking about a "method" in a "library". I mostly see / use it with the string, math and table libraries.
-
- Rainmeter Sage
- Posts: 16164
- Joined: October 11th, 2010, 6:27 pm
- Location: Gheorgheni, Romania
Re: lua time is interpreted in an odd way in this skin no 0 on AM hours = nope?
Well, I don't know too much in lua, just what have I gathered while I was using it with Rainmeter, so it was just an observation, based on my experience.
-
- Posts: 1366
- Joined: September 7th, 2020, 2:24 pm
- Location: QLD, Australia
Re: lua time is interpreted in an odd way in this skin no 0 on AM hours = nope?
Ok, so sometimes the time is coming out 2 hours too early in the rainmeter skin from what is in my calendar. But not always.
Where would that go in this line:jsmorley wrote: ↑October 18th, 2020, 1:18 pm Correct. To duplicate the functionality of the # character in Lua, you would use string.gsub to remove the leading 0:
string.gsub() can support two forms:Code: Select all
function Update() someTime = string.gsub(os.date('%I:%M:%S', 1603005001),'^0','') print(someTime) end
newString = string.gsub(oldString, regular expression search pattern, replacement)
newString = oldString:gsub(regular expression search pattern, replacement)
So this would also work, no real advantage either way, your preference... I kinda prefer this:
http://lua-users.org/wiki/StringLibraryTutorialCode: Select all
function Update() someTime = os.date('%I:%M:%S', 1603005001):gsub('^0','') print(someTime) end
Code: Select all
Queue['Item'..i..'Time'] = Item.Date and os.date('%I:%M -', Item.Date) or ''
ƈǟռ'ȶ ʄɨӼ ɨȶ ɨʄ ɨȶ ǟɨռ'ȶ ɮʀօӄɛ - ʊռʟɛֆֆ ɨȶ ɨֆ ɨռ ƈօɖɛ.
-
- Developer
- Posts: 22629
- Joined: April 19th, 2009, 11:02 pm
- Location: Fort Hunt, Virginia, USA
Re: lua time is interpreted in an odd way in this skin no 0 on AM hours = nope?
Queue['Item'..i..'Time'] = Item.Date and os.date('%I:%M -', Item.Date):gsub('^0','') or ''CodeCode wrote: ↑October 18th, 2020, 9:04 pm Where would that go in this line:Code: Select all
Queue['Item'..i..'Time'] = Item.Date and os.date('%I:%M -', Item.Date) or ''
-
- Posts: 1366
- Joined: September 7th, 2020, 2:24 pm
- Location: QLD, Australia
Re: lua time is interpreted in an odd way in this skin no 0 on AM hours = nope?
Thanks jsmorley, that fixed my issue as posted.
Strange, I saw this solution somewhere else, and I tried it, but it did not work - however now it does... hmph.
ƈǟռ'ȶ ʄɨӼ ɨȶ ɨʄ ɨȶ ǟɨռ'ȶ ɮʀօӄɛ - ʊռʟɛֆֆ ɨȶ ɨֆ ɨռ ƈօɖɛ.
-
- Posts: 1366
- Joined: September 7th, 2020, 2:24 pm
- Location: QLD, Australia
Re: lua time is interpreted in an odd way in this skin no 0 on AM hours = nope?
There remains the additional issue though.
Some of my calendar appointments are still coming out 2 hours earlier than they should.
The calendar even says 7 am - 8 am but is showing as 5am to 6 am. Even after deleting the event and re-entering it.
Some of my calendar appointments are still coming out 2 hours earlier than they should.
The calendar even says 7 am - 8 am but is showing as 5am to 6 am. Even after deleting the event and re-entering it.
ƈǟռ'ȶ ʄɨӼ ɨȶ ɨʄ ɨȶ ǟɨռ'ȶ ɮʀօӄɛ - ʊռʟɛֆֆ ɨȶ ɨֆ ɨռ ƈօɖɛ.