Motherboard Forums


Reply
Thread Tools Display Modes

Terminal command to get user's time/date customisations

 
 
Tim Streater
Guest
Posts: n/a
 
      04-05-2012, 08:16 PM
I'd like to be able to get the user's settings for time/date, so that
when I prepare times and dates for them, I can format it to their system
settings. Is there a Terminal command I can use to acquire this info?

Thanks,

--
Tim

"That excessive bail ought not to be required, nor excessive fines imposed,
nor cruel and unusual punishments inflicted" -- Bill of Rights 1689
 
Reply With Quote
 
 
 
 
paris2venice@gmail.com
Guest
Posts: n/a
 
      04-05-2012, 10:54 PM
On Thursday, April 5, 2012 1:16:56 PM UTC-7, Tim Streater wrote:
> I'd like to be able to get the user's settings for time/date, so that
> when I prepare times and dates for them, I can format it to their system
> settings. Is there a Terminal command I can use to acquire this info?
>
> Thanks,
>
> --
> Tim
>
> "That excessive bail ought not to be required, nor excessive fines imposed,
> nor cruel and unusual punishments inflicted" -- Bill of Rights 1689


man date

However, you seem to imply you want to obtain these remotely? If so, you would have to have their admin password and you don't state that you do.

If you do:

ssh admin@111.222.333.444 'date' # where date is the command you want to execute on their system

I have no idea why you would need their date format though. In what situation could this possibly be necessary? Thus, I can't really answer what it is you are seeking.
 
Reply With Quote
 
 
 
 
Michael Vilain
Guest
Posts: n/a
 
      04-06-2012, 12:19 AM
In article <(E-Mail Removed)>,
Tim Streater <(E-Mail Removed)> wrote:

> I'd like to be able to get the user's settings for time/date, so that
> when I prepare times and dates for them, I can format it to their system
> settings. Is there a Terminal command I can use to acquire this info?
>
> Thanks,


I think the CLI access to system defaults is through the 'defaults'
command. Here's an article on the trove of various settings that
someone has compiled:

<http://www.macgasm.net/2012/04/03/cu...-giant-list-of
-63-defaults-hacks-for-the-terminal/>

<https://github.com/mathiasbynens/dotfiles/blob/master/.osx>

But it doesn't list the date/time format. I spent the better part of 2
hours poking around preferences files and didn't find anything that lead
me to where the system date/time format is stored. I know it's
available to compiled applications. My guess is you're going to have to
write a command-line utility to ask MacOS "what is your system date/time
setting for 'short', 'medium', 'long', and 'full'. The APIs for this
are documented, so it shouldn't be to hard.

--
DeeDee, don't press that button! DeeDee! NO! Dee...
[I filter all Goggle Groups posts, so any reply may be automatically ignored]


 
Reply With Quote
 
Wes Groleau
Guest
Posts: n/a
 
      04-06-2012, 01:41 AM
On 04-05-2012 20:19, Michael Vilain wrote:
> Tim Streater<(E-Mail Removed)> wrote:
>> I'd like to be able to get the user's settings for time/date, so that
>> when I prepare times and dates for them, I can format it to their system
>> settings. Is there a Terminal command I can use to acquire this info?
>>
>> Thanks,

>
> I think the CLI access to system defaults is through the 'defaults'
> command. Here's an article on the trove of various settings that
> someone has compiled:
>
> <http://www.macgasm.net/2012/04/03/cu...-giant-list-of
> -63-defaults-hacks-for-the-terminal/>
>
> <https://github.com/mathiasbynens/dotfiles/blob/master/.osx>
>
> But it doesn't list the date/time format. I spent the better part of 2
> hours poking around preferences files and didn't find anything that lead
> me to where the system date/time format is stored. I know it's
> available to compiled applications. My guess is you're going to have to
> write a command-line utility to ask MacOS "what is your system date/time
> setting for 'short', 'medium', 'long', and 'full'. The APIs for this
> are documented, so it shouldn't be to hard.


Change the format, then search for a file that has just been changed.
Look in it to see what you can find.


--
Wes Groleau

Armchair Activism: http://www.breakthechain.org/armchair.html

 
Reply With Quote
 
Tim Streater
Guest
Posts: n/a
 
      04-06-2012, 09:41 AM
In article
<403539.94.1333666441771.JavaMail.geo-discussion-forums@ynbj3>,
(E-Mail Removed) wrote:

> On Thursday, April 5, 2012 1:16:56 PM UTC-7, Tim Streater wrote:
> > I'd like to be able to get the user's settings for time/date, so that
> > when I prepare times and dates for them, I can format it to their system
> > settings. Is there a Terminal command I can use to acquire this info?


> man date
>
> However, you seem to imply you want to obtain these remotely? If so, you
> would have to have their admin password and you don't state that you do.
>
> If you do:
>
> ssh admin@111.222.333.444 'date' # where date is the command you want
> to execute on their system
>
> I have no idea why you would need their date format though. In what
> situation could this possibly be necessary? Thus, I can't really answer
> what it is you are seeking.


No, this would all be on the user's own machine. My app runs a PHP CLI
script at startup to initialise a number of things. Running a CLI
command from within it to obtain the users time/date prefs would be nice.

--
Tim

"That excessive bail ought not to be required, nor excessive fines imposed,
nor cruel and unusual punishments inflicted" -- Bill of Rights 1689
 
Reply With Quote
 
Tim Streater
Guest
Posts: n/a
 
      04-06-2012, 09:41 AM
In article <jllhkj$aie$(E-Mail Removed)>,
Wes Groleau <(E-Mail Removed)> wrote:

> On 04-05-2012 20:19, Michael Vilain wrote:
> > Tim Streater<(E-Mail Removed)> wrote:
> >> I'd like to be able to get the user's settings for time/date, so that
> >> when I prepare times and dates for them, I can format it to their system
> >> settings. Is there a Terminal command I can use to acquire this info?


> > I think the CLI access to system defaults is through the 'defaults'
> > command. Here's an article on the trove of various settings that
> > someone has compiled:
> >
> > <http://www.macgasm.net/2012/04/03/cu...-giant-list-of
> > -63-defaults-hacks-for-the-terminal/>
> >
> > <https://github.com/mathiasbynens/dotfiles/blob/master/.osx>
> >
> > But it doesn't list the date/time format. I spent the better part of 2
> > hours poking around preferences files and didn't find anything that lead
> > me to where the system date/time format is stored. I know it's
> > available to compiled applications. My guess is you're going to have to
> > write a command-line utility to ask MacOS "what is your system date/time
> > setting for 'short', 'medium', 'long', and 'full'. The APIs for this
> > are documented, so it shouldn't be to hard.

>
> Change the format, then search for a file that has just been changed.
> Look in it to see what you can find.


Thanks both, I'll look into that.

--
Tim

"That excessive bail ought not to be required, nor excessive fines imposed,
nor cruel and unusual punishments inflicted" -- Bill of Rights 1689
 
Reply With Quote
 
Paul Sture
Guest
Posts: n/a
 
      04-06-2012, 01:47 PM
On Thu, 05 Apr 2012 21:16:56 +0100, Tim Streater wrote:

> I'd like to be able to get the user's settings for time/date, so that
> when I prepare times and dates for them, I can format it to their system
> settings. Is there a Terminal command I can use to acquire this info?
>
> Thanks,


Not sure about customisations but here:

defaults read "Apple Global Domain"

gives me things AppleLanguages containing my language preferece and
specifically this line:

AppleLocale = "de_CH";

where I use the date and time formats which are the default for de_CH

--
Paul Sture
 
Reply With Quote
 
Tim Streater
Guest
Posts: n/a
 
      04-06-2012, 03:36 PM
In article <(E-Mail Removed)>, Paul Sture <(E-Mail Removed)>
wrote:

> On Thu, 05 Apr 2012 21:16:56 +0100, Tim Streater wrote:
>
> > I'd like to be able to get the user's settings for time/date, so that
> > when I prepare times and dates for them, I can format it to their system
> > settings. Is there a Terminal command I can use to acquire this info?
> >
> > Thanks,

>
> Not sure about customisations but here:
>
> defaults read "Apple Global Domain"
>
> gives me things AppleLanguages containing my language preferece and
> specifically this line:
>
> AppleLocale = "de_CH";
>
> where I use the date and time formats which are the default for de_CH


Thanks. Looks like com.apple.systempreferences.plist in
~/Library/Preferences contains something - but I suspect only if you
customise your date/time settings away from the locale defaults.

--
Tim

"That excessive bail ought not to be required, nor excessive fines imposed,
nor cruel and unusual punishments inflicted" -- Bill of Rights 1689
 
Reply With Quote
 
Michael Vilain
Guest
Posts: n/a
 
      04-06-2012, 07:25 PM
In article <(E-Mail Removed)>,
Tim Streater <(E-Mail Removed)> wrote:

> In article <jllhkj$aie$(E-Mail Removed)>,
> Wes Groleau <(E-Mail Removed)> wrote:
>
> > On 04-05-2012 20:19, Michael Vilain wrote:
> > > Tim Streater<(E-Mail Removed)> wrote:
> > >> I'd like to be able to get the user's settings for time/date, so that
> > >> when I prepare times and dates for them, I can format it to their system
> > >> settings. Is there a Terminal command I can use to acquire this info?

>
> > > I think the CLI access to system defaults is through the 'defaults'
> > > command. Here's an article on the trove of various settings that
> > > someone has compiled:
> > >
> > > <http://www.macgasm.net/2012/04/03/cu...-giant-list-of
> > > -63-defaults-hacks-for-the-terminal/>
> > >
> > > <https://github.com/mathiasbynens/dotfiles/blob/master/.osx>
> > >
> > > But it doesn't list the date/time format. I spent the better part of 2
> > > hours poking around preferences files and didn't find anything that lead
> > > me to where the system date/time format is stored. I know it's
> > > available to compiled applications. My guess is you're going to have to
> > > write a command-line utility to ask MacOS "what is your system date/time
> > > setting for 'short', 'medium', 'long', and 'full'. The APIs for this
> > > are documented, so it shouldn't be to hard.

> >
> > Change the format, then search for a file that has just been changed.
> > Look in it to see what you can find.

>
> Thanks both, I'll look into that.


I did just as Wes suggested, which is why I spent 2 hours looking
around. Didn't find anything that jumped out at me. I'll leave this to
someone who really wants to solve the problem rather than someone who's
just curious. It may require someone poking around in source code to
find it. My guess is that Apple doesn't want a published interface to
this and so hides it from the user.

--
DeeDee, don't press that button! DeeDee! NO! Dee...
[I filter all Goggle Groups posts, so any reply may be automatically ignored]


 
Reply With Quote
 
Michael Vilain
Guest
Posts: n/a
 
      04-06-2012, 07:46 PM
In article <(E-Mail Removed)>,
Tim Streater <(E-Mail Removed)> wrote:

> In article <(E-Mail Removed)>, Paul Sture <(E-Mail Removed)>
> wrote:
>
> > On Thu, 05 Apr 2012 21:16:56 +0100, Tim Streater wrote:
> >
> > > I'd like to be able to get the user's settings for time/date, so that
> > > when I prepare times and dates for them, I can format it to their system
> > > settings. Is there a Terminal command I can use to acquire this info?
> > >
> > > Thanks,

> >
> > Not sure about customisations but here:
> >
> > defaults read "Apple Global Domain"
> >
> > gives me things AppleLanguages containing my language preferece and
> > specifically this line:
> >
> > AppleLocale = "de_CH";
> >
> > where I use the date and time formats which are the default for de_CH

>
> Thanks. Looks like com.apple.systempreferences.plist in
> ~/Library/Preferences contains something - but I suspect only if you
> customise your date/time settings away from the locale defaults.


It contained nothing like what I had setup in my Date/Time language
customization. I finally figure out some interesting find-foo. I
created a file with touch, then did a find on ~/Library/Preferences with
-name "com.apple.*" -cnewer <file> -ls, and it identified

~/Library/Preferences/com.apple.systempreferences.plist

The only thing with "[Dd]ate" in the key name is
"AppleICUDateFormatStrings" which is always set to "dd-MMM-yyyy" no
matter what I specify. This is why I say that Apple has embedded this
deeply into the OS.

php 5.3 uses various language-specific ways of formatting dates. But I
don't know if Apple modified the native php to read the system language
and respond correctly. If you run your php application on a server, all
this is moot anyway. It will only correctly report date format on a
local machine once you get that working.

Seriously, you should write an Xcode application that queries the Apple
Language Date/Time format. I use an application which shows dates with
my System's 'short' format until I complained that I wanted to set the
format myself. I don't see an easy scriptable solution to this.

--
DeeDee, don't press that button! DeeDee! NO! Dee...
[I filter all Goggle Groups posts, so any reply may be automatically ignored]


 
Reply With Quote
 
 
 
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Terminal command to close terminal Oliver Marshall Apple 4 02-27-2007 03:02 AM
[Ultra 10] How to change monochrome terminal to color terminal? =?iso-8859-2?Q?Artur_D=EAbski?= Sun Hardware 0 01-16-2006 11:22 AM
terminal with reply of defaults command: no such command Klimt Apple 1 06-25-2004 10:15 PM
terminal command question gary thomson Apple 5 06-19-2004 05:14 PM
terminal command for turning on video mirroring George Apple 0 05-31-2004 11:26 PM


All times are GMT. The time now is 06:12 PM.


Welcome!
Welcome to Motherboard Point
 

Advertisment