Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Wed 17 Sep 2014, 11:59
All times are UTC - 4
 Forum index » Taking the Puppy out for a walk » Suggestions
Optionally use UTC (rather than local) time on the HW clock
Moderators: Flash, Ian, JohnMurga
Post new topic   Reply to topic View previous topic :: View next topic
Page 1 of 1 [8 Posts]  
Author Message
Pizzasgood


Joined: 04 May 2005
Posts: 6270
Location: Knoxville, TN, USA

PostPosted: Sun 26 Apr 2009, 20:32    Post subject:  Optionally use UTC (rather than local) time on the HW clock
Subject description: Patch provided, tested on 4.1.2
 

Puppy defaults to using localtime on the hardware clock. The reason for this is that the vast majority of desktop Windows installations use localtime on the hardware clock. But when a computer doesn't have Windows on it (as on my laptop and my old computer) or when the user just doesn't give a turkey about the Windows install (my new machine), keeping the hardware clock set to UTC time has some alluring benefits: If you properly configure Linux to use your local timezone (using the named options, like US/Eastern, rather than the numbered ones), it will automatically handle daylight savings time. You also don't have to correct the hardware clock's time when you move through timezones (like if you have a laptop). You just correct the timezone option, and Puppy will compute the proper time. Plus, it just feels cooler.

No, those aren't major things, but I'm very lazy.

Using UTC time is quite easy - set the hardware clock to UTC time, and then whenever you use the hwclock program to read or set it, add the --utc option instead of the --localtime option. There are only three places in Puppy where that command is used: /usr/sbin/timezone-set, /usr/sbin/set-time-for-puppy, and /etc/rc.d/rc.country.

Rather than hardcoding it, I figured it would be best to just make it optional, so weirdos like me can use UTC while everybody else can use local time. So what I did was add a file named /etc/clock, which sets the variable "$HWCLOCKTIME" to either 'localtime' or 'utc'. Then the three scripts listed above can just include /etc/clock and use the variable to set the time based on the user's choice.

The patch I provide here makes those changes. It defaults to using localtime, so you'll still have to edit /etc/clock if you want to switch it. The patch is applied by extracting it and then using the patch program with the -p 1 option in /. For example, if I downloaded the patch directly to /, I'd run these commands:
Code:
cd /
gunzip optional_utc_time.patch.gz
patch -p 1 < optional_utc_time.patch

If applying this to an Unleashed tree, the package to be modified is 0rootfs_skeleton-XXX. Open a terminal inside the packages/0rootfs_skeleton-XXX/ directory and run the above commands (minus the cd one) providing the full path to the patch (unless you temporarily copy it into the 0rootfs_skeleton-XXX directory too, but if you do, be sure to remove it when you get done!).

That's the most reliable way to install these changes. Even if you've made other modifications to the three files it modifies, unless those changes interfere with the very few lines modified, they will be preserved.


If you want to know what exactly is changed, read the patch.

For those who don't know, a patch is simply the output of the "diff" command. They are human-readable. You just extract it and open it in Geany. Geany will even apply syntax highlighting. The lines to be added are in green and those to be removed are in read. (There is no concept of modifying a line - it is removed and replaced with the new line). So you can read them to find out what exactly is going to happen ahead of time.
optional_utc_time.patch.gz
Description  Provides an /etc/clock file which can be edited to specify whether Puppy should consider the
HW clock to be using utc or localtime. Modifies /usr/sbin/timezone-set,
/usr/sbin/set-time-for-puppy, and /etc/rc.d/rc.country.
gz

 Download 
Filename  optional_utc_time.patch.gz 
Filesize  1.25 KB 
Downloaded  986 Time(s) 

_________________
Between depriving a man of one hour from his life and depriving him of his life there exists only a difference of degree. --Muad'Dib

Back to top
View user's profile Send private message Visit poster's website 
lwill


Joined: 13 Jun 2008
Posts: 173
Location: City Of Lights

PostPosted: Wed 29 Apr 2009, 00:27    Post subject:  

Very Cool! Now I don't screw up Fedora or Puppy when I switch back and forth.

One note though- I needed to install the devx_XXX.sfs which contains 'patch'

Lyle
Back to top
View user's profile Send private message Visit poster's website 
Pizzasgood


Joined: 04 May 2005
Posts: 6270
Location: Knoxville, TN, USA

PostPosted: Sun 03 May 2009, 00:11    Post subject:  

I forgot that Puppy doesn't have patch included in the actual ISO. For those who don't have a devx_xxx.sfs file, here are .pet packages of the modified files and /etc/clock, for 4.1.2 and 4.2.

EDIT: I've put together and uploaded a package for 4.3-pre-beta-reloaded. I have not actually tested that version because frankly I'm too tired and lazy to care right now. Should be fine though. Anyway, if it doesn't work, complain and I'll do it right.

Edit: spelling
Edit: added package for 4.3-pre-beta-reloaded
optional_utc_time-430-pre-beta-reloaded.pet
Description  Replaces /usr/sbin/timezone-set, /usr/sbin/set-time-for-puppy, and /etc/rc.d/rc.country, and adds /etc/clock.
pet

 Download 
Filename  optional_utc_time-430-pre-beta-reloaded.pet 
Filesize  4.63 KB 
Downloaded  850 Time(s) 
optional_utc_time-412.pet
Description  Replaces /usr/sbin/timezone-set, /usr/sbin/set-time-for-puppy, and /etc/rc.d/rc.country, and adds /etc/clock.
pet

 Download 
Filename  optional_utc_time-412.pet 
Filesize  4.21 KB 
Downloaded  734 Time(s) 
optional_utc_time-420.pet
Description  Replaces /usr/sbin/timezone-set, /usr/sbin/set-time-for-puppy, and /etc/rc.d/rc.country, and adds /etc/clock.
pet

 Download 
Filename  optional_utc_time-420.pet 
Filesize  4.46 KB 
Downloaded  898 Time(s) 

_________________
Between depriving a man of one hour from his life and depriving him of his life there exists only a difference of degree. --Muad'Dib


Last edited by Pizzasgood on Sun 09 Aug 2009, 22:10; edited 2 times in total
Back to top
View user's profile Send private message Visit poster's website 
Pizzasgood


Joined: 04 May 2005
Posts: 6270
Location: Knoxville, TN, USA

PostPosted: Mon 03 Aug 2009, 19:14    Post subject:  

I guess I forgot to mention that this doesn't actually change your system over to using UTC. It adjusts the scripts to make them look at /etc/clock to find out what to use, but leaves it set to localtime.

If you want to actually use UTC time, you need to edit /etc/clock and change it from 'utc' to 'localtime'. Then the next time Puppy interacts with the hardware clock it will assume it uses UTC.

If your hardware clock was using localtime leading up to that, you'll also need to update it afterward. That can be done like this:
hwclock --systohc --utc

If your hardware clock was already using UTC but Puppy was using local and you just corrected Puppy, you can reload the time from the hardware clock like this:
hwclock --hctosys --utc


Alternately, in either of the above scenarios you could just go to "Menu->Desktop->Set date and time" and set the time.

_________________
Between depriving a man of one hour from his life and depriving him of his life there exists only a difference of degree. --Muad'Dib

Back to top
View user's profile Send private message Visit poster's website 
Pizzasgood


Joined: 04 May 2005
Posts: 6270
Location: Knoxville, TN, USA

PostPosted: Sun 09 Aug 2009, 23:47    Post subject:  

I wrote a very simple GUI to help with changing from UTC to localtime or back. After letting you choose which one to use, it lets you either reload the software clock from the hardware clock, or reset the hardware clock from the software clock.

For tonight you just get raw code. I need to sleep. Tomorrow I'll polish it a little, test it harder, and then make a .pet of it.
Code:
#!/bin/sh
. /etc/clock

if [ "$HWCLOCKTIME" = "utc" ]; then
    utc_flag='on'
    local_flag='off'
else
    utc_flag='off'
    local_flag='on'
fi

HWCLOCKTIME=$(Xdialog --radiolist "What should the hardware clock be interpreted as?" 0 0 0 localtime "" $local_flag utc "" $utc_flag 2>&1)

if [ "$HWCLOCKTIME" = "utc" ] || [ "$HWCLOCKTIME" = "localtime" ]; then
    sed -i "s/^HWCLOCKTIME=[^#]*/HWCLOCKTIME='$HWCLOCKTIME'/" /etc/clock

    RET=$(Xdialog --radiolist "Update the software clock or the hardware clock?" 0 0 0 software "to match hardware" on hardware "to match software" off 2>&1)

    if [ "$RET" = "software" ]; then
      hwclock --hctosys --$HWCLOCKTIME
    elif [ "$RET" = "hardware" ]; then
      hwclock --systohc --$HWCLOCKTIME
    fi

    Xdialog --infobox "Done" 0 0

fi

_________________
Between depriving a man of one hour from his life and depriving him of his life there exists only a difference of degree. --Muad'Dib

Back to top
View user's profile Send private message Visit poster's website 
Pizzasgood


Joined: 04 May 2005
Posts: 6270
Location: Knoxville, TN, USA

PostPosted: Mon 10 Aug 2009, 18:23    Post subject:  

Okay, I made a couple slight improvements. I added a menu entry, the dialog boxes now have their titles set, and it is now tolerant of whether the /etc/clock file exists yet. I also made it handle aborting slightly more gracefully. Note: it never undoes anything. If you hit "cancel" that means you're canceling that step, not the previous ones. There are only two steps, so if you cancel the first one the program ends. If you cancel at the second one, the /etc/clock file will have been modified, but neither the hw clock nor the software clock will be modified.

And please note that this is useless without installing the patch or one of the .pet packages with the pre-modified scripts. Otherwise, this will create/edit the /etc/clock file, but Puppy will just ignore it.
set_hwclock_type-0.1.pet
Description  GUI for use with the above patch to choose which type of time the HW clock is assumed to be in, and to assist with either updating the HW clock or the software clock afterward.
pet

 Download 
Filename  set_hwclock_type-0.1.pet 
Filesize  968 Bytes 
Downloaded  916 Time(s) 

_________________
Between depriving a man of one hour from his life and depriving him of his life there exists only a difference of degree. --Muad'Dib

Back to top
View user's profile Send private message Visit poster's website 
iscraigh

Joined: 03 Sep 2006
Posts: 276

PostPosted: Mon 10 Aug 2009, 20:58    Post subject:  

Thank you this has been my biggest irritant with puppy. It works with upup 476

Craig
Back to top
View user's profile Send private message 
nanasy2

Joined: 29 Sep 2011
Posts: 2

PostPosted: Thu 29 Sep 2011, 07:05    Post subject:  

I've put together and uploaded a package for 4.3-pre-beta-reloaded. I have not actually tested that version because frankly I'm too tired and lazy to care right now. Should be fine though. Anyway, if it doesn't work, complain and I'll do it right.
Back to top
View user's profile Send private message Visit poster's website 
Display posts from previous:   Sort by:   
Page 1 of 1 [8 Posts]  
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » Taking the Puppy out for a walk » Suggestions
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.0755s ][ Queries: 12 (0.0061s) ][ GZIP on ]