|
@@ -51,16 +51,17 @@ sub get_sodexo_restaurants {
|
51
|
51
|
# Loop weekdays
|
52
|
52
|
for (my $weekday = 1; $weekday < 7; $weekday++) {
|
53
|
53
|
|
54
|
|
- # Get current unix timestamp and week
|
|
54
|
+ # Get current unix timestamp and week day
|
55
|
55
|
$s = strftime "%s", localtime;
|
56
|
56
|
$v = strftime "%w", localtime;
|
57
|
57
|
# Calculate current weekday
|
58
|
|
- $s = $s - ($v - 2 + $weekday) * 84600;
|
|
58
|
+ $s = $s + ($weekday - $v) * 86400;
|
59
|
59
|
$timestr = strftime "%Y/%m/%d", localtime($s);
|
60
|
60
|
|
61
|
61
|
my $url = "http://www.sodexo.fi/ruokalistat/output/daily_json/$kitchen/$timestr/fi";
|
62
|
62
|
my $temp_fname = "sodexo$count-$weekday.temp.js";
|
63
|
63
|
if (!-f $temp_fname || !$use_old) {
|
|
64
|
+ print $url . " -> " . $temp_fname . "\n";
|
64
|
65
|
system("wget -q --timeout=10 -O $temp_fname.tmp \"$url\" && mv $temp_fname.tmp $temp_fname");
|
65
|
66
|
}
|
66
|
67
|
if (-f $temp_fname) {
|