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

date picker wraps around to 1 for the first of the current month #496

Conversation

krugerk
Copy link
Contributor

@krugerk krugerk commented Oct 21, 2024

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

@krugerk krugerk force-pushed the bugfix/issue386-date-picker-wraps-around-to-1-for-the-first-of-the-current-month branch from cbe6b00 to a6e7e93 Compare October 24, 2024 07:58
@theospears theospears self-assigned this Nov 6, 2024
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
@krugerk krugerk force-pushed the bugfix/issue386-date-picker-wraps-around-to-1-for-the-first-of-the-current-month branch from 04bd28c to e3b6e51 Compare November 12, 2024 11:23
Copy link
Collaborator

@theospears theospears left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. Thanks for including the video.

@@ -368,12 +371,14 @@ class GoalViewController: UIViewController, UIScrollViewDelegate, DatapointTabl
var components = DateComponents()
components.day = Int(self.dateStepper.value)

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 }
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: This seems like the return here should never happen. I like logging a warning in these cases.

@@ -368,12 +371,14 @@ class GoalViewController: UIViewController, UIScrollViewDelegate, DatapointTabl
var components = DateComponents()
components.day = Int(self.dateStepper.value)

let newDate = (calendar as NSCalendar?)?.date(byAdding: components, to: Date(), options: [])
let now = Date()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Contributor Author

@krugerk krugerk Nov 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

@theospears theospears merged commit 22f47bf into beeminder:master Nov 15, 2024
1 check passed
@krugerk krugerk deleted the bugfix/issue386-date-picker-wraps-around-to-1-for-the-first-of-the-current-month branch November 15, 2024 22:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Date picker wraps around to 1 for the first of the current month
2 participants