-
Notifications
You must be signed in to change notification settings - Fork 54
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
Support timezones for Puerto Rico #8225
Conversation
10ead1e
to
498ff68
Compare
@@ -144,6 +145,7 @@ public ZoneId getZoneIdByLookup(Lookup lookup) { | |||
return null; | |||
} | |||
|
|||
return ZoneId.of("US/" + timezoneInfo.timezoneCommonName); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Atlantic
for timezoneInfo.timezoneCommonName
.
If you see the list here, US/Atlantic
doesn't exist and was throwing an exception.
Decided to get the ZoneId
using the ZoneOffset
value instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think using the ZoneOffset
might run into issues with whether ZoneId.of()
is returning the correct zone since it would change based on whether the zone obeys daylight savings time or not. The slight inaccuracy might not matter, but the original issue that forced us to start handling time zones in bulk upload was a STLT having issues with some of their data being marked as an incorrect day due to time wackiness. Wondering if it would be better in this case to just specifically handle the Atlantic time zone and still use the existing US/commonName
to handle the other time zones since Smartystreets is still able to pinpoint what time zone the address is in compared to the possible ambiguity with utcOffset
? I wish Smartystreets simply returned the official time zone rather than just the common name 😩
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OOO thank you for this context, Mike! I will rethink my implementation!
@@ -37,6 +37,7 @@ public class DateTimeUtils { | |||
private static final ZoneId hawaiiTimeZoneId = ZoneId.of("US/Hawaii"); | |||
private static final ZoneId aleutianTimeZoneId = ZoneId.of("US/Aleutian"); | |||
private static final ZoneId samoaTimeZoneId = ZoneId.of("US/Samoa"); | |||
private static final ZoneId puertoRicoTimeZoneId = ZoneId.of("America/Puerto_Rico"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In addition to specifically handling Puerto Rico, I think it makes sense to catch whatever exception was being thrown and default the timezone to something (eastern time?). If this is a big deal we can add alerting for when it happens, but I think the failure state should be that the file still gets uploaded successfully.
Do we know how the single entry flow was handling this case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Re: handling the exception
Based on the fix implemented I don't think there would be an exception thrown anymore.
Because we were doing this before
return ZoneId.of("US/" + timezoneInfo.timezoneCommonName);
if timezoneInfo.timezoneCommonName
returned something like Atlantic
(like the valid Puerto Rico address did), we'd be trying to get the ZoneId.of("US/Atlantic")
which would throw the exception.
Now, since we are using the timezoneInfo.utcOffset
value instead of creating strings (that potentially don't exist) we should be good. If timezoneInfo == null
we already return null
. The method that calls getZoneIdByAddress
sets the default timezone (eastern time) if the value is null
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Re: single entry flow
I believe this is how we are handling it. We aren't extracting any timezone data from the ordering provider so we would not run into the same issue in the single entry flow based on my read of this 👀
@@ -62,9 +63,9 @@ public class DateTimeUtils { | |||
Map.entry("HI", hawaiiTimeZoneId), | |||
Map.entry("HST", hawaiiTimeZoneId), | |||
Map.entry("HDT", aleutianTimeZoneId), | |||
Map.entry("AS", samoaTimeZoneId), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally we should use the IANA Time Zone Database. The wiki page here has the latest 2024 list.
For this particular map, IIRC we wanted to allow users to include these valid time zone abbreviations in their upload since some people still use AS or ASM. For example, this site still includes AS and ASM as abbreviations even though the ISO official time zone is SST.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OOO thank you for letting me know! I'll take a look!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added "AS" and "ASM" back
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for looking into this! Left some questions about whether we can rely on utc offset vs the geolocated time zone name from smarty
@@ -62,9 +63,9 @@ public class DateTimeUtils { | |||
Map.entry("HI", hawaiiTimeZoneId), | |||
Map.entry("HST", hawaiiTimeZoneId), | |||
Map.entry("HDT", aleutianTimeZoneId), | |||
Map.entry("AS", samoaTimeZoneId), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally we should use the IANA Time Zone Database. The wiki page here has the latest 2024 list.
For this particular map, IIRC we wanted to allow users to include these valid time zone abbreviations in their upload since some people still use AS or ASM. For example, this site still includes AS and ASM as abbreviations even though the ISO official time zone is SST.
@@ -144,6 +145,7 @@ public ZoneId getZoneIdByLookup(Lookup lookup) { | |||
return null; | |||
} | |||
|
|||
return ZoneId.of("US/" + timezoneInfo.timezoneCommonName); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think using the ZoneOffset
might run into issues with whether ZoneId.of()
is returning the correct zone since it would change based on whether the zone obeys daylight savings time or not. The slight inaccuracy might not matter, but the original issue that forced us to start handling time zones in bulk upload was a STLT having issues with some of their data being marked as an incorrect day due to time wackiness. Wondering if it would be better in this case to just specifically handle the Atlantic time zone and still use the existing US/commonName
to handle the other time zones since Smartystreets is still able to pinpoint what time zone the address is in compared to the possible ambiguity with utcOffset
? I wish Smartystreets simply returned the official time zone rather than just the common name 😩
Back in draft while I address Mike's comments! - PLEASE DO NOT REVIEW! |
498ff68
to
1720d18
Compare
Quality Gate passedIssues Measures |
* Map of common name `time_zone` values returned from SmartyStreets and their corresponding | ||
* ZoneId https://www.smarty.com/docs/cloud/us-street-api | ||
*/ | ||
public static final Map<String, ZoneId> commonNameZoneIdMap = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
time_zone
common names that could be returned to specific ZoneId
s
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
strange that they use this list instead of something more standard
* Map of abbreviated timezones and their corresponding ZoneId Used for bulk upload timestamp | ||
* validations and when converting user-supplied timezones to a ZoneId | ||
*/ | ||
public static final Map<String, ZoneId> timezoneAbbreviationZoneIdMap = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
validTimeZoneIdMap
to hopefully be more descriptive 😅
Ready for review again! @mpbrown @mehansen @bobbywells52 @DanielSass |
The example file worked for dev3, but when I edited it to include the time zones within the date time values, it gave me these errors 🤔 Here's the edited copy that I tried on dev3 Also I noticed in the example file that we're using |
OO I checked that file and noticed that there's an extra whitespace in between the date and time so it was failing the DATE_TIME_REGEX check. I could add that as part of the ticket you alluded to to make our DATE_TIME_REGEX a little bit more robust. Does that work, Mike? 🤔 |
Ooof my bad, I used excel to edit the csv and forgot that excel adds a bunch of autoformatting on save which ends up messing with the csv 😬 Those edited time zones work as expected on dev3 now! I think it makes sense to create another ticket since we'll want to check with the rest of the team on what (if anything) we want to change about parsing date time inputs in the csv. It seems better to put it in the backlog for now and think about it more closely once we pivot our focus to revamping bulk upload |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great job on this! The time zone issues are a real nuisance so I appreciate you working on it!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm! thoughts on a low-urgency alert of some kind that lets us know if we ever log Unsupported timezone common name
? since we don't really have any guarantee that Smarty doesn't change the set of strings they use for that field
I like that idea! Would it be enough for me to create a ticket for it? Or would you like it included in this PR, @mehansen? 🤔 |
new ticket seems good to me! |
|
BACKEND PULL REQUEST
Related Issue
Changes Proposed
order_test_date
,specimen_collection_date
,testing_lab_specimen_received_date
,test_result_date
,date_result_released
10/18/2024
or10/18/2024 12:00
and NOT10/18/2024 12:00 ET
)AST
andADT
) so that these timezones can be used in dates for our bulk uploader and pass validationAdditional Information
Testing
main
dev3
AST
orADT
to any date timestamps should also pass the validations