date picker wraps around to 1 for the first of the current month#496
Conversation
cbe6b00 to
a6e7e93
Compare
The Edit Datapoint screen contains a date picker. The Add Datapoint screen, the lower part of the goal screen, did not contain a date picker. Instead it contained a single digit to represent the date of the to-be-created datapoint and furthermore sent this single digit to the backend as part of `urtext`. The backend itself then interpreted the values sent and really had no way to accurately map the "day of the month" number to any particular year or month. Here the Add Datapoint section has its own date which is then sent to the backend when adding the new datapoint. Since the app now provides all of year, month, and day, there is less ambiguity with regards to the daystamp for the datapoint. The (date) value shown is either a simple single number (the day) when within the same month, the month and day when no longer in the same month but still the same year, and all three components when the point is for a different calendar year. Fixes beeminder#386
no longer unnecessarily wrapping conditionals or arguments in parentheses
04bd28c to
e3b6e51
Compare
theospears
left a comment
There was a problem hiding this comment.
Looks good to me. Thanks for including the video.
|
|
||
| let newDate = (calendar as NSCalendar?)?.date(byAdding: components, to: Date(), options: []) | ||
| let now = Date() | ||
| guard let newDate = calendar.date(byAdding: components, to: now) else { return } |
There was a problem hiding this comment.
Nit: This seems like the return here should never happen. I like logging a warning in these cases.
| components.day = Int(self.dateStepper.value) | ||
|
|
||
| let newDate = (calendar as NSCalendar?)?.date(byAdding: components, to: Date(), options: []) | ||
| let now = Date() |
There was a problem hiding this comment.
This does surprising things if you have the view open and midnight rolls around. But this PR doesn't change that weird behavior, it was always there.
There was a problem hiding this comment.
True. The app will work with the data it has from the time it last fetched it. One can use other means to adjust the deadline and the one client might not know about it while it is at the timer screen, add data screen, or edit data screen. (See #26)
Is the server posting to the app via remote notification that a goal has been updated? Does the app still need to fetch (pull) to find out?
The Edit Datapoint screen contains a date picker. The Add Datapoint screen, the lower part of the goal screen, did not contain a date picker. Instead it contained a single digit to represent the date of the to-be-created datapoint and furthermore sent this single digit to the backend as part of
urtext. The backend itself then interpreted the values sent and really had no way to accurately map the "day of the month" number to any particular year or month.With this merge request, the Add Datapoint section has been given its own date which is then sent to the backend when adding the new datapoint. Since the app now provides all of year, month, and day, there is less ambiguity related to the daystamp for the datapoint.
Furthermore, similar to how the Android app / Beedroid handles this, the format shown varies: the (date) value shown is either a simple single number (the day) when within the same month, the month and day when no longer in the same month but still the same year, and all three components when the point is for a different calendar year.
example, stepping through dates on 2024-Oct-21:
stepping.through.dates.mp4
Fixes #386