|
@@ -221,7 +221,7 @@ proc ::wds::output_current {chan geonames darksky} {
|
|
|
|
|
|
|
|
append output " \002Local time\002: "
|
|
append output " \002Local time\002: "
|
|
|
append output [clock format [dict get $darksky time] \
|
|
append output [clock format [dict get $darksky time] \
|
|
|
- -format "%H:%M" \
|
|
|
|
|
|
|
+ -format "%H:%M" \
|
|
|
-timezone :[dict get $darksky timezone] \
|
|
-timezone :[dict get $darksky timezone] \
|
|
|
]
|
|
]
|
|
|
|
|
|
|
@@ -280,9 +280,10 @@ proc ::wds::output_forecast {chan geonames darksky} {
|
|
|
if {$count == 5} {
|
|
if {$count == 5} {
|
|
|
break
|
|
break
|
|
|
}
|
|
}
|
|
|
- if {[dict get $forecast time] < [clock seconds]} {
|
|
|
|
|
|
|
+ if {![wds::should_show_forecast [dict get $darksky timezone] $forecast]} {
|
|
|
continue
|
|
continue
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
if {$output != ""} {
|
|
if {$output != ""} {
|
|
|
append output " "
|
|
append output " "
|
|
|
}
|
|
}
|
|
@@ -311,6 +312,27 @@ proc ::wds::output_forecast {chan geonames darksky} {
|
|
|
$::wds::output_cmd "PRIVMSG $chan :$output"
|
|
$::wds::output_cmd "PRIVMSG $chan :$output"
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+# We can get old forecast info. For example if it's Sunday we could get
|
|
|
|
|
+# Saturday's. We don't want to show that.
|
|
|
|
|
+#
|
|
|
|
|
+# We do want to show today's though. The time given in the forecast is at
|
|
|
|
|
+# 00:00:00 of the day.
|
|
|
|
|
+proc ::wds::should_show_forecast {timezone forecast} {
|
|
|
|
|
+ set now [clock seconds]
|
|
|
|
|
+
|
|
|
|
|
+ set today [::wds::format_ymd $timezone $now]
|
|
|
|
|
+ set forecast_day [::wds::format_ymd $timezone [dict get $forecast time]]
|
|
|
|
|
+
|
|
|
|
|
+ return $today == $forecast_day || [dict get $forecast time] >= $now
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+proc ::wds::format_ymd {timezone time} {
|
|
|
|
|
+ return [clock format $time \
|
|
|
|
|
+ -format "%Y-%m-%d" \
|
|
|
|
|
+ -timezone :$timezone \
|
|
|
|
|
+ ]
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
proc ::wds::celsius_to_fahrenheit {celsius} {
|
|
proc ::wds::celsius_to_fahrenheit {celsius} {
|
|
|
set fahrenheit [expr $celsius*9.0/5.0+32.0]
|
|
set fahrenheit [expr $celsius*9.0/5.0+32.0]
|
|
|
return [::wds::format_decimal $fahrenheit]
|
|
return [::wds::format_decimal $fahrenheit]
|