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

fix(types): Handle 12-hour time formats and narrow non-breaking spaces #26

Merged
merged 3 commits into from
Oct 26, 2024

Conversation

irvinlim
Copy link
Owner

@irvinlim irvinlim commented Oct 4, 2024

Fixes #25.

Copy link
Collaborator

@tedpearson tedpearson left a comment

Choose a reason for hiding this comment

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

Just a few minor comments, but seems good overall.

BTW, It irks me a little how inefficient the try-each-format parsing is, but while that could be improved, it's not necessary to over-engineer a solution for code that doesn't run very often. 🙂

pkg/healthautoexport/types.go Outdated Show resolved Hide resolved
pkg/healthautoexport/types.go Outdated Show resolved Hide resolved
pkg/healthautoexport/types.go Outdated Show resolved Hide resolved
pkg/healthautoexport/types.go Outdated Show resolved Hide resolved
@irvinlim
Copy link
Owner Author

irvinlim commented Oct 24, 2024

BTW, It irks me a little how inefficient the try-each-format parsing is, but while that could be improved, it's not necessary to over-engineer a solution for code that doesn't run very often. 🙂

I've added a lastUsedTimeFormat global variable that caches the last-known good time format that was used, to address this concern. I think this should be suitable for most use cases, since we likely can easily speed up time parsing of many timestamps in a single JSON blob by short-circuiting to the correct time format, and it's also highly unlikely that users would use different iOS region settings that sync to the same ingester server. 🙂

On top of that, I also think we should support both AM/PM and am/pm time formats. Go's time.Parse differentiates between the two 😮‍💨 But with the caching of the lastUsedTimeFormat I think the cost of adding new formats should be largely mitigated!

For your review again!

@irvinlim irvinlim changed the title fix(types): Handle 12-hour time formats and non-breaking spaces fix(types): Handle 12-hour time formats and narrow non-breaking spaces Oct 24, 2024
Copy link
Collaborator

@tedpearson tedpearson left a comment

Choose a reason for hiding this comment

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

I've added a lastUsedTimeFormat global variable that caches the last-known good time format that was used, to address this concern. I think this should be suitable for most use cases, since we likely can easily speed up time parsing of many timestamps in a single JSON blob by short-circuiting to the correct time format, and it's also highly unlikely that users would use different iOS region settings that sync to the same ingester server. 🙂

Yeah this is a decent improvement. 🙂

On top of that, I also think we should support both AM/PM and am/pm time formats. Go's time.Parse differentiates between the two 😮‍💨 But with the caching of the lastUsedTimeFormat I think the cost of adding new formats should be largely mitigated!

Works for me! This PR looks good now.

@irvinlim irvinlim merged commit 1cf15d5 into main Oct 26, 2024
3 checks passed
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.

Support 12-hour time formats
2 participants