ubuntu-touch-coreapps-reviewers team mailing list archive
-
ubuntu-touch-coreapps-reviewers team
-
Mailing list archive
-
Message #05319
[Merge] lp:~vthompson/ubuntu-weather-app/adjust-sunrise-sunset-tz into lp:ubuntu-weather-app/reboot
Victor Thompson has proposed merging lp:~vthompson/ubuntu-weather-app/adjust-sunrise-sunset-tz into lp:ubuntu-weather-app/reboot.
Commit message:
* Use the timezone of the Location to display sunrise/sunset times.
Requested reviews:
Ubuntu Weather Developers (ubuntu-weather-dev)
For more details, see:
https://code.launchpad.net/~vthompson/ubuntu-weather-app/adjust-sunrise-sunset-tz/+merge/274834
* Use the timezone of the Location to display sunrise/sunset times.
--
Your team Ubuntu Weather Developers is requested to review the proposed merge of lp:~vthompson/ubuntu-weather-app/adjust-sunrise-sunset-tz into lp:ubuntu-weather-app/reboot.
=== modified file 'app/data/WeatherApi.js'
--- app/data/WeatherApi.js 2015-10-14 23:53:23 +0000
+++ app/data/WeatherApi.js 2015-10-18 22:58:29 +0000
@@ -552,10 +552,12 @@
todayDate = date;
}
tmpResult[day] = _buildDayFormat(date, dayData, nowMs);
- var sunrise = new Date(sunRiseSet.rise*1000);
- var sunset = new Date(sunRiseSet.set*1000);
- tmpResult[day].sunrise = sunrise.toLocaleTimeString();
- tmpResult[day].sunset = sunset.toLocaleTimeString();
+ var timezoneOffset = new Date().getTimezoneOffset();
+ var offset = (location.timezone && location.timezone.dstOffset) ? (location.timezone.dstOffset*60 + timezoneOffset)*60*1000: 0
+ var sunrise = new Date(sunRiseSet.rise*1000 + offset);
+ var sunset = new Date(sunRiseSet.set*1000 + offset);
+ tmpResult[day].sunrise = sunrise.toTimeString();
+ tmpResult[day].sunset = sunset.toTimeString();
}
//
if(data["forecast"] !== undefined) {
=== modified file 'app/ui/LocationPane.qml'
--- app/ui/LocationPane.qml 2015-10-15 14:15:10 +0000
+++ app/ui/LocationPane.qml 2015-10-18 22:58:29 +0000
@@ -140,6 +140,10 @@
function getDayData(data) {
var tempUnits = settings.tempScale === "°C" ? "metric" : "imperial"
+ var timezoneOffset = new Date().getTimezoneOffset();
+ var offset = (data.location.timezone && data.location.timezone.dstOffset) ? (data.location.timezone.dstOffset*60 + timezoneOffset)*60*1000: 0
+ var sunrise = new Date(SunCalc.SunCalc.getTimes(getDate(data.date), data.location.coord.lat, data.location.coord.lon).sunrise.getTime() + offset)
+ var sunset = new Date(SunCalc.SunCalc.getTimes(getDate(data.date), data.location.coord.lat, data.location.coord.lon).sunset.getTime() + offset)
return {
day: formatTimestamp(data.date, 'dddd'),
@@ -149,8 +153,8 @@
condition: emptyIfUndefined(data.condition),
chanceOfRain: emptyIfUndefined(data.propPrecip, "%"),
humidity: emptyIfUndefined(data.humidity, "%"),
- sunrise: data.sunrise || SunCalc.SunCalc.getTimes(getDate(data.date), data.location.coord.lat, data.location.coord.lon).sunrise.toLocaleTimeString(),
- sunset: data.sunset || SunCalc.SunCalc.getTimes(getDate(data.date), data.location.coord.lat, data.location.coord.lon).sunset.toLocaleTimeString(),
+ sunrise: data.sunrise || sunrise.toTimeString(),
+ sunset: data.sunset || sunset.toTimeString(),
uvIndex: emptyIfUndefined(data.uv),
wind: data[tempUnits].windSpeed === undefined || data.windDir === undefined
? "" : Math.round(data[tempUnits].windSpeed) + settings.windUnits + " " + data.windDir
@@ -201,10 +205,11 @@
hourlyForecasts = hourlyForecasts.concat(forecasts[x].hourly)
}
- // Copy the coords of the location
+ // Copy the coords and timezone of the location
// so that sun{rise,set} work with OWM
forecasts[x].location = {
coord: data.location.coord,
+ timezone: data.location.timezone
};
if (x === 0) {
=== modified file 'debian/changelog'
--- debian/changelog 2015-10-18 15:51:11 +0000
+++ debian/changelog 2015-10-18 22:58:29 +0000
@@ -30,6 +30,7 @@
languages.
* Show the bottom loading animation (LoadingIndicator) on the LocationsPage. (LP: #1490040)
* Add FakeHeader component to ease the bottom edge transition.
+ * Use the timezone of the Location to display sunrise/sunset times.
[ Andrew Hayzen ]
* Add mocked locations for autopilot and add a test using the data
Follow ups