Fix the time difference between osx86 and
Windows in multiboot setups.
Preface: When you installed osx86, dual-booting with Windows,
you might notice your clock changed one or several hours
when booting Windows right after osx86 and vice versa.
There are a few fixes out there that apply to a Windows registry edit,
but the actual cause is your osx86 installation.
Why does this happen? Macs save the universal time (aka UTC)
of the world to the BIOS instead of the local time
of the time zone you live in (aka localtime).
And Windows assumes the BIOS time is the local time.
Wait, what? For instance, while running osx86,
the clock on your screen could read 4:02pm (local time),
but in your BIOS, the time could be 2:02pm (universal time).
And if you would reboot to Windows, the clock in the taskbar
will read 2:02pm because Windows reads the time from
the BIOS upon booting and assumes it's the local time.
How can we fix this? The best way to fix this, is to make an adjustment to the osx86 installation,
and not to your Windows OS because that's not where the problem is located.
In other words, we will create a script and a launchdaemon for your osx86 installation
to switch between UTC and localtime every time you run osx86.
Also note that this fix is for OS X 10.5 and above. (it might work on older versions of OS X though, but I can't test it.)
The scripts are made in plain text, to configure TextEdit to create plain text files, open up TextEdit's preferences window, and click "Plain text".
Just like in this screenshot.
1. First, we will make the script.
Create a file named localtime-toggle and place it in /sbin.
#!/bin/sh
to_utc() {
echo "localtime-toggle: Toggling to UTC."
date -f %m%d%H%M%Y `date -u +%m%d%H%M%Y`
}
to_localtime() {
echo "localtime-toggle: Toggling to localtime."
date -u -f %m%d%H%M%Y `date +%m%d%H%M%Y`
}
trap 'to_localtime; exit' term
to_utc
{ while true; do sleep 86400; done; } &
wait
2. Second, we will write the launchdaemon.
Create a file named org.osx86.localtime-toggle.plist
and place it in /System/Library/LaunchDaemons.
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>Label</key> <string>org.osx86.localtime-toggle</string> <key>Program</key> <string>/sbin/localtime-toggle</string> <key>KeepAlive</key> <true/> <key>RunAtLoad</key> <true/> <key>HopefullyExitsFirst</key> <true/> </dict> </plist>
3. Now, we have to execute some commands.
The first command makes our script executable:
$ sudo chmod +x /sbin/localtime-toggle
The second and third command will give our launchdaemon the right permissions:
$ sudo chown root /System/Library/LaunchDaemons/org.osx86.localtime-toggle.plist
$ sudo chmod 644 /System/Library/LaunchDaemons/org.osx86.localtime-toggle.plist
The final command will load our launchdaemon.
$ sudo launchctl load -w /System/Library/LaunchDaemons/org.osx86.localtime-toggle.plist
Now, if all went well, upon pressing enter on that last command, you should notice the time changed again.
If not, you did something wrong.
Don't worry,
check if the scripts you made are correct, if they are plain-text,
and if they have the correct names and places.
Also, press up in the terminal to see the history of commands you pressed, and check if they are correct.
4. Sync the clock with the internet, or manually correct the time, and you're done!
Finally, a few notes: I made this guide because there are a few different ways described on the internet that deal with this problem, but I think they are hard to find or incomplete.
I took some time and effort to write this, so if...
this solved your problem,
this didn't solve your problem,
I made any mistakes on the grammar or the technical side,
please write a comment to let me know.
Harm.



Sign In
Create Account










