【AppleScript】日付の操作

日付の操作してみる。

set target_date to (current date) - 7 * days --7日前までの訪問者
set dt_year to year of target_date
set dt_month to month of target_date as number
set dt_month to my packZero({val_:dt_month as text, len_:2})
set dt_date to day of target_date
set dt_date to my packZero({val_:dt_date as text, len_:2})

set dt_ymd to (dt_year & "/" & dt_month & "/" & dt_date) as text -- "(...)) as text" が ないと配列扱いになるので注意!

ゼロ詰めの関数はこちら。

参考サイト