Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {
- // ...
- } else if (compId == wxId) {
- // getComplication will throw an exception if the complication doesn't exist.
- // idk if this is actually possible in this case, but let's pretend it is
- // just for the sake of this example
- try {
- wxNow = (Complications.getComplication(wxId)).value;
- } catch (e) {
- wxNow = null;
- }
- if (wxNow == null && hasWx) {
- var tempTemp = Weather.getCurrentConditions();
- if (tempTemp != null) {
- wxNow = tempTemp.temperature;
- }
- }
- if (wxNow != null) {
- // since it's possible for wxNow to be a Number,
- // ensure it's a Float. this not only solves the issue
- // with the following conversion to fahrenheit (although that
- // could've been easily solved by changing 9 to 9.0 or
- // 5 to 5.0), but it also ensures
- // whatever code handles/displays wxNow later will
- // always see a consistent type (Float rather than Number)
- wxNow = wxNow.toFloat();
- if ((ForC != System.UNIT_METRIC)) {
- // changed 9 to 9.0 anyway, since it doesn't hurt
- wxNow = (wxNow * 9.0 / 5 + 32);
- }
- }
- // at this point, wxNow is either Float or null
- } else {
- // ...
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement