Re: Shell script date & time coercions...
Re: Shell script date & time coercions...
- Subject: Re: Shell script date & time coercions...
- From: John W Baxter <email@hidden>
- Date: Sat, 30 Mar 2002 19:26:44 -0800
At 2:08 +0100 3/31/2002, Mr Tea wrote:
>
This from Matthew Stuckwisch - dated 30/3/02 05.56 pm:
>
>
> set monthNum to do shell script "date +%m"
>
>
As others have already observed, 'Woo hoo!'
>
>
I had to try some other options. Aside from the obvious two...
>
>
"date +%d" -->"31"
>
"date +%y" -->"02"
>
>
...I also got these potentially useful results with a quick trawl through
>
the lower case alphabet...
man date
Just has a couple of examples, but refers (rather quietly) to man strftime
which has the list (which may do rather poorly passing through line wrap,
below).
Your j is the number of the day within the year (sometimes called the
Julian day, not to be confused with a Julian date or with NCR's old "M-day"
(the day of the year not counting days when manufacturing wasn't scheduled
to operate)).
Your s is the number of seconds since the start of Unix time (number of
seconds since 1969, which is easier than specifying the midnight which
opened January 1, 1970). There is ongoing disagreement over whether the
leap seconds which are added to (and sometimes subtracted from) UTC now and
then count or not.
w is the day of the week, starting with 0-->Sunday and ending with
6-->Saturday.
--John
Each conversion specification is replaced by the characters as follows
which are then copied into the buffer.
%A is replaced by the locale's full weekday name.
%a is replaced by the locale's abbreviated weekday name.
%B is replaced by the locale's full month name.
%b or %h
is replaced by the locale's abbreviated month name.
%C is replaced by the century (a year divided by 100 and truncated to
an integer) as a decimal number (00-99).
%c is replaced by the locale's appropriate date and time representa-
tion.
%D is replaced by the date in the format ``%m/%d/%y''.
%d is replaced by the day of the month as a decimal number (01-31).
%e is replaced by the day of month as a decimal number (1-31); single
digits are preceded by a blank.
%H is replaced by the hour (24-hour clock) as a decimal number
(00-23).
%I is replaced by the hour (12-hour clock) as a decimal number
(01-12).
%j is replaced by the day of the year as a decimal number (001-366).
%k is replaced by the hour (24-hour clock) as a decimal number (0-23);
single digits are preceded by a blank.
%l is replaced by the hour (12-hour clock) as a decimal number (1-12);
single digits are preceded by a blank.
%M is replaced by the minute as a decimal number (00-59).
%m is replaced by the month as a decimal number (01-12).
%n is replaced by a newline.
%p is replaced by the locale's equivalent of either ``AM'' or ``PM''.
%R is replaced by the time in the format ``%H:%M''.
%r is replaced by the locale's representation of 12-hour clock time
using AM/PM notation.
%T is replaced by the time in the format ``%H:%M:%S''.
%t is replaced by a tab.
%S is replaced by the second as a decimal number (00-60).
%s is replaced by the number of seconds since the Epoch, UCT (see
mktime(3)).
%U is replaced by the week number of the year (Sunday as the first day
of the week) as a decimal number (00-53).
%u is replaced by the weekday (Monday as the first day of the week) as
a decimal number (1-7).
%V is replaced by the week number of the year (Monday as the first day
of the week) as a decimal number (01-53). If the week containing
January 1 has four or more days in the new year, then it is week 1;
otherwise it is week 53 of the previous year, and the next week is
week 1.
%W is replaced by the week number of the year (Monday as the first day
of the week) as a decimal number (00-53).
%w is replaced by the weekday (Sunday as the first day of the week) as
a decimal number (0-6).
%X is replaced by the locale's appropriate time representation.
%x is replaced by the locale's appropriate date representation.
%Y is replaced by the year with century as a decimal number.
%y is replaced by the year without century as a decimal number
(00-99).
%Z is replaced by the time zone name.
%% is replaced by `%'.
--
John Baxter email@hidden Port Ludlow, WA, USA
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.