Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use relative times for calendar events in protocol 7 documentation #324

Merged
merged 2 commits into from
Aug 13, 2023

Conversation

synthead
Copy link
Owner

@synthead synthead commented Aug 13, 2023

Fixes #323!
Related to #316.

This PR replaces the fixed times for calendar events with relative times for tomorrow in the protocol 7 documentation. This fixes a documentation bug where Time.now in the complete code example advances past the fixed calendar event times.

From #323:

Related to #316.
Related to #321.

The DSI e-BRAIN (protocol 7) uses 5 minute intervals relative to the current date of the device time as the event time. This means that if the device time is midnight, and the event if at 00:15, the calendar event time is sent as "3". If the event is midnight on the next day, it is sent as "288" (1440 minutes in a day / 5 minutes).

Since this is relative to the device time, if a calendar event happens to be before the device time, then the calendar event time will have a negative value due to it being relative to the device time. With #322, calendar event times are now validated, and a event before the device time will raise a message like so:

Validation failed: Time 2022-12-13 09:00:00 -0800 must be greater or equal to device time! (ActiveModel::ValidationError)

The protocol 7 documentation includes a combination of Time.now for the device time, and two times in December, 2022 as calendar event times:

time = Time.now
breakfast_with_cousins = phrase_builder.vocab_ids_for("Breakfast", "With", "Cousins")
crashing_around_the_house = phrase_builder.vocab_ids_for("Crashing", "Around", "The", "House")
events = [
TimexDatalinkClient::Protocol7::Eeprom::Calendar::Event.new(
time: Time.new(2022, 12, 13, 9, 0, 0),
phrase: breakfast_with_cousins
),
TimexDatalinkClient::Protocol7::Eeprom::Calendar::Event.new(
time: Time.new(2022, 12, 13, 19, 0, 0),
phrase: crashing_around_the_house
)
]
calendar = TimexDatalinkClient::Protocol7::Eeprom::Calendar.new(
time: time,
events: events
)

While the protocol 7 documentation worked well when it was written, time has passed, and the 2022 dates are now before Time.now, so the complete code example in the protocol 7 documentation now raises exceptions when used.

This should be fixed so that the example works at any point in time. Since the calendar event times are relative to the device time, and the example uses a relative Time.now device time, the failure-proof way to fix this documentation would be to make the event examples relative to Time.now, too.

@synthead synthead added bug Something isn't working documentation Improvements or additions to documentation protocol 7 Specific to protocol 7 labels Aug 13, 2023
@synthead synthead self-assigned this Aug 13, 2023
@synthead synthead merged commit 30642fb into main Aug 13, 2023
5 checks passed
@synthead synthead deleted the use-times-for-tomorrow-in-protocol-7-documentation branch August 13, 2023 01:39
@synthead synthead changed the title Use relative times for tomorrow for calendar events in protocol 7 documentation Use relative times for calendar events in protocol 7 documentation Aug 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working documentation Improvements or additions to documentation protocol 7 Specific to protocol 7
Projects
None yet
1 participant