added local time characteristic #4
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "cybuzuma/infinitime:gatt_localtime"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Motivation
InfiniTime gains the Local Time GATT Characteristic in this PR. This characteristic sends information about the current timezone to the watch and thus allows it to calculate the current UTC.
Changes
SetTimezone()
function building the corresponding bytes.Notes
I did not find a way to find the exact dst offset in go (there are cases where dst does not shift by a full hour). As a result, when
t.IsDST()
returns true, the dst offset is set to one hour and the timezone offset is decreased by one hour.Thank you for this PR. I don't want to merge this until the InfiniTime PR gets merged, so I will keep this open for now. In the meantime, please apply my suggestion in the comment I wrote here, and modify the ITD side to match that (you can use
time.Local
).I am afraid I can not see any comment.
Ok, I'll just copy them here.
infinitime.go, line 720:
infinitime.go, line 728:
Your version will return the timezone offset at
Now()
. You see, the timezone offset is not constant over time (see DST). That is why the timezone usually is tied to a datetime to make it unambiguous.If now someone wants to set the watch to a different time, this might give wrong results. I agree that this is probably an unlikely corner case, but I have seen users requesting the ability to set the PineTime to a different time.
I have seen other libraries use a
datetime
instead of atimezone
to set such information, because of the aforementioned problem.So, I would stay with my implementation, if you can follow my argument.
But in the end: Your code, your decision.
Sorry, have to admit that I was too lazy to look up if go supports this syntax. Will fix.
Yes, you are right. That makes me think that maybe instead of having a separate SetTimezone function, this should just be done inside SetTime, right after the time is set. That way, the timezone will always be set to local automatically unless the user specifically chooses a different timezone. That should probably also be reflected in the doc comment above
SetTime()
.infinitime.go, line 722:
I think silent failure would be better in this case, just because many people won't have 1.10.0 at first, and printing warnings every time would be pretty annoying for users. I might re-add the warning later.
A better way to do this would be like so:
Perfect, I'll merge this when the PR on InfiniTime gets merged. Thank you.
Hello ! We've finally merged the feature in InfiniTime! @Arsen6331 @cybuzuma thank you for your work on this feature and on ITD!
@cybuzuma If you have time, could you please resolve the conflicts? If not, I can do it myself as well.
Thanks, merging now