Advertisement
Guest User

Untitled

a guest
May 19th, 2025
7
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. {
  2. // ...
  3. } else if (compId == wxId) {
  4. // getComplication will throw an exception if the complication doesn't exist.
  5. // idk if this is actually possible in this case, but let's pretend it is
  6. // just for the sake of this example
  7. try {
  8. wxNow = (Complications.getComplication(wxId)).value;
  9. } catch (e) {
  10. wxNow = null;
  11. }
  12.  
  13. if (wxNow == null && hasWx) {
  14. var tempTemp = Weather.getCurrentConditions();
  15. if (tempTemp != null) {
  16. wxNow = tempTemp.temperature;
  17. }
  18. }
  19.  
  20. if (wxNow != null) {
  21. // since it's possible for wxNow to be a Number,
  22. // ensure it's a Float. this not only solves the issue
  23. // with the following conversion to fahrenheit (although that
  24. // could've been easily solved by changing 9 to 9.0 or
  25. // 5 to 5.0), but it also ensures
  26. // whatever code handles/displays wxNow later will
  27. // always see a consistent type (Float rather than Number)
  28. wxNow = wxNow.toFloat();
  29.  
  30. if ((ForC != System.UNIT_METRIC)) {
  31. // changed 9 to 9.0 anyway, since it doesn't hurt
  32. wxNow = (wxNow * 9.0 / 5 + 32);
  33. }
  34. }
  35. // at this point, wxNow is either Float or null
  36. } else {
  37. // ...
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement