SolarPosition icon indicating copy to clipboard operation
SolarPosition copied to clipboard

solarTimeRTC.ino example prints times without zero padding

Open drf5n opened this issue 2 years ago • 6 comments

The solarTimeRTC example is missing leading zeros on the time elements, and could print ugly times like:

     9:5:1 UTC on Tuesday, April 18, 2023

https://github.com/KenWillmott/SolarPosition/blob/ba19df4b971837592b78930d4baed061b2b45ac8/examples/solarTimeRTC/solarTimeRTC.ino#L80-L92

A few lines like this would solve it:

if(someTime.Second<10)Serial.print('0');

Here's a configured simulation:

https://wokwi.com/projects/362382128060882945

image

drf5n avatar Apr 18 '23 22:04 drf5n

Requires some thought about how to handle this.

KenWillmott avatar Apr 19 '23 20:04 KenWillmott

Here's a solar tracker simulation with text-based 0 padding and steppers:

https://wokwi.com/projects/362461186756144129

image

And without the zero padding on the times:

image

drf5n avatar Apr 20 '23 15:04 drf5n

It isn't that I don't understand the issue. I want to have an overview of all the code before just patching it.

KenWillmott avatar Apr 20 '23 17:04 KenWillmott

This is just an example and it's up to the programmer to interpret the data. I am using the library in my solar tracker with no problems so I think discussion of sample code is a waste of time.

kacza avatar Apr 20 '23 21:04 kacza

I realize it's a nit-picking little thing. Feel free to close with a "won't fix" because the fault lies with Arduino's lack of a Serial.printf("%02d:",0);

I like your library, and am going to use it to build a tracker with steppers like the Wokwi simulation. Thanks.

drf5n avatar Apr 20 '23 22:04 drf5n

I'm planning to re-write the example using the JeeLabs/Adafruit RTC library because it has a built in function for formatted text output.

KenWillmott avatar Apr 21 '23 00:04 KenWillmott