set theMonth to do shell script " date -v2d -v1m -v99y +%B%n%b%n%m%n%-m"
-> "Enero
Jan
01
1"
set theDay to do shell script " date -v2d -v1m -v99y +%A%n%a%n%d%n%-d"
-> "Sábado
Sat
02
2"
set theYear to do shell script " date -v2d -v1m -v99y +%Y%n%y"
-> "1999
99"
-
La bandera -v ajusta el elemento de la fecha sin cambiar la fecha real.
-
-v2d es el segundo día
-
-v1m es el primer mes
-
-v99y es el año 1999
Los formateadores de fechas son:
-
%n nueva línea
-
%B nombre completo del mes
-
%b abbr nombre del mes
-
%m número de mes con cero a la izquierda
-
%-m número del mes sin el cero a la izquierda
Los demás formateadores siguen el mismo camino. Puedes encontrar más información sobre los formatos simplemente buscando en Google.
Si quieres hacerlo todo en applescript entonces te sugiero que leas MacScripter / Fechas y horas en AppleScripts
---------- actualización
Sí creo que es más eficiente hacerlo con el shell script. Pero si yo fuera a tratar de hacerlo en Applescript solo. Utilizaría manejadores para rellenar o acortar el artículo. Y el sólo pasar el mes, año y día a ellos para ordenar.
set {year:y, month:m, day:d} to current date
--set m to m + 1
set theYearLong to y as string
set theYearShort to shorten(y)
set theMonthNumberZero to pad((m as integer) as string)
set theMonthNumber to ((m as integer) as string)
set theMonthLong to m as string
set theMonthShort to shorten(m)
set theDayNumberZero to pad((d as integer) as string)
set theDayNumber to ((d as integer) as string)
on pad(thisNumber)
if length of thisNumber = 1 then
return "0" & thisNumber
else
return thisNumber
end if
end pad
on shorten(thisItem)
if class of thisItem is integer then
return characters 3 thru -1 of (thisItem as text) as string
else
return characters 1 thru 3 of (thisItem as text) as string
end if
end shorten
Probablemente haya una forma mejor de hacerlo pero este ejemplo puede darte una idea..