The macosxhints Forums

The macosxhints Forums (http://hintsforums.macworld.com/index.php)
-   System (http://hintsforums.macworld.com/forumdisplay.php?f=4)
-   -   Adding Date to Menubar's Time in Jaguar (http://hintsforums.macworld.com/showthread.php?t=5029)

davey 08-28-2002 02:01 AM

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 08-29-2002 10:10 AM

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?

dsk 08-29-2002 12:33 PM

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 08-29-2002 12:56 PM

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

nkuvu 08-29-2002 01:20 PM

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

SpongeBob 08-29-2002 02:23 PM

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/

dsk 08-29-2002 02:29 PM

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 08-29-2002 02:34 PM

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

SpongeBob 08-29-2002 03:34 PM

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.

dsk 08-29-2002 03:51 PM

Super! You're the man! Thanks a lot.

David

davey 08-29-2002 08:37 PM

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

dsk 08-29-2002 08:46 PM

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

davey 08-29-2002 09:03 PM

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

dsk 08-29-2002 09:15 PM

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 08-29-2002 09:19 PM

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

davey 08-29-2002 09:37 PM

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

dsk 08-29-2002 09:40 PM

Please post the string you used.

David

dsk 08-29-2002 09:43 PM

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

davey 08-29-2002 09:43 PM

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

dsk 08-29-2002 09:54 PM

See my last post. Does that help?

David

davey 08-29-2002 10:08 PM

Hey, it appears to be working well on the menu bar. I did update the string slightly to remove one of the two spaces between am/pm and seconds:

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

I did notice that this code change as affected other programs in funky ways. I use a program called Weather Pop. It has an icon in the menu bar which shows the temperature and other weather-related information. It just informed me that a temperature update was performed on:

Thu, Aug 29, 2002 Aug 29 2002 Thu 10:01 pm pm

Oh man! Apple could have made this simpler by just sticking the full date in the DATE and Time control panel as an option.

David and Bob - thank you so much for helping me out. Unless you know of any other options, I am going to stick with this for a while.

-David

dsk 08-29-2002 10:15 PM

Quote:

It just informed me that a temperature update was performed on:

Thu, Aug 29, 2002 Aug 29 2002 Thu 10:01 pm pm
Interesting. I did fear that there may be certain issues like this. Although, WeatherPop should be programmed to have an independent date formatting system. I suppose that it is currently set to simply take the current time format (i.e. the one we messed with) and slap the date on at the beginning and the AM/PM on at the end. Hopefully not many other developers use this method. You could write an e-mail to the WeatherPop people (http://www.glu.com I believe).

Does anyone know if there will be harmful effects associated with this method?

David

SpongeBob 08-30-2002 12:29 PM

I can't say for sure, but I wouldn't think so. I wouldn't however be surprised if there were other programs like WeatherPop that displayed the date in the new format. The string that was modified is a system wide parameter, so if you dink with the format you change it for everything. Other than that, I can really see no repercussions. I also use Weatherpop, but just noticed after reading the thread that it was using the new date format I installed yesterday. Frankly, Apple could fix this simply and easily by having the clock use its' own date string which apparently it did in earlier releases rather than reference the system wide setting.

nkuvu 08-30-2002 01:52 PM

Take a look at file modification dates in the Finder after updating the string.

I have no idea if those might be affected, but it wouldn't hurt to look.

dsk 08-30-2002 01:55 PM

They look fine, nkuvu:

Fri, May 24, 2002, 3:24 PM

David

davey 08-30-2002 03:07 PM

Hey David,

How would I get the time string to look like what you just posted?

Fri, May 24, 2002, 3:24 PM

%a, %b %d %Y, %1I:%M:%S %p

-David

dsk 08-30-2002 03:34 PM

Quote:

Originally posted by davey
Hey David,

How would I get the time string to look like what you just posted?

Fri, May 24, 2002, 3:24 PM

%a, %b %d %Y, %1I:%M:%S %p

-David
I think that should do it. One small detail you missed was the comma after %d.

David

tizzleBizzle 09-07-2002 12:40 AM

check it.
 
http://developer.apple.com/techpubs/...ToStrings.html

Tiburon 10-22-2003 03:59 PM

Quote:

Originally posted by SpongeBob
Wahoo, found it.

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

I don't find this file in my library. How comes? (OSX.2.6)

dsk 10-22-2003 04:01 PM

the period in front of the file name indicates that it's invisible in the finder. use the terminal if you want to manipulate the file.

Tiburon 10-23-2003 05:06 AM

Thanks for reply. Even its an old thread its quite interesting

However: I dont find the <key>NSTime... entry in my .GlobalPreferences.plist File

How comes? Did Apple move this menubar clock entry?

geokker 09-28-2006 01:45 AM

I changed the menu bar time to date & time with the system preference panel on Tiger.

Irene 09-28-2006 12:14 PM

Quote:

Originally Posted by geokker (Post 324446)
I changed the menu bar time to date & time with the system preference panel on Tiger.

Yes, that's shows date and time but not day of week which I also like to have displayed. The application wClock will display all three in the Menu Bar, and in any color you choose, rather than only in black.

yellow 09-28-2006 12:44 PM

Quote:

Originally Posted by geokker (Post 324446)
I changed the menu bar time to date & time with the system preference panel on Tiger.

Your reply is nearly 3 years late. ;)

geokker 09-28-2006 01:54 PM

it was a weird struggle however. I felt somehow 'dirty' doing it.


All times are GMT -5. The time now is 05:00 PM.

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.