Code for Transparency Sunrise/Sunset

Hi fellow Facers, Seasons Greetings! I’m trying to create a sunrise/sunset complication that acts like the Android Wear 2.0 sunrise/Sunset. i.e. before Sunrise the sunrise time is displayed and as soon as the sunrises it displays the Sunset time and so on: I’ll be using one of these TAGS: #WSUNRISE24# but I don’t know how to write the code for it so any assistance gratefully received, cheers in advance

1 Like

This will have 2 elements in it:

  1. the main condition that is based on #DISDAYTIME# tag, which checks if now is a day or night.
  2. based on point 1 it will show code counting from now to either sunrise or sunset:

Time of sunrise (in hours):
(#WRH#+(#WRm#/60))
Time of sunset (in hours):
(#WSH#+(#WSm#/60))
Current time (in hours):
(#DH#+(#Dm#/60))

Subtract from the time of sunrise the current time and recalculate that into separate hours, minutes and seconds.

And vice versa with sunset.

1 Like

Hi @Mellin, thanks for the quick response as always , but how do I actually use this in Creator? I’m afraid I’ll need this spoon fed to me like a child

1 Like

@Mellin, I’m looking for a Transparency TAG, one that will be a 100% for #WSUNRISE24# up until the time of sunrise and then 0% thereafter until sunset has happened and the 100% again. Also same for #WSUNSET24# which will be 100% as soon as the sunrises etc

You cannot use #WSUNRISE24# tag because it returns a text-based value, not number based one.

Second thing: I honestly don’t know how to do that last part…
I can help you with calculating the time until the sunrise and sunset, but in order to calculate values from 100 to 0 %, we would need to know both start and end range.
We DO know the end range - 0 hours and 0 minutes until the sunrise/sunset, but since those times change each day we don’t have the start of the range.

Isn’t this a number based response? Screen grab from Facer Documentation

It gives you “20:06”
I didn’t know that “:” was a number.

good point: OK, can this be modified for a solution? This is kind of the reverse of what I want. Can I send you a .mov file?
$(#DH#+1)>=(#WSH#)&&(#DH#+1)<=(#WSH#)?((#Dm#)(100/60)):$$(#DH#+1)<=(#WRH#)&&(#DH#+1)>=(#WRH#)?(100-(#Dm#(100/60))):$$(#DH#+1)<(#WSH#)&&(#DH#+1)>(#WRH#)?0:100$

No this will not work because you have more than one condition.

If you can pinpoint me to that start range point I mentioned, I will be able to create a script for you.

By mov file, you mean a video?
Why not just upload it to Youtube with visibility set to private?

https://we.tl/Z7Y4RalNEk
if I’m over stepping let me know, would mind downloading and looking at this

Sorry, but as a principle, I don’t download files from sites I don’t know.

If it is a video clip please upload it to YuoTube. and send me a link.

fair enough totally get it: just uploaded as you suggested:

It’s gonna take some time to process it on youtube.

I will look at it in about 15min.

cool, thanks

It still says “Movie is unavailable”.
Can you open it on your end in incognito mode?

no doesn’t work when in incognito mode

That means it is unavailable for others to see, can you check it’s visibility settings?

Hey guys, might be jumping in where not welcome, but I used a similar thing for this one:

I developed the code you said was the reverse of what you wanted, but that actually has a fade in/fade out effect set for one hour before sunset and sunrise. The code you’re after should be simpler:

Transparent during day
$(#DH#)<(#WSH#)&&(#DH#)>(#WRH#)?0:100$

Use the above for the sunrise time

Transparent during night
$(#DH#)<(#WSH#)&&(#DH#)>(#WRH#)?100:0$

Use the above for the sunset time.

Hope this helps

I’ve just realised, that code only incorporates the hour.

Use this instead. the #DISDAYTIME# returns true/false so it incorporates the whole time not just the hour.

Transparent during day
$(#DISDAYTIME#)>0?0:100$

Transparent during night
$(#DISDAYTIME#)==0?100:0$

1 Like

@tara.goisisi, thanks for jumping in, all help always welcome. I’m trying to create a dial/window with dual imagery, like the sunrise/sunset Android Wear 2.0 complication, i.e. before sunrise the watch displays tine of sunrise, as soon as that time is reached the dial/window changes to sunset and so on: Here’s the face I’m working on, this one is published and it shows both sunrise and sunset simultaneously which seems a little clumsy:

Here’s a link to the draft modified version of the face that I would like the code for:

I don’t know why but above link is displaying the incorrect face if you click the face it will show the correct one which can be inspected "Fit Track Big Data MKII)
PS: Really like your designs