# Make an object appear for a 1/2 hour based on sunrise/sunset

So I’m a bit new to facer and even newer to the coding side of things. The logic is proving difficult for me to grasp. I want an object to appear using the transparency feature for a 1/2 hour before sunrise and again for a 1/2 hour after sunset. Then another object to appear for a 1/2 hour following sunrise and a 1/2 hour before sunset. I can’t figure out the proper codes to achieve this. I’ve been looking at several tutorials and threads such as the following links but cannot make figure out how to modify those formulas to achieve the desired effect. Does anyone know how this could be done? I feel like I am so close but yet so far! Thanks in advance!

Hm. Gonna stream-of-consciousness this a bit because i think it’ll be complex.

First, the time has to be converted into minutes in the day as a whole to merge the hour + minutes tags.

((#WSUNRISEH24#*60)+(#WSUNRISEM#))

then -30

((#WSUNRISEH24#*60)+(#WSUNRISEM#)-30)

Gotta get the current time in minutes / day to compare

((#Dk#*60)+(#Dm#))

So just checking to see if you’re past sunrise - 30 minutes would look like this:

\$((#Dk#*60)+(#Dm#))>((#WSUNRISEH24#*60)+(#WSUNRISEM#)-30)?100:0\$

Tested that and it works, but if that’s just getting something to show up a half hour before, you can imagine how complex getting it to show up a half hour before and hide after sunrise would be.

Edit: just to test the length of facer text inputs, I tried the full one and it works. It’d look a bit like this:

\$((#Dk#*60)+(#Dm#))>((#WSUNRISEH24#*60)+(#WSUNRISEM#)-30)&&((#Dk#*60)+(#Dm#))<=((#WSUNRISEH24#*60)+(#WSUNRISEM#))?100:0\$

That’s an item showing when > 30 min before and <= sunrise

1 Like

Thank you @dy_watch! That does work and I managed to get what I wanted by duplicating the item and having a total of four equations on four objects, each a variation of yours to put them at the right time. Check it out! Now I’m curious to know if it drains the battery too quick and how it works on a real watch! (Unfortunately I don’t have a smartwatch yet.)

I’m wondering though, would it not make the equation shorter to use #WRH# (Sunrise hour) or #WRm# (Sunrise minute) instead of #WSUNRISE24# (Time of sunrise)?

1 Like

Glad it worked! And I’m not sure why they have two sets of tags for basically the same thing .#WSUNRISEH# and #WRH# are both listed as sunrise hour, but #WRH# is 0-23, so you’d have to add 1 I think. At least, if #WSUNRISEH# is accurate, which it seems to be from testing, the 1-24 hour time is better.

Also, from my experience, weather + location drains battery more than anything else so it should be a negligible difference on top of that here.

1 Like