-
Notifications
You must be signed in to change notification settings - Fork 2
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
Localized trip times in notifications #201
Merged
Merged
Changes from 8 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
8c73c79
feat(TripMonitorNotification): Format trip times in initial reminder …
binh-dam-ibigroup f2c4d68
refactor(DateTimeUtils): Extract formatShortDate with locale.
binh-dam-ibigroup 7fd5e5c
test(DateTimeUtils): Move locale-based date format tests to new file.
binh-dam-ibigroup 7d3d9a1
refactor(TripMonitorNotification): Apply localized date to delayed tr…
binh-dam-ibigroup 10d0cfa
test(TripMonitorNotification): Refactor test file
binh-dam-ibigroup 77a5589
refactor(CheckMonitoredTrip): Cache OTP user result.
binh-dam-ibigroup 3685b30
test(CheckMonitoredtrip): Update expected formatted times in tests.
binh-dam-ibigroup 6d0b495
test(DateTimeUtils): Adjust Format.JS spelling
binh-dam-ibigroup 8811f9f
chore: Remove NOTIFICATIONS_TIME_FORMAT from docs and config templ.
binh-dam-ibigroup File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
src/test/java/org/opentripplanner/middleware/utils/DateTimeUtilsTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package org.opentripplanner.middleware.utils; | ||
|
||
import org.junit.jupiter.params.ParameterizedTest; | ||
import org.junit.jupiter.params.provider.Arguments; | ||
import org.junit.jupiter.params.provider.MethodSource; | ||
|
||
import java.time.ZonedDateTime; | ||
import java.util.Date; | ||
import java.util.Locale; | ||
import java.util.stream.Stream; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
class DateTimeUtilsTest { | ||
@ParameterizedTest | ||
@MethodSource("createDateFormatCases") | ||
void supportsDateFormatsInSeveralLocales(String localeTag, String result) { | ||
ZonedDateTime zonedTime = ZonedDateTime.of(2023, 2, 12, 17, 44, 0, 0, DateTimeUtils.getOtpZoneId()); | ||
assertEquals(result, DateTimeUtils.formatShortDate( | ||
Date.from(zonedTime.toInstant()), | ||
Locale.forLanguageTag(localeTag)) | ||
); | ||
} | ||
|
||
private static Stream<Arguments> createDateFormatCases() { | ||
return Stream.of( | ||
Arguments.of("en-US", "5:44 PM"), | ||
Arguments.of("fr", "17:44"), | ||
Arguments.of("es", "17:44"), | ||
Arguments.of("ko", "오후 5:44"), | ||
Arguments.of("vi", "17:44"), | ||
Arguments.of("zh", "下午5:44"), // Note: The Format.JS library shows 24-hour format for Chinese. | ||
Arguments.of("ru", "17:44"), | ||
Arguments.of("tl", "5:44 PM") | ||
); | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Can "NOTIFICATION_TIME_FORMAT" now be removed from env.yml.tmp, env.schema.json and README.md? It doesn't appear to be used anywhere else.
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.
Removed in 8811f9f, thanks for reminding me of these places!