AppleScript名:ローカライズドな期間表記 |
— Created 2016-01-14 by Takaaki Naganoya — 2016 Piyomaru Software use AppleScript version "2.4" use scripting additions use framework "Foundation" –Date Interval set engNSDateIntervalFormatter to current application’s NSDateIntervalFormatter’s alloc()’s init() engNSDateIntervalFormatter’s setLocale:(current application’s NSLocale’s localeWithLocaleIdentifier:"en-US") engNSDateIntervalFormatter’s setDateStyle:(current application’s NSDateIntervalFormatterLongStyle) engNSDateIntervalFormatter’s setDateTemplate:(current application’s NSDateFormatter’s alloc()’s init()’s setDateFormat:"yyyy-MM-dd HH:mm") engNSDateIntervalFormatter’s setTimeStyle:(current application’s NSDateIntervalFormatterNoStyle) engNSDateIntervalFormatter’s setTimeZone:(current application’s NSTimeZone’s timeZoneWithAbbreviation:"JST") engNSDateIntervalFormatter’s setCalendar:(current application’s NSCalendar’s currentCalendar()) set startDate to current application’s NSDate’s |date|() set endDate to current application’s NSDate’s dateWithTimeInterval:86400 sinceDate:startDate set outEString to (engNSDateIntervalFormatter’s stringFromDate:startDate toDate:endDate) as string –> "1/14/16 – 1/15/16"–ShortStyle –> "Jan 14 – 15, 2016"–Medium Style –> "January 14 – 15, 2016"–Long Style –> "Thursday, January 14 – Friday, January 15, 2016"–Full Style set jpnNSDateIntervalFormatter to current application’s NSDateIntervalFormatter’s alloc()’s init() jpnNSDateIntervalFormatter’s setLocale:(current application’s NSLocale’s localeWithLocaleIdentifier:"ja") jpnNSDateIntervalFormatter’s setDateStyle:(current application’s NSDateIntervalFormatterFullStyle) jpnNSDateIntervalFormatter’s setDateTemplate:(current application’s NSDateFormatter’s alloc()’s init()’s setDateFormat:"yyyy-MM-dd HH:mm") jpnNSDateIntervalFormatter’s setTimeStyle:(current application’s NSDateIntervalFormatterNoStyle) jpnNSDateIntervalFormatter’s setTimeZone:(current application’s NSTimeZone’s timeZoneWithAbbreviation:"JST") jpnNSDateIntervalFormatter’s setCalendar:(current application’s NSCalendar’s currentCalendar()) set startDate to current application’s NSDate’s |date|() set endDate to current application’s NSDate’s dateWithTimeInterval:86400 sinceDate:startDate set outJString to (jpnNSDateIntervalFormatter’s stringFromDate:startDate toDate:endDate) as string –> "2016/01/14~2016/01/15"–ShortStyle –> "2016/01/14~2016/01/15"–Medium Style –> "2016/01/14~2016/01/15"–Long Style –> "2016/01/14(木曜日)~2016/01/15(金曜日)"–Full Style |
More from my site
(Visited 20 times, 1 visits today)