Trouble with Displaying the Correct 'Hour' value #9196
Unanswered
farTooOld
asked this question in
Using MicroPython
Replies: 1 comment 9 replies
-
I’m having some trouble following your code because it’s very long and oddly formatted and contains a lot more That said, the output looks like something is interpreting the hour as hexadecimal. E.g. in the row |
Beta Was this translation helpful? Give feedback.
9 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
OSX 12.5
MicroPython v1.19.1
Thonny 3.3 13
Python 3.7.9
Pi Pico with RP2040
Problem: Printing / Displaying Numbers from Time Codes
I come to Python with over 40 years of programming experience and never had issues with Using/Calculating, Printing/Displaying numbers (in all other programming languages). That is to say, once understanding the number type and formatting particulars for it with respect to Display type (i.e., Monitor, LCD, TFT...)
I'm having trouble with Displaying the correct 'Hour' value, as follows:
Goal: Using 24hr clock, I Grab the 'Hour' from ds3231 and add '7' to it to yield GMT. The current ds3231 Hour is set to my local time and my time zone is 7hr behind GMT). Rather than setting for GMT and subtracting 7hr to get local, I prefer to set for local time and add 7hr to get GMT)
• I can get the local HR and display it, no problem
• The local time (including HR) is always correct
• For GMT's Hr, logic suggests simply adding 7hr to the local hr BUT...
... the 'But' is this:
• All is good from 12am (0am) through 9am local. Then, at 10am local time, the GMThr jumps from 17 to 23 (a delta of 13hrs! Not, 7hrs) and, when local time is 20hrs, GMThr jumps from 19hrs ahead of local to 39).
Perhaps best to look at the printout, below
The solution's I tried:
• Different number formats, Int, Str, i, d, x, s, r, f
• I've tried using Bytes, Ints, Floats, etc...
• I've printed out the 'number' types example: type (print(type(GMTHr)) and they show the correct type
No matter what combinations I use, I never get a consistent addition of 7 to the local Hr. What I'm I doing wrong, or even better, what should I do to both understand this problem and fix it?
Printout of a partial day's time data
Portion of the Relevant Code:
(Edit by @jimmo -- add code formatting using triple-backticks
```
).Beta Was this translation helpful? Give feedback.
All reactions