-
Notifications
You must be signed in to change notification settings - Fork 34
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: support distance display in metric units #736
Open
doncicuto
wants to merge
5
commits into
opentripplanner:master
Choose a base branch
from
doncicuto:fix-116
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
bb5cf33
fix(itinerary-body): allow metric units for distance
doncicuto 256a164
fix: use humanizeDistanceString in LocationField
doncicuto 821721c
fix: add useMetricUnits to printable-itinerary AccessLeg
doncicuto e1c6678
fix: add areMetricUnitsUsed and use react-intl
doncicuto ff248bd
fix: remove useMetricUnits remaining stories
doncicuto 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// Reference: https://en.wikipedia.org/wiki/Mile | ||
// While most countries abandoned the mile when switching to the metric system, | ||
// the international mile continues to be used in some countries, such as Liberia, | ||
// Myanmar, the United Kingdom and the United States. It is also used in a number | ||
// of territories with less than a million inhabitants, most of which are UK or US territories, | ||
// or have close historical ties with the UK or US: American Samoa, Bahamas, Belize, | ||
// British Virgin Islands, Cayman Islands, Dominica, Falkland Islands, Grenada,Guam, | ||
// The N. Mariana Islands, Samoa, St. Lucia, St. Vincent & The Grenadines, St. Helena, | ||
// St. Kitts & Nevis, the Turks & Caicos Islands, and the US Virgin Islands. | ||
// The mile is even encountered in Canada, though this is predominantly in rail transport | ||
// and horse racing, as the roadways have been metricated since 1977. | ||
|
||
export const areMetricUnitsUsed = (locale: string): boolean => { | ||
const localesUsingImperialUnits = [ | ||
"en-US", | ||
"en-GB", | ||
"en-LR", | ||
"en-AS", | ||
"sm-AS", | ||
"en-BS", | ||
"en-BZ", | ||
"es-BZ", | ||
"en-VG", | ||
"en-KY", | ||
"en-DM", | ||
"en-GD", | ||
"en-GU", | ||
"en-MP", | ||
"en-WS", | ||
"sm-WS", | ||
"en-LC", | ||
"en-VC", | ||
"en-SH", | ||
"en-KN", | ||
"en-TC", | ||
"en-VI", | ||
"my-MM" | ||
]; | ||
|
||
return !localesUsingImperialUnits.includes(locale); | ||
}; | ||
|
||
export default areMetricUnitsUsed; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3246,6 +3246,11 @@ | |
resolved "https://registry.yarnpkg.com/@open-draft/until/-/until-1.0.3.tgz#db9cc719191a62e7d9200f6e7bab21c5b848adca" | ||
integrity sha512-Aq58f5HiWdyDlFffbbSjAlv596h/cOnt2DO1w3DOC7OJ5EHs0hd/nycJfiu9RJbT6Yk6F1knnRRXNSpxoIVZ9Q== | ||
|
||
"@opentripplanner/[email protected]": | ||
version "6.4.0" | ||
resolved "https://registry.yarnpkg.com/@opentripplanner/types/-/types-6.4.0.tgz#6f7a3475ea982c7b7d8b2f1383a6d775dfabe62a" | ||
integrity sha512-PS+CUwETLf0WzAUZg3qiey+SBigaf0CfknKF1XMOM+zJVc2c8nN34hgnwV7sS+RKs030KZFAgIn8p035ErcBuQ== | ||
|
||
"@peculiar/asn1-schema@^2.1.6", "@peculiar/asn1-schema@^2.3.0": | ||
version "2.3.3" | ||
resolved "https://registry.yarnpkg.com/@peculiar/asn1-schema/-/asn1-schema-2.3.3.tgz#21418e1f3819e0b353ceff0c2dad8ccb61acd777" | ||
|
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.
Would it be possible to refactor
humanizeDistanceString
to use theintl
object it gets anyway to avoid having to importcoreUtils
everywhere?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'd say don't remove the manual override (for backwards compatibility) but instead use it as an override -- a way to force metric even if the locale isn't metric