It is currently November 29th, 2020, 5:16 pm

Enigma Google Calendar Patch

Post your work-in-progress and completed skins to share and discuss.
Ruff_hi
Posts: 15
Joined: August 21st, 2018, 1:30 pm

Re: Enigma Google Calendar Patch

Post by Ruff_hi »

I have just started playing with a RPI and MagicMirror (mm). The mm calendar code reads from a gmail calendar and has no trouble with annual recurring appointments (eg Christmas, birthday, etc). I will peek at their code to see how they do it.

That said, I added Christmas to my google calendar as an annual recurring event ... and now my rainmeter calendar is showing Christmas. But it isn't showing New Years Day ... that is weird.

I just added NYEve (Dec 31) and it is showing in the rainmeter calendar. The calendar must have a thing about showing recurring events that occur NEXT YEAR.
Ruff_hi
Posts: 15
Joined: August 21st, 2018, 1:30 pm

Re: Enigma Google Calendar Patch

Post by Ruff_hi »

Well ... that was easy. The code was just sitting there.

There is some code to handle adding a month if the recurring frequency is monthly ... so i just stole that and used it for annual ...

Code: Select all

-- Yearly recurring events
elseif s:match('FREQ=YEARLY') then
	-- Match and set to this year
	Date.year, Date.month, Date.day = s:match('DTSTART;VALUE=DATE:(%d%d%d%d)(%d%d)(%d%d)')
	Date.year = os.date('%Y')
					
	-- If date is in the past then add a year
	if os.time(Date) < os.time() then
		Date.year = Date.year + 1
	end
	return Date
Ruff_hi
Posts: 15
Joined: August 21st, 2018, 1:30 pm

Re: Enigma Google Calendar Patch

Post by Ruff_hi »

Because the above just dumps all future annual recurring events ... I added some code to only show annual events if they occur in the next 3 months.

Code: Select all

-- ADD NEW ITEMS
for i = #Items, 1, -1 do
	if Items[i] then
		if t == 'iCalendar' then
			FutDate.year = os.date('%Y')
			FutDate.month = os.date('%m') + 3
			FutDate.day = os.date('%d')
			if FutDate.month > 12 then
				FutDate.year = FutDate.year + 1
				FutDate.month = FutDate.month - 12
			end
							
			if (Items[i].Date > os.time()) and (Items[i].Date < os.time(FutDate)) then
				table.insert(Feeds[f], 1, Items[i])
			end
		else
			table.insert(Feeds[f], 1, Items[i])
		end
	end
end
Note, you will have to define FutDate ...

Code: Select all

function Input(a)
        local f = a or f
	local FutDate = {}
User avatar
CodeCode
Posts: 171
Joined: September 7th, 2020, 2:24 pm

Re: Enigma Google Calendar Patch

Post by CodeCode »

Hey Ruff_hi,

Wow. Your grasp of lua is much better than mine.

That said, I noticed that if an event recurs, say weekly that the time gets messed up and shows fairly consistently for each event I created to be 2 hour early.

With what you've discovered so far (which I will add to mine ;-) ), perhaps you might understand what is going on there?

Cheers.
Can't fix it if it ain't broke - unless it is in code.
Ruff_hi
Posts: 15
Joined: August 21st, 2018, 1:30 pm

Re: Enigma Google Calendar Patch

Post by Ruff_hi »

Not sure what is going on with the time. I see it too ... my 11am was showing as 7am.

The offending line of code (for weekly recurring meetings) has been removed from about line 500 ... just above the rememberthemilk routine.

Something to do with daylight saving ... but my DS is not 4 hrs ... that said, I am 4hrs from GMT (but in the other direction). Hmm ... file says my DS adjustment is -4 ... so it must take my 11am as 11am GMT and change that to 7am (New York). Where does it pick my location from? Why does it think my calendar is GMT and my location is NYC?

Code: Select all

				if s:match(MatchTime) then
					Date.year, Date.month, Date.day, Date.hour, Date.min, Date.sec = s:match(MatchTime)
--					Date.Offset = DS.Offset
				else
					Date.year, Date.month, Date.day = s:match(MatchDate)
				end
Edit: it needs that ds.offset for non-recurring meetings. So we can't just remove (and ignore) that line.
User avatar
CodeCode
Posts: 171
Joined: September 7th, 2020, 2:24 pm

Re: Enigma Google Calendar Patch

Post by CodeCode »

Ruff_hi wrote: October 20th, 2020, 9:27 pm Not sure what is going on with the time. I see it too ... my 11am was showing as 7am.

The offending line of code (for weekly recurring meetings) has been removed from about line 500 ... just above the rememberthemilk routine.

Something to do with daylight saving ... but my DS is not 4 hrs ... that said, I am 4hrs from GMT (but in the other direction). Hmm ... file says my DS adjustment is -4 ... so it must take my 11am as 11am GMT and change that to 7am (New York). Where does it pick my location from? Why does it think my calendar is GMT and my location is NYC?

Code: Select all

				if s:match(MatchTime) then
					Date.year, Date.month, Date.day, Date.hour, Date.min, Date.sec = s:match(MatchTime)
--					Date.Offset = DS.Offset
				else
					Date.year, Date.month, Date.day = s:match(MatchDate)
				end
Edit: it needs that ds.offset for non-recurring meetings. So we can't just remove (and ignore) that line.
I was poking around as well but I found that most - if not all time references are based on local time. But, for me as well since I am +10 GMT which is that same time difference but on my end of 2 hours or 10 rather which might explain why my Am and PM were being incorrect for recurring events.

The code mentions UTC once and a tired to set it to AEST but woah not good.
Can't fix it if it ain't broke - unless it is in code.
Ruff_hi
Posts: 15
Joined: August 21st, 2018, 1:30 pm

Re: Enigma Google Calendar Patch

Post by Ruff_hi »

Yeah ... yearly or monthly recurring meetings don't have their time squashed. Weekly does ... I expect anything other than annual or monthly does. There is something in the code re recurring meetings (not yearly or monthly) that is borked.

AEST is Australian East summer time ... I am an Aussie but have been living in the US for ... sigh ... 20 yrs.
User avatar
CodeCode
Posts: 171
Joined: September 7th, 2020, 2:24 pm

Re: Enigma Google Calendar Patch

Post by CodeCode »

Ruff_hi wrote: October 20th, 2020, 10:34 pm Yeah ... yearly or monthly recurring meetings don't have their time squashed. Weekly does ... I expect anything other than annual or monthly does. There is something in the code re recurring meetings (not yearly or monthly) that is borked.
Well, that might help identify where the error is. I'll keep looking..
Ruff_hi wrote: October 20th, 2020, 10:34 pm AEST is Australian East summer time ... I am an Aussie but have been living in the US for ... sigh ... 20 yrs.
Heh. I'm from the US and been in Aus for 15 years.
Can't fix it if it ain't broke - unless it is in code.