Welcome, Guest
Please Login or Register.    Lost Password?

Moon phase?
(1 viewing) (1) Guest
Go to bottomPage: 123
TOPIC: Moon phase?
#20783
Re: Sun-Moon 5 Months, 1 Week ago  
Thanks, It works now with latest Rainlendar.

But it shows:
HH:MM Full Moon
Where HH:MM are literal in Windows 7 64 bit
In Ubuntu 64 bit it correctly shows:
14:09 Full Moon

Oh! Rainlendar Bug. Every event display HH:MM when full day is deselected. And the time list shows literally:
HH:MM
HH:MM
HH:MM
HH:MM
...

I didn't saw this bug reported before.
Nilfred
Junior Boarder
Posts: 23
graphgraph
User Offline Click here to see the profile of this user
Gender: Male Location: Argentina
The administrator has disabled public write access.
 
#20805
Re: Sun-Moon 5 Months ago  
To Nilfred :
Sounded seems that you got a wrong "Time format".
Please go: Options>>Advanced, look at the first item "Time format", correct the setting.
anoob
Platinum Boarder
Posts: 498
graphgraph
User Offline Click here to see the profile of this user
Gender: Male Location: TaiChung, Taiwan, R.O.C. Birthday: 02/12
The administrator has disabled public write access.
I couldn't speak English! This skin released to Customize.org(Do you want it? Click Picture) Please contact me if interested: jhg5702@gmail.com
 
#21037
Re: Sun-Moon 4 Months ago  
Thanks anoob, there was HH:MM wrote. Setting to Default do the trick.

@Jorge_Luis:
Could I have sunrise and sunset alarms?
I was peeking around ~/.config/.rainlendar2/skins/Shadow4.r2skin/scripts/sun-moon-riseset.lua looking where to set a hook.
Looks like "Sunmoon.time2" and "Sunmoon.time3" in function SunMoon_RiseSet_OnTimer(window) are what I'm looking for.
Nilfred
Junior Boarder
Posts: 23
graphgraph
User Offline Click here to see the profile of this user
Gender: Male Location: Argentina
The administrator has disabled public write access.
 
#21039
Re: Sun-Moon 4 Months ago  
Nilfred wrote:
Thanks anoob, there was HH:MM wrote. Setting to Default do the trick.

@Jorge_Luis:
Could I have sunrise and sunset alarms?
I was peeking around ~/.config/.rainlendar2/skins/Shadow4.r2skin/scripts/sun-moon-riseset.lua looking where to set a hook.
Looks like "Sunmoon.time2" and "Sunmoon.time3" in function SunMoon_RiseSet_OnTimer(window) are what I'm looking for.


time2 and time3 shows the sunrise and sunset times, but to add an alarm you'll need to create a volatile event every time the window is loaded. Replacing the code below would do the trick, but it's a little annoying. Repeating the same for time3 will create an alarm for sunset.

Replace this:
Code:

timeUTC = timeUTC * 60 + cityTimeZone * 3600    
Rainlendar_SetItemValue(window, "Sunmoon.time2", "text", string.format("%02d:%02d", math.floor(timeUTC / 3600), math.floor((timeUTC % 3600) / 60)))    



With this to create a task (or remove the DUE line and change VTODO with VEVENT to have an event):
Code:

    timeUTC = timeUTC * 60
    local icalData = "BEGIN:VTODO\n"
    icalData = icalData .. "UID:Sunrise-for-today\n"
    icalData = icalData .. "SUMMARY:Sunrise\n"    
    local today = os.date("*t")
    local alarmTime = string.format("%04d%02d%02dT%02d%02d00Z", today.year, today.month, today.day, math.floor(timeUTC / 3600), math.floor((timeUTC % 3600) / 60))
    icalData = icalData .. "DTSTART:" .. alarmTime .. "\n"
    icalData = icalData .. "DUE:" .. alarmTime .. "\n"
    icalData = icalData .. "BEGIN:VALARM\n"
    icalData = icalData .. "ACTION:AUDIO\n"
    icalData = icalData .. "TRIGGER;VALUE=DURATION:-PT1M\n"
    icalData = icalData .. "X-RAINLENDAR-ALARM-TYPE:alert\n"
    icalData = icalData .. "END:VALARM\n"
    icalData = icalData .. "END:VTODO"
    local strUID = Rainlendar_CreateComponent(icalData)
    timeUTC = timeUTC + cityTimeZone * 3600
    Rainlendar_SetItemValue(window, "Sunmoon.time2", "text", string.format("%02d:%02d", math.floor(timeUTC / 3600), math.floor((timeUTC % 3600) / 60)))    

Jorge_Luis
Platinum Boarder
Posts: 792
graphgraph
User Offline Click here to see the profile of this user
Gender: Male My Rainlendar Skins Location: Argentina Birthday: 03/15
Last Edit: 2014/04/22 09:24 By Jorge_Luis.
The administrator has disabled public write access.
 
#21041
Re: Sun-Moon 3 Months, 4 Weeks ago  
Nice!
I always miss sunrise, so I setup the alarm for sunset instead following your guidelines.
Replaced this:
Code:

    timeUTC = timeUTC * 60 + cityTimeZone * 3600
    Rainlendar_SetItemValue(window, "Sunmoon.time3", "text", string.format("%02d:%02d", math.floor(timeUTC / 3600), math.floor((timeUTC % 3600) / 60)))


With this:
Code:

    timeUTC = timeUTC * 60
    local today = os.date("*t")
    local icalData = string.format([[
BEGIN:VEVENT
TRANSP:TRANSPARENT
CLASS:PRIVATE
UID:Sunset-for-today
SUMMARY:Sunset
DTSTART:%04d%02d%02dT%02d%02d00Z
BEGIN:VALARM
ACTION:AUDIO
TRIGGER;VALUE=DURATION:PT0S
X-RAINLENDAR-ALARM-TYPE:alert
END:VALARM
END:VEVENT]], today.year, today.month, today.day,
      math.floor(timeUTC / 3600), math.floor((timeUTC % 3600) / 60))
    local strUID = Rainlendar_CreateComponent(icalData) 
    timeUTC = timeUTC + cityTimeZone * 3600 
    Rainlendar_SetItemValue(window, "Sunmoon.time3", "text",
      string.format("%02d:%02d", math.floor(timeUTC / 3600),
      math.floor((timeUTC % 3600) / 60)))


And it works as expected, but if I touch the arrows the alarm is set today for the sunset time at "Sunmoon.time1" date.
"today" is already defined at the beginning of the function:
Code:

function SunMoon_RiseSet_OnTimer(window) 
  userData = Rainlendar_GetItemValue("Sun-Moon Rise-Set", "Sunmoon.time1", "text")
  _, _, day, month, year = userData:find("(.*)/(.*)/(.*)")
  day = tonumber(day)
  month = tonumber(month)
  year = tonumber(year)

  if (month <= 2) then
    year = year - 1
    month = month + 12
  end


But may be messed up, so a backup copy works better than hardcoding "today"
Code:

  year = tonumber(year)

  local today = {}
  today.day = day
  today.month = month
  today.year = year

  if (month <= 2) then


And remove the line containing:
Code:

    local today = os.date("*t")

It still need some tweak to the UID, I'm working on it, but that isn't the big problem I now face...

Now that I have a sunset alarm, I don't need the "Sun-Moon Rise-Set" window opened But If I don't open it, the alarm isn't setup.

I overwrite sun-moon-riseset.lua inside Shadow4.r2skin and it feels weird.
What happens when function names collide?
If don't throw an error: Which definition wins?
At the end I will not need a collision, so I asking while at it.

The usefulness of such alarms are for Judaism, that close their business Fridays at sunset.
Also for Muslims: Sehri and Iftaar in Ramadan.
Nilfred
Junior Boarder
Posts: 23
graphgraph
User Offline Click here to see the profile of this user
Gender: Male Location: Argentina
The administrator has disabled public write access.
 
#21042
Re: Sun-Moon 3 Months, 4 Weeks ago  
Copy the attached lua file to ~/.config/.rainlendar2/scripts/ and refresh Rainlendar. This is a standalone (and cut) version with sunrise and sunset only.
The file will create the alarm without the need for a window.

The idea behind the script was to show the sunrise/sunset for the specified date, and not only the current date, that's why time1 changes everything.

To avoid further problem, all the variables should be locals... but I leave that for you

I think that when 2 functions have the same name, the last win... and this brief script proves it:
Code:

function ThisIsTest()
  Rainlendar_Log("0")
end
function ThisIsTest()
  Rainlendar_Log("1")
end
ThisIsTest()


Output: "1"

File Attachment:
File Name: Sunset_Alarm.lua
File Size: 14901
Jorge_Luis
Platinum Boarder
Posts: 792
graphgraph
User Offline Click here to see the profile of this user
Gender: Male My Rainlendar Skins Location: Argentina Birthday: 03/15
The administrator has disabled public write access.
 
Go to topPage: 123
get the latest posts directly to your desktop