[debian-edu-commits] debian-edu/ 54/64: Correct time zone calculations, try to ensure that the 07:00 wake up time is in the local time zone and not UTC.

Mike Gabriel sunweaver at debian.org
Wed Oct 23 09:51:57 UTC 2013


This is an automated email from the git hooks/post-receive script.

sunweaver pushed a commit to branch master
in repository shutdown-at-night.

commit f822644162513122c806e8de393458115cffdd49
Author: Petter Reinholdtsen <pere at hungry.com>
Date:   Sun Jul 21 10:43:28 2013 +0000

    Correct time zone calculations, try to ensure that the 07:00 wake
    up time is in the local time zone and not UTC.
    
    git-svn-id: svn+ssh://svn.debian.org/svn/debian-edu/trunk/src/shutdown-at-night@81779 6e500793-9bee-0310-a5b0-9d0909bd054d
---
 debian/changelog  |    2 ++
 shutdown-at-night |    7 ++++++-
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/debian/changelog b/debian/changelog
index 855fffc..d1ad3c0 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -2,6 +2,8 @@ shutdown-at-night (0.12) UNRELEASED; urgency=low
 
   * Add support for using the ACPI RTC wakeup interface to wake up the
     machine (Closes: #717441).
+  * Correct time zone calculations, try to ensure that the 07:00 wake
+    up time is in the local time zone and not UTC.
 
  -- Petter Reinholdtsen <pere at debian.org>  Mon, 15 Jul 2013 17:26:08 +0200
 
diff --git a/shutdown-at-night b/shutdown-at-night
index 5d83a27..9734995 100755
--- a/shutdown-at-night
+++ b/shutdown-at-night
@@ -37,11 +37,16 @@ enabled_for_host() {
     return 1
 }
 
+# Take wakeup hour:minute in local time zone and return wake up time
+# in seconds since EPOC UTC, radomized around the target wakeup time.
 whentowakeup() {
     wakeuptime=$1
     # Spread the BIOS wakeup time across a 20 minute period, to avoid
     # all of them waking up at the same time, killing a fuse.
-    echo $(( $(date -u +%s -d "tomorrow $wakeuptime") - 600 + $RANDOM % 1200))
+
+    # Convert local target time in seconds since EPOC UTC
+    targettime=$(date +%s -d "tomorrow $wakeuptime $(date +%z)")
+    echo $(( $targettime - 600 + $RANDOM % 1200))
 }
 
 nvramwakeup() {

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-edu/pkg-team/shutdown-at-night.git



More information about the debian-edu-commits mailing list