forked from raycast/extensions
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Weather: Add weather 0.3.0 (raycast#74)
* add multi language support for en, de and fr * add better error message * add support for switching the unit-system * add default query * remove multi language support * add icon for daily forecast items
- Loading branch information
Showing
5 changed files
with
185 additions
and
17 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import { getPreferenceValues } from "@raycast/api"; | ||
|
||
export function getUnitSystem(): string { | ||
const pref = getPreferenceValues(); | ||
let result = UnitSystem.Metric; | ||
let us = (pref.unitsystem as string) || undefined; | ||
if (us && (us === UnitSystem.Metric || us === UnitSystem.Imperial)) { | ||
result = us; | ||
} | ||
return result; | ||
} | ||
|
||
export function getWttrTemperaturePostfix(): string { | ||
if (getUnitSystem() === UnitSystem.Imperial) { | ||
return "F"; | ||
} else { | ||
return "C"; | ||
} | ||
} | ||
|
||
export function getTemperatureUnit(): string { | ||
if (getUnitSystem() === UnitSystem.Imperial) { | ||
return "°F"; | ||
} else { | ||
return "°C"; | ||
} | ||
} | ||
|
||
export function getWttrWindPostfix(): string { | ||
if (getUnitSystem() === UnitSystem.Imperial) { | ||
return "Miles"; | ||
} else { | ||
return "Kmph"; | ||
} | ||
} | ||
|
||
export function getWindUnit(): string { | ||
if (getUnitSystem() === UnitSystem.Imperial) { | ||
return "mph"; | ||
} else { | ||
return "km/h"; | ||
} | ||
} | ||
|
||
export enum UnitSystem { | ||
Metric = "metric", | ||
Imperial = "imperial" | ||
} |
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