Re: numeric date
Re: numeric date
- Subject: Re: numeric date
- From: email@hidden
- Date: Sun, 20 Jul 2003 16:15:15 +0200
Well, well... Thanks Tony: I hadn't realized the date command had this option.
Actually, even 'man date' doesn't list all of those, and I'd be very interested to know where you got that documentation.
And the trick with cal is amazing: I realize that shell commands always return strings and that you can do whatever you want with them.
Very nice solution, indeed. Thanks a lot.
Jym Feat
>
> "I need to convert the month from the current date to a 2-digit number. My purpose is to make a folder name, like 2003.07.19"
>
do shell script "date +%Y.%m.%d"
>
-->"2003.07.19"
>
%% a '%' character
>
%a abbreviated weekday name
>
%A full weekday name
>
%b abbreviated month name
>
%B full month name
>
%c a system date representation
>
%d day of the month as a decimal number (01-31)
>
%e same as %d but does not print the leading 0 for days 1 through 9
>
%H hour based on a 24-hour clock as a decimal number (00-23)
>
%I hour based on a 12-hour clock as a decimal number (01-12)
>
%j day of the year as a decimal number (001-366)
>
%m month as a decimal number (01-12)
>
%M minute as a decimal number (00-59)
>
%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
>
%x date using the date representation for the locale
>
%X time using the time representation for the locale
>
%y year without century (00-99)
>
%Y year with century (such as 1990)
>
%Z time zone name (such as Pacific Daylight Time)
>
%z time zone offset in hours and minutes from GMT (HHMM)
>
The unix cal command can also come in handy for certain 'date' scripting tasks:
>
set monthCount to word -1 of (do shell script "cal")
>
-->"31"
>
set febCount to word -1 of (do shell script "cal 2 2003") as number
>
-->28
>
--If your looping thru every day of the month (to build urls for an example):
>
set dayList to words 10 thru -1 of (do shell script "cal")
>
-->{"1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30"}
_______________________________________________
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.