Go Back   The macosxhints Forums > OS X Help Requests > System



Reply
 
Thread Tools Rate Thread Display Modes
Old 08-28-2002, 01:01 AM   #1
davey
Prospect
 
Join Date: Aug 2002
Location: Boston, MA
Posts: 14
Adding Date to Menubar's Time in Jaguar

Hi All,

Some months ago, someone posted the code needed to change the way the date and time show up in the menu bar. Instead of just showing the week day and time, with seconds flashing, it became possible to display the day/month/year as well.

Sadly, this code does not work for Jaguar because the file is not exactly the same as before.

Can you anyone review the code and post an update?

http://www.macosxhints.com/article.p...11126090439402

Please advise. Thanks.

-David
davey is offline   Reply With Quote
Old 08-29-2002, 09:10 AM   #2
davey
Prospect
 
Join Date: Aug 2002
Location: Boston, MA
Posts: 14
Here is more information about this problem...

Before Jaguar, if we typed the following code in Terminal:

cd /System/Library/CoreServices/Menu\ Extras/Clock.menu/Contents/MacOS/
sudo perl -p -i -e "s/%a /%x /" Clock

The clock would change from: Thu 10:04:30 AM

to: Aug 29 2002 Thu 10:04:30 AM

This code doesn't work anymore though because at the end of the unix command is "MacOS/." This subdirectory no longer exists in this location. What I see inside the package is the following:

Info.plist
Resources (folder)
version.plist

Does anyone know how to adjust the unix command to take into account the new editable resources?
davey is offline   Reply With Quote
Old 08-29-2002, 11:33 AM   #3
dsk
Triple-A Player
 
Join Date: Jan 2002
Location: Philadelphia, PA
Posts: 223
I'd love to see this happen as well. The only file of interest I was able to find was /System/Library/CoreServices/Menu\ Extras/Clock.menu/Contents/Resources/English.lproj/Localizable.strings

which seems to dictate the format of the clock.

The default MBC_CLOCK_FORMAT_STRING setting is "%a %time%p" which I believe means "day of week" then, of course, "time" then "am or pm." We need someone who can figure out a.) if the OS has strings built in for month, date, etc. and b.) what they are (i.e. %x, %y, whatever).

1000 points to whoever gets it first.

David
dsk is offline   Reply With Quote
Old 08-29-2002, 11:56 AM   #4
dsk
Triple-A Player
 
Join Date: Jan 2002
Location: Philadelphia, PA
Posts: 223
Well I experimented with that file I found, "Localizable.strings," and changing it seems to have no effect on the clock display. Anyone else have any ideas?

David

Last edited by dsk; 08-29-2002 at 12:22 PM.
dsk is offline   Reply With Quote
Old 08-29-2002, 12:20 PM   #5
nkuvu
MVP
 
Join Date: Jun 2002
Location: Tucson, Arizona
Posts: 1,236
As far as the replacements go, you can look at man 3 strftime

From what I can tell, the Perl command replaces the first occurrence of %a in the file Clock with %x. So you just need to find the Clock file. Which means that the cd command changes, but the Perl command stays the same.

Of course, I don't have Jaguar to test this theory out. But, uh, if anyone wants to send me a (legal!) copy, I'll look into it.
nkuvu is offline   Reply With Quote
Old 08-29-2002, 01:23 PM   #6
SpongeBob
Prospect
 
Join Date: May 2002
Posts: 22
Thumbs up

I just use PTHClock. It's completely customizable regarding the date and time format. As noted, just refer to the strftime page to get the appropriate strings to fill in. I really like PTHClock b/c I can click on it and pull down a full mini calendar. It's free and I've had no problems running it on either 10.1.5 or 10.2. It also has configurable chimes and it can talk using the built-in speech stuff. Here's the link:

http://www.pth.com/PTHClock/
SpongeBob is offline   Reply With Quote
Old 08-29-2002, 01:29 PM   #7
dsk
Triple-A Player
 
Join Date: Jan 2002
Location: Philadelphia, PA
Posts: 223
SpongeBob--
I agree that PTHClock is a great app and probably the easiest solution, but there are a couple reasons why I'd rather solve the problem with Clock.menu. First, PTHClock is not a menu extra. It's another process I would have to place in my already crowded Login Items, and I cannot Command-drag it, which I like to be able to do with things in the menubar. Second, there simply SHOULD be a way to view the date in the menubar without resorting to third party apps.

David
dsk is offline   Reply With Quote
Old 08-29-2002, 01:34 PM   #8
dsk
Triple-A Player
 
Join Date: Jan 2002
Location: Philadelphia, PA
Posts: 223
Quote:
As noted, just refer to the strftime page to get the appropriate strings to fill in.

Okay, now we just need to figure out WHERE to fill them in.

David
dsk is offline   Reply With Quote
Old 08-29-2002, 02:34 PM   #9
SpongeBob
Prospect
 
Join Date: May 2002
Posts: 22
Thumbs up

Wahoo, found it.

Look in the file

/Users/<name>/Library/Preferences/.GlobalPreferences.plist

It's the key NSTimeFormatString

Just use the strings from strftime to format it the way you want. Don't forget that Apple uses the System Preferences config to add to that string. So, you might want to uncheck the AM/PM box, the Show Day of week box or whatever depending on the strings used.
SpongeBob is offline   Reply With Quote
Old 08-29-2002, 02:51 PM   #10
dsk
Triple-A Player
 
Join Date: Jan 2002
Location: Philadelphia, PA
Posts: 223
Super! You're the man! Thanks a lot.

David
dsk is offline   Reply With Quote
Old 08-29-2002, 07:37 PM   #11
davey
Prospect
 
Join Date: Aug 2002
Location: Boston, MA
Posts: 14
Thank you, Bob! I agree - you da man. : )

Now, for a non-unix guru, how should the code look to get the menu bar to look like this:

Aug 29 2002 Thu 10:04:30 AM

Thanks!

-David
davey is offline   Reply With Quote
Old 08-29-2002, 07:46 PM   #12
dsk
Triple-A Player
 
Join Date: Jan 2002
Location: Philadelphia, PA
Posts: 223
Aug 29 2002 Thu 10 04 30 AM
%b %d %G %a %I %M %S %p

Case sensitive. Space it out/punctuate it as you wish. %e is like %d, but will not show a zero before single digit dates.

use "man 3 strftime" as nkuvu said at the terminal to see all the options (and to make sure I'm correct about the above). And as SpongeBob said, it might be a good idea to uncheck all the sub-options for the Menu Bar Clock in System Prefs.

David

Last edited by dsk; 08-29-2002 at 07:48 PM.
dsk is offline   Reply With Quote
Old 08-29-2002, 08:03 PM   #13
davey
Prospect
 
Join Date: Aug 2002
Location: Boston, MA
Posts: 14
I take it you guys know a lot more unix commands than I do, because I am still a bit lost on how to add the date to my menu bar.

Assuming I want the date to show as Aug 29 2002 Thu 9:00:34 pm, what is the command supposed to look like?

Something like:

cd /Users/david/Library/Preferences/.GlobalPreferences.plist
sudo perl %b %d %G %a %I %M %S %p

I think a file name is supposed to show up in there, but I don't know where.

Thanks in advance, guys!

-David
davey is offline   Reply With Quote
Old 08-29-2002, 08:15 PM   #14
dsk
Triple-A Player
 
Join Date: Jan 2002
Location: Philadelphia, PA
Posts: 223
Ah, sorry. Misunderstood the question. You have to edit the .GlobalPreferences.plist file itself. I personally don't know how to boil it down to one command (someone else might) but here's what I did:

cp ~/Library/Preferences/.GlobalPreferences.plist ~/Desktop/GlobalPreferences.plist.bak

[backs up the file to the desktop. Notice the space in between "~/Library/Preferences/.GlobalPreferences.plist" and "~/Desktop/GlobalPreferences.plist.bak". Also notice the period preceeding "GlobalPreferences.plist " and the lack thereof in "GlobalPreferences.plist.bak" -- a period before the file name makes it invisible. Verify that the file is on the desktop before proceeding to make sure you're safe and sound.]

pico ~/Library/Preferences/.GlobalPreferences.plist

[opens the file in a command line text editor, pico]

At this point, you have to locate the string for time format that SpongeBob found. Scroll down (by pressing the down arrow) to:

<key>NSTimeFormatString</key>
<string>%1I:%M:%S</string>

then edit the "%1I:%M:%S" part using the codes I directed you to in my last post on this thread. When you're done, hit Control-O, then Enter to save. Quit and reopen the Menu Bar clock (or I guess just logging out and back in should work too). Changes should take effect.

On a side note, does anyone know why there is a "1" before "I" in the default string, "%1I:%M:%S"? It's really buggin' me.

Let us know how it goes, davey.

David
dsk is offline   Reply With Quote
Old 08-29-2002, 08:19 PM   #15
dsk
Triple-A Player
 
Join Date: Jan 2002
Location: Philadelphia, PA
Posts: 223
Quote:
On a side note, does anyone know why there is a "1" before "I" in the default string, "%1I:%M:%S"? It's really buggin' me.

In response to my own question, it turns out the "1" makes it so that a single digit hour will not have a "0" before it. Found this out by deleting the "1". Go figure.

David
dsk is offline   Reply With Quote
Old 08-29-2002, 08:37 PM   #16
davey
Prospect
 
Join Date: Aug 2002
Location: Boston, MA
Posts: 14
Ok, well it did not exactly work, but I'm a whole lot closer now than before.

When I followed the instructions before, I ended up with a time/date lines that looks like this:

Aug 29 ? Thu 9:33:15 pm pm

When I went to the Date and Time Pref Panel, I unchecked am/pm and then the date totally reverted back to the original display: Thu 9:33:15 pm.

I tried this a second time, unchecking "Show AM/PM" and "Show the Day of Week" and this time the result looks like this:

Aug 29 ? Thu 9:34:59

This time there is no am/pm at all, and the year stays a question mark.

I went back to date/time pref panel and rechecked the am/pm and day of week, and now the menu bar looks like this:

Thu Aug 29 ? Thu 9:35:55 pm

I hope this helps in figuring this out. I am going to try to fix my clock now.

-David
davey is offline   Reply With Quote
Old 08-29-2002, 08:40 PM   #17
dsk
Triple-A Player
 
Join Date: Jan 2002
Location: Philadelphia, PA
Posts: 223
Please post the string you used.

David
dsk is offline   Reply With Quote
Old 08-29-2002, 08:43 PM   #18
dsk
Triple-A Player
 
Join Date: Jan 2002
Location: Philadelphia, PA
Posts: 223
Okay, I think I see the problem. Forget %G for year, use %Y. That should fix the question mark, I hope. Also, do uncheck those options in the system prefs. It will be redundant otherwise.

David
dsk is offline   Reply With Quote
Old 08-29-2002, 08:43 PM   #19
davey
Prospect
 
Join Date: Aug 2002
Location: Boston, MA
Posts: 14
Sure -- first I backed up the file, then I used the pico command, then I went to the string to edit and typed:

%b %d %G %a %1I:%M:%S %p

Command O, exit, log out and back in.

-David
davey is offline   Reply With Quote
Old 08-29-2002, 08:54 PM   #20
dsk
Triple-A Player
 
Join Date: Jan 2002
Location: Philadelphia, PA
Posts: 223
See my last post. Does that help?

David
dsk is offline   Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

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

Forum Jump



All times are GMT -5. The time now is 08:59 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.
Site design © IDG Consumer & SMB; individuals retain copyright of their postings
but consent to the possible use of their material in other areas of IDG Consumer & SMB.