AppleScript名:RFC822エンコーダー v0 |
— Created 2016-02-07 by Takaaki Naganoya — 2016 Piyomaru Software use AppleScript version "2.5" use scripting additions use framework "Foundation" set aStr to "2016-02-06 11:00:00" set rfc822str to retRFC822StrFromDateStr(aStr) of me –> "Sat, 06 Feb 2016 11:00:00GMT" on retRFC822StrFromDateObj(aObj) set aFormat to "yyyy-MM-dd HH:mm:ss" set aTZ to "GMT" set bDate to retNSDateFromStringWithTimeZone(aStr, aFormat, aTZ) of me set aGMform to current application’s NSDateFormatter’s alloc()’s init() aGMform’s setDateFormat:"EEE, dd MMM yyyy HH:mm:ss" aGMform’s setTimeZone:(current application’s NSTimeZone’s timeZoneForSecondsFromGMT:0) set usLocale to current application’s NSLocale’s alloc()’s initWithLocaleIdentifier:"GMT" aGMform’s setLocale:usLocale set theDate to aGMform’s stringFromDate:bDate set theDate to theDate’s stringByAppendingString:"GMT" return theDate as string end retRFC822StrFromDateObj on retRFC822StrFromDateStr(aStr) set aFormat to "yyyy-MM-dd HH:mm:ss" set aTZ to "GMT" set bDate to retNSDateFromStringWithTimeZone(aStr, aFormat, aTZ) of me set aGMform to current application’s NSDateFormatter’s alloc()’s init() aGMform’s setDateFormat:"EEE, dd MMM yyyy HH:mm:ss" aGMform’s setTimeZone:(current application’s NSTimeZone’s timeZoneForSecondsFromGMT:0) set usLocale to current application’s NSLocale’s alloc()’s initWithLocaleIdentifier:"GMT" aGMform’s setLocale:usLocale set theDate to aGMform’s stringFromDate:bDate set theDate to theDate’s stringByAppendingString:" GMT" return theDate as string end retRFC822StrFromDateStr on retNSDateFromStringWithTimeZone(aText, aFormat, aTZ) set aStr to current application’s NSString’s stringWithString:aText set theNSDateFormatter to current application’s NSDateFormatter’s alloc()’s init() theNSDateFormatter’s setDateFormat:(current application’s NSString’s stringWithString:aFormat) theNSDateFormatter’s setTimeZone:(current application’s NSTimeZone’s timeZoneWithAbbreviation:(current application’s NSString’s stringWithString:aTZ)) return (theNSDateFormatter’s dateFromString:aStr) –as date end retNSDateFromStringWithTimeZone |
More from my site
(Visited 23 times, 1 visits today)