Terminal command to get user's time/date customisations

Discussion in 'Apple' started by Tim Streater, Apr 5, 2012.

  1. Tim Streater

    Tim Streater Guest

    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
    Tim Streater, Apr 5, 2012
    #1
    1. Advertising

  2. Tim Streater

    Guest

    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.
    , Apr 5, 2012
    #2
    1. Advertising

  3. In article <>,
    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,


    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/customize-os-x-with-this-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]
    Michael Vilain, Apr 6, 2012
    #3
  4. Tim Streater

    Wes Groleau Guest

    On 04-05-2012 20:19, Michael Vilain wrote:
    > 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,

    >
    > 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/customize-os-x-with-this-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
    Wes Groleau, Apr 6, 2012
    #4
  5. Tim Streater

    Tim Streater Guest

    In article
    <403539.94.1333666441771.JavaMail.geo-discussion-forums@ynbj3>,
    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
    Tim Streater, Apr 6, 2012
    #5
  6. Tim Streater

    Tim Streater Guest

    In article <jllhkj$aie$>,
    Wes Groleau <> wrote:

    > On 04-05-2012 20:19, Michael Vilain wrote:
    > > 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?


    > > 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/customize-os-x-with-this-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
    Tim Streater, Apr 6, 2012
    #6
  7. Tim Streater

    Paul Sture Guest

    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
    Paul Sture, Apr 6, 2012
    #7
  8. Tim Streater

    Tim Streater Guest

    In article <>, Paul Sture <>
    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
    Tim Streater, Apr 6, 2012
    #8
  9. In article <>,
    Tim Streater <> wrote:

    > In article <jllhkj$aie$>,
    > Wes Groleau <> wrote:
    >
    > > On 04-05-2012 20:19, Michael Vilain wrote:
    > > > 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?

    >
    > > > 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/customize-os-x-with-this-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]
    Michael Vilain, Apr 6, 2012
    #9
  10. In article <>,
    Tim Streater <> wrote:

    > In article <>, Paul Sture <>
    > 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]
    Michael Vilain, Apr 6, 2012
    #10
  11. Tim Streater

    Tim Streater Guest

    In article <>,
    Michael Vilain <> wrote:

    > In article <>,
    > Tim Streater <> wrote:
    >
    > > In article <jllhkj$aie$>,
    > > Wes Groleau <> wrote:
    > >
    > > > On 04-05-2012 20:19, Michael Vilain wrote:
    > > > > 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?

    > >
    > > > > 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/customize-os-x-with-this-giant-list-o
    > > > > f
    > > > > -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.


    I'm getting some info from:

    locale -ck LC_TIME

    and also by doing things like:

    defaults read com.apple.systempreferences AppleIntlCustomFormat
    defaults read "Apple Global Domain" AppleICUDateFormatStrings

    Whether or not I can put a script together to consistently extract the
    info I need, remains to be seen.

    --
    Tim

    "That excessive bail ought not to be required, nor excessive fines imposed,
    nor cruel and unusual punishments inflicted" -- Bill of Rights 1689
    Tim Streater, Apr 6, 2012
    #11
  12. Tim Streater

    Tim Streater Guest

    In article <>,
    Michael Vilain <> wrote:

    > In article <>,
    > Tim Streater <> wrote:
    >
    > > In article <>, Paul Sture <>
    > > 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.


    The contents of the .plist file does change, but I'm wondering whether
    that happens in real time or not, or perhaps its written out later.

    E.g. I can do:

    Mini% defaults read "Apple Global Domain" AppleICUDateFormatStrings
    {
    2 = "dd MMM y";
    3 = "dd MMMM y";
    }
    Mini% defaults read com.apple.systempreferences AppleICUDateFormatStrings
    2012-04-06 20:57:54.193 defaults[1162:707]
    The domain/default pair of
    (/Users/tim/Library/Preferences/com.apple.systempreferences.plist,
    AppleICUDateFormatStrings) does not exist

    > 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.


    I'd be a little surprised as there's nothing in principle to stop me
    building my own copy of PHP or installing someone else's .dmg. Might be
    embarrassing if that version then gave wrong results.

    > 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.


    I expect you're right but I'll keep looking for the moment. I've used
    xcode to make small changes to programs or create sqlite3 using the
    latest sqlite release but I haven't done a C app from scratch in xcode.
    It's 20 years since I wrote any sizeable amount of C and I was hoping
    never to have to do so again.

    --
    Tim

    "That excessive bail ought not to be required, nor excessive fines imposed,
    nor cruel and unusual punishments inflicted" -- Bill of Rights 1689
    Tim Streater, Apr 6, 2012
    #12
  13. In article <>,
    Tim Streater <> wrote:

    > In article <>,
    > Michael Vilain <> wrote:
    >
    > > In article <>,
    > > Tim Streater <> wrote:
    > >
    > > > In article <jllhkj$aie$>,
    > > > Wes Groleau <> wrote:
    > > >
    > > > > On 04-05-2012 20:19, Michael Vilain wrote:
    > > > > > 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?
    > > >
    > > > > > 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/customize-os-x-with-this-giant-list
    > > > > > -o
    > > > > > f
    > > > > > -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.

    >
    > I'm getting some info from:
    >
    > locale -ck LC_TIME
    >
    > and also by doing things like:
    >
    > defaults read com.apple.systempreferences AppleIntlCustomFormat
    > defaults read "Apple Global Domain" AppleICUDateFormatStrings
    >
    > Whether or not I can put a script together to consistently extract the
    > info I need, remains to be seen.


    Since this is a script (presumable with a preferences or config file),
    you could output using a standard US-centric date format and allow the
    user to change it to their liking. This way you have a starting point.
    It's your call on how much time you want to spend with this feature.
    Unless I had some code fragment around already that queried the MacOS
    System Format and Language, I'd just create the most logical default and
    let the user change it.

    A manager often told me when I'd get stuck in minutiae to spend a hour
    tops on something then make a design decision and move on. I've
    followed that advise on future projects. Often times I'd have to change
    my initial assumption, but if I'd designed it with sufficient
    flexibility that's not a problem. If a major design decision required a
    rewrite, well that's the breaks.

    --
    DeeDee, don't press that button! DeeDee! NO! Dee...
    [I filter all Goggle Groups posts, so any reply may be automatically ignored]
    Michael Vilain, Apr 7, 2012
    #13
  14. In article <>,
    Michael Vilain <> wrote:

    > In article <>,
    > Tim Streater <> wrote:
    >
    > > In article <>,
    > > Michael Vilain <> wrote:
    > >
    > > > In article <>,
    > > > Tim Streater <> wrote:
    > > >
    > > > > In article <jllhkj$aie$>,
    > > > > Wes Groleau <> wrote:
    > > > >
    > > > > > On 04-05-2012 20:19, Michael Vilain wrote:
    > > > > > > 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?
    > > > >
    > > > > > > 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/customize-os-x-with-this-giant-li
    > > > > > > st
    > > > > > > -o
    > > > > > > f
    > > > > > > -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.

    > >
    > > I'm getting some info from:
    > >
    > > locale -ck LC_TIME
    > >
    > > and also by doing things like:
    > >
    > > defaults read com.apple.systempreferences AppleIntlCustomFormat
    > > defaults read "Apple Global Domain" AppleICUDateFormatStrings
    > >
    > > Whether or not I can put a script together to consistently extract the
    > > info I need, remains to be seen.

    >
    > Since this is a script (presumable with a preferences or config file),
    > you could output using a standard US-centric date format and allow the
    > user to change it to their liking. This way you have a starting point.
    > It's your call on how much time you want to spend with this feature.
    > Unless I had some code fragment around already that queried the MacOS
    > System Format and Language, I'd just create the most logical default and
    > let the user change it.
    >
    > A manager often told me when I'd get stuck in minutiae to spend a hour
    > tops on something then make a design decision and move on. I've
    > followed that advise on future projects. Often times I'd have to change
    > my initial assumption, but if I'd designed it with sufficient
    > flexibility that's not a problem. If a major design decision required a
    > rewrite, well that's the breaks.


    I dug around the Apple Developer site looking at the system preferences
    API and various preferences frameworks. Then I just looked for "date
    format" and their's a whole class of stuff for getting the date in
    various formats.

    <https://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/
    DataFormatting/Articles/dfDateFormatting10_4.html#//apple_ref/doc/uid/TP4
    0002369>

    This is what you need to get at, somehow. It's part of the Foundation
    MacOS API. Somehow there has to be a way to write a simple gcc program
    that links to this library.

    Good luck.

    --
    DeeDee, don't press that button! DeeDee! NO! Dee...
    [I filter all Goggle Groups posts, so any reply may be automatically ignored]
    Michael Vilain, Apr 7, 2012
    #14
  15. Tim Streater

    Wes Groleau Guest

    On 04-06-2012 15:25, Michael Vilain wrote:
    > 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


    The format for the clock in the menu bar is in
    ~/Library/Preferences/com.apple.menuextra.clock.plist

    I found it rather odd that it that the pref. pane in Lion requires an
    admin password to change something that obviously should be a per-user
    preference.

    I find it even odder that something which requires admin password would
    be recorded in the user's preferences.


    ~/Library/Preferences/com.apple.HIToolbox.plist
    was modified at the exact time I changed the time formats for locale.

    Then I changed them back, and the file was modified again.
    BUT, the values in it did not change!

    The way I located it was to note that I changed the pref at close to
    23:26:00 and so:

    find ~ -mtime -1 -exec ls -l "{}" \; | egrep "23:35"

    listed about twenty files, most of which I judged to be irrelevant by
    their names. I used ~ because I expected it to be per-user. If it is
    system-wide, I would use /Library and /System/Library


    --
    Wes Groleau

    Pat's Polemics
    http://Ideas.Lang-Learn.us/barrett
    Wes Groleau, Apr 7, 2012
    #15
  16. In article <jlodet$qqu$>,
    Wes Groleau <> wrote:

    > I found it rather odd that it that the pref. pane in Lion requires an
    > admin password to change something that obviously should be a per-user
    > preference.


    Actually it doesn't. Even though the Date & Time preferences panel shows
    the lock in the bottom left corner, I was able to make changes to the clock
    pane without having to enter a password while the lock was in the locked
    position.

    --
    Tea Party Patriots is to Patriotism as
    People's Democratic Republic is to Democracy.
    Michelle Steiner, Apr 7, 2012
    #16
  17. Tim Streater

    Wes Groleau Guest

    On 04-05-2012 16:16, 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?


    iMac:~ wgroleau$ defaults read com.apple.systempreferences
    AppleIntlCustomFormat
    {
    AppleIntlCustomICUDictionary = {
    AppleICUDateFormatStrings = {
    1 = "MM-dd-yyyy";
    2 = " d MMM yyyy";
    3 = " d MMMM yyyy";
    4 = "EEEE, d MMMM yyyy";
    };
    AppleICUTimeFormatStrings = {
    1 = "HH:mm";
    2 = "HH:mm:ss";
    3 = "HH:mm:ss z";
    4 = "HH:mm:ss.SSS z";
    };
    };
    AppleIntlCustomLocale = "en_US";
    }
    iMac:~ wgroleau$ defaults read com.apple.systempreferences
    AppleIntlCustomFormat | grep M | grep 2
    2 = " d MMM yyyy";
    iMac:~ wgroleau$ defaults read com.apple.systempreferences
    AppleIntlCustomFormat | grep M | grep 2 | awk '{print $3}'
    "
    iMac:~ wgroleau$ defaults read com.apple.systempreferences
    AppleIntlCustomFormat | grep M | grep 2 | perl -p -e 's:.*"(.*)".*:\1:g;'
    d MMM yyyy
    iMac:~ wgroleau$ export FMT="$(!!)"
    export FMT="$(defaults read com.apple.systempreferences
    AppleIntlCustomFormat | grep M | grep 2 | perl -p -e 's:.*"(.*)".*:\1:g;')"
    iMac:~ wgroleau$ echo "+$FMT+"
    + d MMM yyyy+




    --
    Wes Groleau

    Pat's Polemics
    http://Ideas.Lang-Learn.us/barrett
    Wes Groleau, Apr 7, 2012
    #17
  18. Tim Streater

    Tim Streater Guest

    In article <>,
    Michael Vilain <> wrote:

    > In article <>,
    > Tim Streater <> wrote:


    > > I'm getting some info from:
    > >
    > > locale -ck LC_TIME
    > >
    > > and also by doing things like:
    > >
    > > defaults read com.apple.systempreferences AppleIntlCustomFormat
    > > defaults read "Apple Global Domain" AppleICUDateFormatStrings
    > >
    > > Whether or not I can put a script together to consistently extract the
    > > info I need, remains to be seen.

    >
    > Since this is a script (presumable with a preferences or config file),
    > you could output using a standard US-centric date format and allow the
    > user to change it to their liking. This way you have a starting point.
    > It's your call on how much time you want to spend with this feature.
    > Unless I had some code fragment around already that queried the MacOS
    > System Format and Language, I'd just create the most logical default and
    > let the user change it.
    >
    > A manager often told me when I'd get stuck in minutiae to spend a hour
    > tops on something then make a design decision and move on. I've
    > followed that advice on future projects. Often times I'd have to change
    > my initial assumption, but if I'd designed it with sufficient
    > flexibility that's not a problem. If a major design decision required a
    > rewrite, well that's the breaks.


    The app is already written and the users (well, that's just me at
    present :) have to make do with my UK date format. This is more about
    getting it to a state where I could make it available.

    You're right about the design/development process. I did just that when
    I couldn't find an easy way to interface to Apple's AddressBook [1]:
    wrote my own for the app.

    --
    Tim

    "That excessive bail ought not to be required, nor excessive fines imposed,
    nor cruel and unusual punishments inflicted" -- Bill of Rights 1689
    Tim Streater, Apr 7, 2012
    #18
  19. In article <>,
    Tim Streater <> wrote:

    > In article <>,
    > Michael Vilain <> wrote:
    >
    > > In article <>,
    > > Tim Streater <> wrote:

    >
    > > > I'm getting some info from:
    > > >
    > > > locale -ck LC_TIME
    > > >
    > > > and also by doing things like:
    > > >
    > > > defaults read com.apple.systempreferences AppleIntlCustomFormat
    > > > defaults read "Apple Global Domain" AppleICUDateFormatStrings
    > > >
    > > > Whether or not I can put a script together to consistently extract the
    > > > info I need, remains to be seen.

    > >
    > > Since this is a script (presumable with a preferences or config file),
    > > you could output using a standard US-centric date format and allow the
    > > user to change it to their liking. This way you have a starting point.
    > > It's your call on how much time you want to spend with this feature.
    > > Unless I had some code fragment around already that queried the MacOS
    > > System Format and Language, I'd just create the most logical default and
    > > let the user change it.
    > >
    > > A manager often told me when I'd get stuck in minutiae to spend a hour
    > > tops on something then make a design decision and move on. I've
    > > followed that advice on future projects. Often times I'd have to change
    > > my initial assumption, but if I'd designed it with sufficient
    > > flexibility that's not a problem. If a major design decision required a
    > > rewrite, well that's the breaks.

    >
    > The app is already written and the users (well, that's just me at
    > present :) have to make do with my UK date format. This is more about
    > getting it to a state where I could make it available.
    >
    > You're right about the design/development process. I did just that when
    > I couldn't find an easy way to interface to Apple's AddressBook [1]:
    > wrote my own for the app.


    Apparently, there's a Perl module that will interface to the Foundations
    classes so you can access NSDate and NSDateFormat from perl. That would
    be ideal from the command line.

    <http://drdobbs.com/web-development/184415982>

    <https://developer.apple.com/library/mac/#documentation/Darwin/Reference/
    Manpages/man3/PerlObjCBridge.3pm.html>

    <http://cocoadevcentral.com/articles/000076.php>

    --
    DeeDee, don't press that button! DeeDee! NO! Dee...
    [I filter all Goggle Groups posts, so any reply may be automatically ignored]
    Michael Vilain, Apr 7, 2012
    #19
  20. Tim Streater

    Paul Sture Guest

    On Sat, 07 Apr 2012 11:37:43 -0700, Michael Vilain wrote:

    > Apparently, there's a Perl module that will interface to the Foundations
    > classes so you can access NSDate and NSDateFormat from perl. That would
    > be ideal from the command line.


    But unless that module comes with the version of Perl distributed by
    Apple, Tim is potentially going to need to incorporate it somehow in his
    app.

    > <http://drdobbs.com/web-development/184415982>
    >
    > <https://developer.apple.com/library/mac/#documentation/Darwin/

    Reference/>
    > Manpages/man3/PerlObjCBridge.3pm.html>
    >
    > <http://cocoadevcentral.com/articles/000076.php>






    --
    Paul Sture
    Paul Sture, Apr 8, 2012
    #20
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Minardi
    Replies:
    3
    Views:
    453
    Minardi
    Jan 16, 2006
  2. Minardi
    Replies:
    3
    Views:
    368
    Minardi
    Jan 16, 2006
  3. =?iso-8859-2?Q?Artur_D=EAbski?=

    [Ultra 10] How to change monochrome terminal to color terminal?

    =?iso-8859-2?Q?Artur_D=EAbski?=, Jan 16, 2006, in forum: Sun Hardware
    Replies:
    0
    Views:
    315
    =?iso-8859-2?Q?Artur_D=EAbski?=
    Jan 16, 2006
  4. Klimt
    Replies:
    1
    Views:
    257
    Klimt
    Jun 25, 2004
  5. Oliver  Marshall

    Terminal command to close terminal

    Oliver Marshall, Feb 26, 2007, in forum: Apple
    Replies:
    4
    Views:
    279
    Heath Raftery
    Feb 27, 2007
Loading...

Share This Page