beautypg.com

Working with dates and times, The calendar format, Date conversion specifiers – Apple WebObjects 3.5 User Manual

Page 206

background image

Chapter 11

WebScript Programmer’s Quick Reference to Foundation Classes

206

Working With Dates and Times

NSCalendarDate objects represent dates and times. These objects are
especially suited for representing and manipulating dates according to Western
calendrical systems. NSCalendarDate performs date computations based on
Western calendrical systems, primarily the Gregorian.

The methods provided by NSCalendarDate are described in more detail in
“Commonly Used Date Methods” (page 207).

The Calendar Format

Each NSCalendarDate object has a calendar format associated with it. This
format is a string that contains date-conversion specifiers very similar to those
used in the standard C library function

strftime()

. NSCalendarDate interprets

dates that are represented as strings conforming to this format. You can set the
default format for an NSCalendarDate object either at initialization time or by
using the

setCalendarFormat:

method. Several methods allow you to specify formats

other than the one bound to the object.

Date Conversion Specifiers

The date conversion specifiers cover a range of date conventions:

Conversion Specifier

Argument Type

%%

a '%' character

%A, %a

full and abbreviated weekday name, respectively

%B, %b

full and abbreviated month name, respectively

%c

date and time designation for the locale

%d

day of the month as a decimal number (01–31)

%F

milliseconds as a decimal number (000-999)

%H, %I

hour based on a 24-hour or 12-hour clock as a decimal number,
respectively. (00–23 or 01–12)

%j

day of the year as a decimal number (001–366)

%M

minute as a decimal number (00–59)

%m

month as a decimal number (01–12)

%p

AM/PM designation for the locale

%S

second as a decimal number (00–59)

%w

weekday as a decimal number (0–6), where Sunday is 0