Pages 3 Tip: Custom formats for automatic date
Posted by Pierre Igot in: PagesApril 25th, 2008 • 2:03 pm
Apple’s word processor Pages comes with some basic functionality for inserting an automatic date in a document. When you are composing a document, just go to the “
” menu and choose the “ ” command.This will insert the current date in a default (long date) format:
It looks like regular text, but it actually cannot be edited. If you click anywhere on it, Pages selects the entire thing, and if you double-click on it, you get access to a small floating thing that provides further options:
In this little floating thing, you can use the “Choose Date Format” menu to select other date formats:
The list of available date format options, however, is still limited. What if, for example, you’d like an automatic date in the universal “yyyy-mm-dd” format (as in “2008-04-25”)?
As you can see from the picture above, this particular date format is not part of the list of options. But this is where tight integration with Mac OS X’s underlying standards becomes important. See, the date format options provided in the floating thing above are actually based on the date format options defined in the “International” preference pane in System Preferences:
And the good news is that these date format options can be customized there. The “Customize…” button gives you access to a dialog sheet where you customize four different default values for the date format: “Short,” “Medium,” “Long,” and “Full”:
In the example below, I have customized the “Short” value and replaced it with the universal “yyyy-mm-dd” format:
(As this particular screen shot indicates, in order to get the number of the day with two digits, I just inserted the “Day of Month” control and then used the contextual menu to change from the default single-digit value to the two-digit value. You can do the same for the “Month” control in order to get the number of the month with two digits instead of the name of the month.)
Once this customization is done, I can return to Pages and double-click again on my automatic date, and now the options in the “Choose Date Format” menu have changed:
Et voilà! I can now insert an automatic date with the universal “yyyy-mm-dd” format in my Pages documents.
Sadly, Pages’s automatic date feature suffers from some frustrating limitations nonetheless. The major one for me is the fact that it is a unilingual feature, even though Pages itself is multilingual and lets you compose documents in a variety of languages.
This means that, regardless of which language your Pages document is in, the date inserted by Pages’s “International” preference pane.
” command will be in the language-specific format selected in the “Since the majority of my documents are in Canadian French, I use the “French (Canada)” region in the “International” preference pane. Here are the four default values for the “Full,” “Long,”, “Medium,” and “Short” format options for the “French (Canada)” region:
As you can see, the “Medium” and “Short” values are exactly the same, which is pretty useless. This means that I can customize the “Medium” one to use the universal “yyyy-mm-dd” format mentioned above:
And I very much need this, because when I compose documents in Pages in English, the “yyyy-mm-dd” date format is pretty much the only acceptable one in English. Otherwise, I have no choice but to enter my dates manually in English, which means that there is no automatic updating—a particularly frustrating limitation when using dates in document templates.
Of course, in order to circumvent this limitation, Pages would have to break free of its total dependence on the “International” preference pane settings. It would have to provide its own preference settings for language-specific date formats, and that would undoubtedly add to the complexity of the feature. But I am afraid that, in a multilingual world, there is no other solution, and if Pages claims to be a multilingual word processor, then it needs to go all the way and provide multilingual options for dates as well.
The current situation might be acceptable to the majority of users who only ever use a single set of date, time and number formats—the one for their mother tongue. But it penalizes users who regularly switch from one language to another and, while these users might not be the majority, there are still quite a few of them, and not just in Canada.
(The same restrictions, of course, apply to automatic number formats in tables in Pages, Numbers and Keynote. Here again, it is impossible to use the applications’ automatic number formatting features in any language other than the one selected in the “International” preference pane.)
In conclusion and as a comparison, I was going to mention Microsoft Word’s own multilingual features. It used to be that Word was smart enough to change the date format used depending on the language setting for the underlying text. And indeed if I open old templates that I had defined in previous versions of Word, I can still find automatic dates in an English format in those templates that are in English. But when I try to insert a new automatic date in Word 2008, I now get the same limitations as in Pages, i.e. only it inserts the automatic date with the format options defined in the “International” preference pane, regardless of what the current language setting for the text is in the Word document.
So it looks like Word 2008 has been crippled in that respect compared to previous versions. Since I profoundly loathe Microsoft Word and use it as little as possible, I am not going to bother to try experiment to see if I can reproduce the language-specific date formats that I used to be able to achieve in previous versions. But if Word 2008 is indeed crippled, it is yet another reason to give up on Microsoft and switch to Pages. Word 2008 still has more flexibility than Pages (for example, it has separate field codes for print dates, which are dates that are only updated when the document is printed), but for all we know Microsoft’s MacBU is just as likely to further cripple the next version of Word and remove that functionality as well.
The real conclusion here is that Pages, while it is still somewhat limited in what it can do in terms of automatic dates, does provide a number of options, with further customization possible through the “International” preference pane in System Preferences.
June 20th, 2008 at Jun 20, 08 | 6:04 pm
The problem I have with Pages is that I can’t get both the date and the time inserted in the combination of formats that I want. I found this page while I was looking for the solution, so now that I’ve discovered one, I figure I’ll post it here since I don’t see it documented elsewhere. One has to be comfortable editing a plist file. I’m working with Pages 3.0.2 in Max 10.5.3 on an iMac G5.
(I am not aware if it would be possible to use date or time formats other than those defined in the System Preferences, but perhaps hunting among the plist files will help. A possibly relevant one is mentioned in the comments of a macosxhints tip about modifying Numbers, but I can’t figure out how to make it work with the below.)
Quit Pages. Select Pages in the Finder, control-click on it, and “Show Package Contents”. Then, after backing it up somewhere just in case, open the following file:
/Contents/Frameworks/SFWordProcessing.framework/Versions/A/Resources/English.lproj/Defaults.plist
You can do this using TextEdit or the Property List Editor (if you have that installed). In TextEdit, look for the following lines:
<string>Custom</string>
<integer>0</integer>
<integer>0</integer>
<integer></integer>
This is a “custom” date and time format, and once you set it to your liking, it will appear in your list of Date Format options. The two integers represent the date and time, respectively.
First, note that you only have certain formats you can work with. These are defined in the Formats tab of the International preference pane in your System Preferences, and you can alter them there. As you will see, there are options for Full, Long, Medium, and Short Date formats, and for Medium and Short Time formats. Take note of what they are.
Now, back to the plist file. The first integer represents the date format, thusly:
0: null – that is, nothing appears for the date
1: Short Date
2: Medium Date
3: Long Date
4: Full Date
Now change the second integer to represent your desired time format:
0: null – that is, nothing appears for the time
1: Short Time
2: Medium Time
So, for “Monday, June 16, 2008 11:23 AM”, the text should look like this:
<string>Custom</string>
<integer>4</integer>
<integer>1</integer>
<integer></integer>
Now save the file and reopen Pages. When you double-click on a date, you should see your desired format as the final option in the list. That’s that.
If doing this in the Property List Editor, drill down as follows: “Root > SFWPDateTimeFormats > 7”. The first “Number” represents the date, and the second represents the time.
I expect that one could add a further Custom format by creating an 8th sibling, but I haven’t tried that.