shell script to set system preferences time format to short/24hour

Hi,

I have written a script which parses out a non-friendly .ics file and adds events to ical… There is a requirement to set the time format in System Preferences to short/24hour format otherwise the events don’t get handled correctly.

I currently have a dialog that informs the user to set these prefs manually and then open the relevant tab in System Preferences.

set alertResult to display alert ¬
		"Some housekeeping - Press Continue to open" & return & "SYSTEM PREFERENCES" & return & return & "and customize the short time to 24 hour format." buttons {"Cancel", "Continue"} as warning ¬
		default button "Continue" cancel button "Cancel" giving up after 60
	
	tell application "System Preferences"
		activate
		reveal anchor "Formats" of pane id "com.apple.Localization"
	end tell

this is OK however, I’m searching for a way to set these preferences without user interaction via a shell script or similar.

I have looked at the excellent tutorial in “UnScripted” here http://macscripter.net/viewtopic.php?id=24773 written by Kai however, I can’t find any reference in apropos to setting time formats.

Any help would be greatly appreciated.

Cheers

This might help.
Use the scriplet near the end of the post to read the clock’s plist.

Ah alastor933, you come to my rescue again. Thanks for your previous help, the script is working beautifully.

The settings I am trying to get to are the ones hidden in the International - Formats - Times section of Sys Prefs. not the menu clocks options of 24hour time display.

This is just polish, so no biggie if it can’t be done…

What doesn’t handle them correctly? The system or your script? It’s very bad form to fool around with a user’s preferences ” unless you’re the user, of course.

Sorry - no. When you select a different region in that panel it will also modify the clock setting, when it’s different from the previous one.

But Nigel is right (of course). When your script manipulates the dates it is fully responsible for the result.