AppleScript名:現時点における年齢を計算する |
— Created 2015-09-10 by Takaaki Naganoya — 2015 Piyomaru Software use AppleScript version "2.4" use scripting additions use framework "Foundation" –http://stackoverflow.com/questions/4463893/ –how-to-calculate-the-age-based-on-nsdate set aBirthday to "2009-04-24 12:00:00" –誕生日 set aFormatter to current application’s NSDateFormatter’s alloc()’s init() aFormatter’s setDateFormat:"yyyy-MM-dd HH:mm:ss" aFormatter’s setTimeZone:(current application’s NSTimeZone’s timeZoneForSecondsFromGMT:0) set aBirthdayDate to aFormatter’s dateFromString:aBirthday set currentDate to current application’s NSDate’s |date|() set ageComponents to current application’s NSCalendar’s currentCalendar()’s components:(current application’s NSCalendarUnitYear) fromDate:aBirthdayDate toDate:currentDate options:0 set myAge to ageComponents’s |year|() –> 8 |
More from my site
(Visited 45 times, 1 visits today)