Menu

Skip to content
AppleScriptの穴
  • Home
  • Products
  • Books
  • Docs
  • Events
  • Forum
  • About This Blog
  • License
  • 仕事依頼

AppleScriptの穴

Useful & Practical AppleScript archive. Click '★Click Here to Open This Script' Link to download each AppleScript

カテゴリー: Calendar

getMlenInternational_ASOC

Posted on 2月 24, 2018 by Takaaki Naganoya

年と月を数値で指定した対象月の日数を計算するAppleScriptです。国際化対応バージョンです。

AppleScriptで日付(date)関連の処理を行うと、どうしても言語依存してしまいがちです。

つまり、日本語環境で作ったAppleScriptをその他の言語環境に持って行ったときに、あるいは逆に英語圏で作られたAppleScriptでまっさきに書き換える必要が出てくるのが、日付関連処理です(その次ぐらいにApple純正アプリケーションの「過剰ローカライズ」によりAppleScriptのオブジェクト名までローカライズされてしまうので、その点を書き換えるとか)。

日本語環境以外で通じる処理を書くというのは、けっこう練習が必要です。ただ、国際化対応の処理をいったん書いておけば、二度目からはその処理を使い回すだけです。

そんな、言語環境非依存で真っ先に必要になってくる、指定月の日数計算を書いたものです。少なくとも、Mac App Storeに出すアプリケーションを書くのであれば、こうした他の言語環境でも動作するルーチンを整備しておく必要があります。

AppleScript名:getMlenInternational_ASOC
— Created 2015-02-02 by Shane Stanley
— Modified 2015-02-02 by Takaaki Naganoya
use AppleScript version "2.4"
use scripting additions
use framework "Foundation"

set mList to {}
repeat with m from 1 to 12
  set the end of mList to getMlenInternational(2012, m) of me –2012 is a Leap Year–2012年はうるう年
end repeat
mList
–>  {​​​​​31, ​​​​​29, ​​​​​31, ​​​​​30, ​​​​​31, ​​​​​30, ​​​​​31, ​​​​​31, ​​​​​30, ​​​​​31, ​​​​​30, ​​​​​31​​​}

–現在のカレンダーで指定年月の日数を返す
on getMlenInternational(aYear, aMonth)
  –From Shane’s getMlenInternational(ASOC) v1
  
set theNSCalendar to current application’s NSCalendar’s currentCalendar() — do *not* use initWithCalendarIdentifier:
  
set theDate to theNSCalendar’s dateWithEra:1 |year|:aYear |month|:aMonth |day|:1 hour:0 minute:0 |second|:0 nanosecond:0
  
set theResult to theNSCalendar’s rangeOfUnit:(current application’s NSDayCalendarUnit) inUnit:(current application’s NSMonthCalendarUnit) forDate:theDate
  
–>  {location:1, length:31}
  
return |length| of theResult
end getMlenInternational

★Click Here to Open This Script 

Posted in Calendar | Tagged 10.11savvy 10.12savvy 10.13savvy | Leave a comment

数値の秒を文字フォーマットして返す

Posted on 2月 24, 2018 by Takaaki Naganoya
AppleScript名:数値の秒を文字フォーマットして返す
— Created 2016-02-09 by Takaaki Naganoya
— 2016 Piyomaru Software
use AppleScript version "2.4"
use scripting additions
use framework "Foundation"

set aStr to formatTimeNum(61) of me
–> "01分 01秒"

set bStr to formatTimeNum(3700) of me
–> "01時間 01分 40秒"

set cStr to formatTimeNum(9100) of me
–> "02時間 31分 40秒"

set dStr to formatTimeNum(720001) of me
–>"200時間 00分 01秒"

set eStr to formatTimeNum(7200001) of me
–>"2000時間 00分 01秒"

–数値の秒を文字フォーマットして返す
on formatTimeNum(a)
  set hourStr to "時間 "
  
set minuteStr to "分 "
  
set secStr to "秒"
  
  
set aRec to separateSec(a) of me
  
set aStr to ""
  
set anHour to hourNum of aRec
  
set aMinute to minuteNum of aRec
  
set aSec to secondNum of aRec
  
  
if anHour > 0 then
    set aStr to aStr & retZeroPaddingText(anHour, 2) of me & hourStr
    
set aStr to aStr & retZeroPaddingText(aMinute, 2) of me & minuteStr
  else if aMinute > 0 then
    set aStr to aStr & retZeroPaddingText(aMinute, 2) of me & minuteStr
  end if
  
set aStr to aStr & retZeroPaddingText(aSec, 2) of me & secStr
  
  
return aStr
end formatTimeNum

—数値の秒を時、分、秒に分解する
on separateSec(a)
  set anHour to a div 3600
  
set b to a – (anHour * 3600)
  
set aMinute to b div 60
  
set c to b – (aMinute * 60)
  
return {hourNum:anHour, minuteNum:aMinute, secondNum:c}
end separateSec

–ゼロパディング
on retZeroPaddingText(aNum as integer, aDigitNum as integer)
  if aNum > (((10 ^ aDigitNum) as integer) – 1) then
    return aNum as string –指定桁数を数値データがオーバーしたら数値を文字化してそのまま返す
  end if
  
set aFormatter to current application’s NSNumberFormatter’s alloc()’s init()
  
aFormatter’s setUsesGroupingSeparator:false
  
aFormatter’s setAllowsFloats:false
  
aFormatter’s setMaximumIntegerDigits:aDigitNum
  
aFormatter’s setMinimumIntegerDigits:aDigitNum
  
aFormatter’s setPaddingCharacter:"0"
  
set aStr to aFormatter’s stringFromNumber:(current application’s NSNumber’s numberWithFloat:aNum)
  
return aStr as string
end retZeroPaddingText

★Click Here to Open This Script 

Posted in Calendar | Tagged 10.11savvy 10.12savvy 10.13savvy | Leave a comment

午前午後のローカライズ名称を返す

Posted on 2月 24, 2018 by Takaaki Naganoya
AppleScript名:午前午後のローカライズ名称を返す
— Created 2017-12-19 01:14:42 +0900 by Takaaki Naganoya
— 2017 Piyomaru Software
use AppleScript version "2.4"
use scripting additions
use framework "Foundation"

set bList to getLocalizedAMSymbol("ja_JP") of me
–>  "午前"

set bList to getLocalizedPMSymbol("ja_JP") of me
–>  "午後"

–ローカライズされた午前の名称を返す
on getLocalizedAMSymbol(aLoc)
  set df to current application’s NSDateFormatter’s alloc()’s init()
  
df’s setLocale:(current application’s NSLocale’s localeWithLocaleIdentifier:aLoc)
  
set dayNames to df’s AMSymbol()
  
return dayNames as string
end getLocalizedAMSymbol

–ローカライズされた午後の名称を返す
on getLocalizedPMSymbol(aLoc)
  set df to current application’s NSDateFormatter’s alloc()’s init()
  
df’s setLocale:(current application’s NSLocale’s localeWithLocaleIdentifier:aLoc)
  
set dayNames to df’s PMSymbol()
  
return dayNames as string
end getLocalizedPMSymbol

★Click Here to Open This Script 

Posted in Calendar | Tagged 10.11savvy 10.12savvy 10.13savvy | Leave a comment

元号変換v31

Posted on 2月 24, 2018 by Takaaki Naganoya
AppleScript名:元号変換v31
set a to "2010/7/21"
set a to parseDate(a) of me
set {aGengoStr, aGengoNum} to retJapaneseGengo(a) of me
–> {"平成", 22}

on retJapaneseGengo(aDate)
  
  
set aYear to year of aDate
  
set aMonth to month of aDate as number
  
set aDay to day of aDate
  
  
set aStr to retZeroPaddingText(aYear, 4) of me & retZeroPaddingText(aMonth, 2) of me & retZeroPaddingText(aDay, 2) of me
  
  
set aGengo to ""
  
if aStr ≥ "19890108" then
    set aGengo to "平成"
    
set aGengoNum to aYear – 1989 + 1
  else if aStr ≥ "19261225" then
    set aGengo to "昭和"
    
set aGengoNum to aYear – 1926 + 1
  else if aStr ≥ "19120730" then
    set aGengo to "大正"
    
set aGengoNum to aYear – 1912 + 1
  else if aStr ≥ "18680125" then
    set aGengo to "明治"
    
set aGengoNum to aYear – 1868 + 1
  end if
  
  
return {aGengo, aGengoNum}
  
end retJapaneseGengo

–数値にゼロパディングしたテキストを返す
on retZeroPaddingText(aNum, aLen)
  set tText to ("0000000000" & aNum as text)
  
set tCount to length of tText
  
set resText to text (tCount – aLen + 1) thru tCount of tText
  
return resText
end retZeroPaddingText

on parseDate(inStr)
  set aClass to class of inStr
  
if aClass = string then
    try
      set aDate to date inStr
    on error
      return false
    end try
  else if aClass = date then
    set aDate to inStr
    
  end if
  
  
return aDate
  
end parseDate

★Click Here to Open This Script 

Posted in Calendar | Tagged 10.11savvy 10.12savvy 10.13savvy | Leave a comment

現在のLocaleのIdentifier文字を取得する

Posted on 2月 22, 2018 by Takaaki Naganoya
AppleScript名:現在のLocaleのIdentifier文字を取得する.scpt
use AppleScript version "2.7"
use scripting additions
use framework "Foundation"

set aLoc to (current application’s NSLocale’s currentLocale()’s identifier()) as anything
log aLoc
–> "ja_JP"

set aLoc to (current application’s NSLocale’s systemLocale()’s identifier()) as anything
log aLoc
–>  (__NSCFLocale) <__NSCFLocale: 0x6180000f5480>

set isoCountry to (current application’s NSLocale’s ISOCountryCodes()) as anything
log isoCountry
–>  (NSArray) {​​​​​"AD", ​​​​​"AE", ​​​​​"AF", ​​​​​"AG", ​​​​​"AI", ​​​​​"AL", ​​​​​"AM", ​​​​​"AO", ​​​​​"AQ", ​​​​​"AR", ​​​​​"AS", ​​​​​"AT", ​​​​​"AU", ​​​​​"AW", ​​​​​"AX", ​​​​​"AZ", ​​​​​"BA", ​​​​​"BB", ​​​​​"BD", ​​​​​"BE", ​​​​​"BF", ​​​​​"BG", ​​​​​"BH", ​​​​​"BI", ​​​​​"BJ", ​​​​​"BL", ​​​​​"BM", ​​​​​"BN", ​​​​​"BO", ​​​​​"BQ", ​​​​​"BR", ​​​​​"BS", ​​​​​"BT", ​​​​​"BV", ​​​​​"BW", ​​​​​"BY", ​​​​​"BZ", ​​​​​"CA", ​​​​​"CC", ​​​​​"CD", ​​​​​"CF", ​​​​​"CG", ​​​​​"CH", ​​​​​"CI", ​​​​​"CK", ​​​​​"CL", ​​​​​"CM", ​​​​​"CN", ​​​​​"CO", ​​​​​"CR", ​​​​​"CU", ​​​​​"CV", ​​​​​"CW", ​​​​​"CX", ​​​​​"CY", ​​​​​"CZ", ​​​​​"DE", ​​​​​"DJ", ​​​​​"DK", ​​​​​"DM", ​​​​​"DO", ​​​​​"DZ", ​​​​​"EC", ​​​​​"EE", ​​​​​"EG", ​​​​​"EH", ​​​​​"ER", ​​​​​"ES", ​​​​​"ET", ​​​​​"FI", ​​​​​"FJ", ​​​​​"FK", ​​​​​"FM", ​​​​​"FO", ​​​​​"FR", ​​​​​"GA", ​​​​​"GB", ​​​​​"GD", ​​​​​"GE", ​​​​​"GF", ​​​​​"GG", ​​​​​"GH", ​​​​​"GI", ​​​​​"GL", ​​​​​"GM", ​​​​​"GN", ​​​​​"GP", ​​​​​"GQ", ​​​​​"GR", ​​​​​"GS", ​​​​​"GT", ​​​​​"GU", ​​​​​"GW", ​​​​​"GY", ​​​​​"HK", ​​​​​"HM", ​​​​​"HN", ​​​​​"HR", ​​​​​"HT", ​​​​​"HU", ​​​​​"ID", ​​​​​"IE", ​​​​​"IL", ​​​​​"IM", ​​​​​"IN", ​​​​​"IO", ​​​​​"IQ", ​​​​​"IR", ​​​​​"IS", ​​​​​"IT", ​​​​​"JE", ​​​​​"JM", ​​​​​"JO", ​​​​​"JP", ​​​​​"KE", ​​​​​"KG", ​​​​​"KH", ​​​​​"KI", ​​​​​"KM", ​​​​​"KN", ​​​​​"KP", ​​​​​"KR", ​​​​​"KW", ​​​​​"KY", ​​​​​"KZ", ​​​​​"LA", ​​​​​"LB", ​​​​​"LC", ​​​​​"LI", ​​​​​"LK", ​​​​​"LR", ​​​​​"LS", ​​​​​"LT", ​​​​​"LU", ​​​​​"LV", ​​​​​"LY", ​​​​​"MA", ​​​​​"MC", ​​​​​"MD", ​​​​​"ME", ​​​​​"MF", ​​​​​"MG", ​​​​​"MH", ​​​​​"MK", ​​​​​"ML", ​​​​​"MM", ​​​​​"MN", ​​​​​"MO", ​​​​​"MP", ​​​​​"MQ", ​​​​​"MR", ​​​​​"MS", ​​​​​"MT", ​​​​​"MU", ​​​​​"MV", ​​​​​"MW", ​​​​​"MX", ​​​​​"MY", ​​​​​"MZ", ​​​​​"NA", ​​​​​"NC", ​​​​​"NE", ​​​​​"NF", ​​​​​"NG", ​​​​​"NI", ​​​​​"NL", ​​​​​"NO", ​​​​​"NP", ​​​​​"NR", ​​​​​"NU", ​​​​​"NZ", ​​​​​"OM", ​​​​​"PA", ​​​​​"PE", ​​​​​"PF", ​​​​​"PG", ​​​​​"PH", ​​​​​"PK", ​​​​​"PL", ​​​​​"PM", ​​​​​"PN", ​​​​​"PR", ​​​​​"PS", ​​​​​"PT", ​​​​​"PW", ​​​​​"PY", ​​​​​"QA", ​​​​​"RE", ​​​​​"RO", ​​​​​"RS", ​​​​​"RU", ​​​​​"RW", ​​​​​"SA", ​​​​​"SB", ​​​​​"SC", ​​​​​"SD", ​​​​​"SE", ​​​​​"SG", ​​​​​"SH", ​​​​​"SI", ​​​​​"SJ", ​​​​​"SK", ​​​​​"SL", ​​​​​"SM", ​​​​​"SN", ​​​​​"SO", ​​​​​"SR", ​​​​​"SS", ​​​​​"ST", ​​​​​"SV", ​​​​​"SX", ​​​​​"SY", ​​​​​"SZ", ​​​​​"TC", ​​​​​"TD", ​​​​​"TF", ​​​​​"TG", ​​​​​"TH", ​​​​​"TJ", ​​​​​"TK", ​​​​​"TL", ​​​​​"TM", ​​​​​"TN", ​​​​​"TO", ​​​​​"TR", ​​​​​"TT", ​​​​​"TV", ​​​​​"TW", ​​​​​"TZ", ​​​​​"UA", ​​​​​"UG", ​​​​​"UM", ​​​​​"US", ​​​​​"UY", ​​​​​"UZ", ​​​​​"VA", ​​​​​"VC", ​​​​​"VE", ​​​​​"VG", ​​​​​"VI", ​​​​​"VN", ​​​​​"VU", ​​​​​"WF", ​​​​​"WS", ​​​​​"YE", ​​​​​"YT", ​​​​​"ZA", ​​​​​"ZM", ​​​​​"ZW"​​​}

set isoCurrency to (current application’s NSLocale’s ISOCurrencyCodes()) as anything
log isoCurrency
–>   {​​​​​"ADP", ​​​​​"AED", ​​​​​"AFA", ​​​​​"AFN", ​​​​​"ALK", ​​​​​"ALL", ​​​​​"AMD", ​​​​​"ANG", ​​​​​"AOA", ​​​​​"AOK", ​​​​​"AON", ​​​​​"AOR", ​​​​​"ARA", ​​​​​"ARL", ​​​​​"ARM", ​​​​​"ARP", ​​​​​"ARS", ​​​​​"ATS", ​​​​​"AUD", ​​​​​"AWG", ​​​​​"AZM", ​​​​​"AZN", ​​​​​"BAD", ​​​​​"BAM", ​​​​​"BAN", ​​​​​"BBD", ​​​​​"BDT", ​​​​​"BEC", ​​​​​"BEF", ​​​​​"BEL", ​​​​​"BGL", ​​​​​"BGM", ​​​​​"BGN", ​​​​​"BGO", ​​​​​"BHD", ​​​​​"BIF", ​​​​​"BMD", ​​​​​"BND", ​​​​​"BOB", ​​​​​"BOL", ​​​​​"BOP", ​​​​​"BOV", ​​​​​"BRB", ​​​​​"BRC", ​​​​​"BRE", ​​​​​"BRL", ​​​​​"BRN", ​​​​​"BRR", ​​​​​"BRZ", ​​​​​"BSD", ​​​​​"BTN", ​​​​​"BUK", ​​​​​"BWP", ​​​​​"BYB", ​​​​​"BYR", ​​​​​"BZD", ​​​​​"CAD", ​​​​​"CDF", ​​​​​"CHE", ​​​​​"CHF", ​​​​​"CHW", ​​​​​"CLE", ​​​​​"CLF", ​​​​​"CLP", ​​​​​"CNX", ​​​​​"CNY", ​​​​​"COP", ​​​​​"COU", ​​​​​"CRC", ​​​​​"CSD", ​​​​​"CSK", ​​​​​"CUC", ​​​​​"CUP", ​​​​​"CVE", ​​​​​"CYP", ​​​​​"CZK", ​​​​​"DDM", ​​​​​"DEM", ​​​​​"DJF", ​​​​​"DKK", ​​​​​"DOP", ​​​​​"DZD", ​​​​​"ECS", ​​​​​"ECV", ​​​​​"EEK", ​​​​​"EGP", ​​​​​"EQE", ​​​​​"ERN", ​​​​​"ESA", ​​​​​"ESB", ​​​​​"ESP", ​​​​​"ETB", ​​​​​"EUR", ​​​​​"FIM", ​​​​​"FJD", ​​​​​"FKP", ​​​​​"FRF", ​​​​​"GBP", ​​​​​"GEK", ​​​​​"GEL", ​​​​​"GHC", ​​​​​"GHS", ​​​​​"GIP", ​​​​​"GMD", ​​​​​"GNF", ​​​​​"GNS", ​​​​​"GQE", ​​​​​"GRD", ​​​​​"GTQ", ​​​​​"GWE", ​​​​​"GWP", ​​​​​"GYD", ​​​​​"HKD", ​​​​​"HNL", ​​​​​"HRD", ​​​​​"HRK", ​​​​​"HTG", ​​​​​"HUF", ​​​​​"IDR", ​​​​​"IEP", ​​​​​"ILP", ​​​​​"ILR", ​​​​​"ILS", ​​​​​"INR", ​​​​​"IQD", ​​​​​"IRR", ​​​​​"ISJ", ​​​​​"ISK", ​​​​​"ITL", ​​​​​"JMD", ​​​​​"JOD", ​​​​​"JPY", ​​​​​"KES", ​​​​​"KGS", ​​​​​"KHR", ​​​​​"KMF", ​​​​​"KPW", ​​​​​"KRH", ​​​​​"KRO", ​​​​​"KRW", ​​​​​"KWD", ​​​​​"KYD", ​​​​​"KZT", ​​​​​"LAK", ​​​​​"LBP", ​​​​​"LKR", ​​​​​"LRD", ​​​​​"LSL", ​​​​​"LSM", ​​​​​"LTL", ​​​​​"LTT", ​​​​​"LUC", ​​​​​"LUF", ​​​​​"LUL", ​​​​​"LVL", ​​​​​"LVR", ​​​​​"LYD", ​​​​​"MAD", ​​​​​"MAF", ​​​​​"MCF", ​​​​​"MDC", ​​​​​"MDL", ​​​​​"MGA", ​​​​​"MGF", ​​​​​"MKD", ​​​​​"MKN", ​​​​​"MLF", ​​​​​"MMK", ​​​​​"MNT", ​​​​​"MOP", ​​​​​"MRO", ​​​​​"MTL", ​​​​​"MTP", ​​​​​"MUR", ​​​​​"MVP", ​​​​​"MVR", ​​​​​"MWK", ​​​​​"MXN", ​​​​​"MXP", ​​​​​"MXV", ​​​​​"MYR", ​​​​​"MZE", ​​​​​"MZM", ​​​​​"MZN", ​​​​​"NAD", ​​​​​"NGN", ​​​​​"NIC", ​​​​​"NIO", ​​​​​"NLG", ​​​​​"NOK", ​​​​​"NPR", ​​​​​"NZD", ​​​​​"OMR", ​​​​​"PAB", ​​​​​"PEI", ​​​​​"PEN", ​​​​​"PES", ​​​​​"PGK", ​​​​​"PHP", ​​​​​"PKR", ​​​​​"PLN", ​​​​​"PLZ", ​​​​​"PTE", ​​​​​"PYG", ​​​​​"QAR", ​​​​​"RHD", ​​​​​"ROL", ​​​​​"RON", ​​​​​"RSD", ​​​​​"RUB", ​​​​​"RUR", ​​​​​"RWF", ​​​​​"SAR", ​​​​​"SBD", ​​​​​"SCR", ​​​​​"SDD", ​​​​​"SDG", ​​​​​"SDP", ​​​​​"SEK", ​​​​​"SGD", ​​​​​"SHP", ​​​​​"SIT", ​​​​​"SKK", ​​​​​"SLL", ​​​​​"SOS", ​​​​​"SRD", ​​​​​"SRG", ​​​​​"SSP", ​​​​​"STD", ​​​​​"SUR", ​​​​​"SVC", ​​​​​"SYP", ​​​​​"SZL", ​​​​​"THB", ​​​​​"TJR", ​​​​​"TJS", ​​​​​"TMM", ​​​​​"TMT", ​​​​​"TND", ​​​​​"TOP", ​​​​​"TPE", ​​​​​"TRL", ​​​​​"TRY", ​​​​​"TTD", ​​​​​"TWD", ​​​​​"TZS", ​​​​​"UAH", ​​​​​"UAK", ​​​​​"UGS", ​​​​​"UGX", ​​​​​"USD", ​​​​​"USN", ​​​​​"USS", ​​​​​"UYI", ​​​​​"UYP", ​​​​​"UYU", ​​​​​"UZS", ​​​​​"VEB", ​​​​​"VEF", ​​​​​"VND", ​​​​​"VNN", ​​​​​"VUV", ​​​​​"WST", ​​​​​"XAF", ​​​​​"XAG", ​​​​​"XAU", ​​​​​"XBA", ​​​​​"XBB", ​​​​​"XBC", ​​​​​"XBD", ​​​​​"XCD", ​​​​​"XDR", ​​​​​"XEU", ​​​​​"XFO", ​​​​​"XFU", ​​​​​"XOF", ​​​​​"XPD", ​​​​​"XPF", ​​​​​"XPT", ​​​​​"XRE", ​​​​​"XSU", ​​​​​"XTS", ​​​​​"XUA", ​​​​​"XXX", ​​​​​"YDD", ​​​​​"YER", ​​​​​"YUD", ​​​​​"YUM", ​​​​​"YUN", ​​​​​"YUR", ​​​​​"ZAL", ​​​​​"ZAR", ​​​​​"ZMK", ​​​​​"ZMW", ​​​​​"ZRN", ​​​​​"ZRZ", ​​​​​"ZWL", ​​​​​"ZWR", ​​​​​"ZWD"​​​}

set aveLoc to (current application’s NSLocale’s availableLocaleIdentifiers()) as anything
log aveLoc
–>  {​​​​​"eu", ​​​​​"hr_BA", ​​​​​"en_CM", ​​​​​"rw_RW", ​​​​​"en_SZ", ​​​​​"tk_Latn", ​​​​​"uz_Arab", ​​​​​"he_IL", ​​​​​"ar", ​​​​​"en_PN", ​​​​​"as", ​​​​​"en_NF", ​​​​​"rwk_TZ", ​​​​​"zh_Hant_TW", ​​​​​"gsw_LI", ​​​​​"th_TH", ​​​​​"ta_IN", ​​​​​"es_EA", ​​​​​"fr_GF", ​​​​​"ar_001", ​​​​​"en_RW", ​​​​​"tr_TR", ​​​​​"de_CH", ​​​​​"ee_TG", ​​​​​"en_NG", ​​​​​"fr_TG", ​​​​​"az", ​​​​​"fr_SC", ​​​​​"es_HN", ​​​​​"en_AG", ​​​​​"ru_KZ", ​​​​​"gsw", ​​​​​"dyo", ​​​​​"so_ET", ​​​​​"zh_Hant_MO", ​​​​​"de_BE", ​​​​​"km_KH", ​​​​​"my_MM", ​​​​​"mgh_MZ", ​​​​​"ee_GH", ​​​​​"es_EC", ​​​​​"kw_GB", ​​​​​"rm_CH", ​​​​​"en_ME", ​​​​​"nyn", ​​​​​"mk_MK", ​​​​​"bs_Cyrl_BA", ​​​​​"ar_MR", ​​​​​"en_BM", ​​​​​"ms_Arab", ​​​​​"en_AI", ​​​​​"gl_ES", ​​​​​"en_PR", ​​​​​"ha_Latn_GH", ​​​​​"ne_IN", ​​​​​"or_IN", ​​​​​"khq_ML", ​​​​​"en_MG", ​​​​​"pt_TL", ​​​​​"en_LC", ​​​​​"ta_SG", ​​​​​"jmc_TZ", ​​​​​"om_ET", ​​​​​"lv_LV", ​​​​​"es_US", ​​​​​"en_PT", ​​​​​"vai_Latn_LR", ​​​​​"to_TO", ​​​​​"en_NL", ​​​​​"cgg_UG", ​​​​​"ta", ​​​​​"en_MH", ​​​​​"iu_Cans_CA", ​​​​​"zu_ZA", ​​​​​"shi_Latn_MA", ​​​​​"brx_IN", ​​​​​"ar_KM", ​​​​​"en_AL", ​​​​​"te", ​​​​​"chr_US", ​​​​​"yo_BJ", ​​​​​"fr_VU", ​​​​​"pa", ​​​​​"tg", ​​​​​"ks_Arab", ​​​​​"kea", ​​​​​"te_IN", ​​​​​"th", ​​​​​"fr_RE", ​​​​​"ur_IN", ​​​​​"yo_NG", ​​​​​"ti", ​​​​​"guz_KE", ​​​​​"tk", ​​​​​"kl_GL", ​​​​​"ksf_CM", ​​​​​"mua_CM", ​​​​​"lag_TZ", ​​​​​"fr_TN", ​​​​​"es_PA", ​​​​​"pl_PL", ​​​​​"to", ​​​​​"hi_IN", ​​​​​"dje_NE", ​​​​​"es_GQ", ​​​​​"kok_IN", ​​​​​"pl", ​​​​​"tr", ​​​​​"bem", ​​​​​"ha", ​​​​​"ckb", ​​​​​"lg", ​​​​​"fr_GN", ​​​​​"en_PW", ​​​​​"en_NO", ​​​​​"nyn_UG", ​​​​​"sr_Latn_RS", ​​​​​"pa_Guru", ​​​​​"he", ​​​​​"swc_CD", ​​​​​"ug_Arab", ​​​​​"lu_CD", ​​​​​"mgo_CM", ​​​​​"sn_ZW", ​​​​​"en_BS", ​​​​​"ps_AF", ​​​​​"da", ​​​​​"ms_Latn_SG", ​​​​​"ps", ​​​​​"ln", ​​​​​"pt", ​​​​​"iu_Cans", ​​​​​"hi", ​​​​​"lo", ​​​​​"ebu", ​​​​​"de", ​​​​​"gu_IN", ​​​​​"seh", ​​​​​"en_CX", ​​​​​"en_ZM", ​​​​​"tzm_Latn_MA", ​​​​​"fr_HT", ​​​​​"fr_GP", ​​​​​"lt", ​​​​​"lu", ​​​​​"ln_CD", ​​​​​"vai_Latn", ​​​​​"el_GR", ​​​​​"lv", ​​​​​"en_KE", ​​​​​"sbp", ​​​​​"hr", ​​​​​"en_CY", ​​​​​"es_GT", ​​​​​"twq_NE", ​​​​​"zh_Hant_HK", ​​​​​"kln_KE", ​​​​​"fr_GQ", ​​​​​"chr", ​​​​​"hu", ​​​​​"es_UY", ​​​​​"fr_CA", ​​​​​"en_NR", ​​​​​"mer", ​​​​​"shi", ​​​​​"es_PE", ​​​​​"fr_SN", ​​​​​"bez", ​​​​​"sw_TZ", ​​​​​"kkj", ​​​​​"hy", ​​​​​"kk_Cyrl_KZ", ​​​​​"en_CZ", ​​​​​"teo_KE", ​​​​​"teo", ​​​​​"dz_BT", ​​​​​"ar_JO", ​​​​​"mer_KE", ​​​​​"khq", ​​​​​"ln_CF", ​​​​​"nn_NO", ​​​​​"en_MO", ​​​​​"ar_TD", ​​​​​"dz", ​​​​​"ses", ​​​​​"en_BW", ​​​​​"en_AS", ​​​​​"ar_IL", ​​​​​"ms_Latn_BN", ​​​​​"bo_CN", ​​​​​"nnh", ​​​​​"teo_UG", ​​​​​"hy_AM", ​​​​​"ln_CG", ​​​​​"sr_Latn_BA", ​​​​​"en_MP", ​​​​​"ksb_TZ", ​​​​​"ar_SA", ​​​​​"ar_LY", ​​​​​"en_AT", ​​​​​"so_KE", ​​​​​"fr_CD", ​​​​​"af_NA", ​​​​​"en_NU", ​​​​​"es_PH", ​​​​​"en_KI", ​​​​​"en_JE", ​​​​​"lkt", ​​​​​"en_AU", ​​​​​"fa_IR", ​​​​​"uz_Latn_UZ", ​​​​​"ky_Cyrl", ​​​​​"zh_Hans_CN", ​​​​​"ewo_CM", ​​​​​"fr_PF", ​​​​​"ca_IT", ​​​​​"en_BZ", ​​​​​"ar_KW", ​​​​​"pt_GW", ​​​​​"fr_FR", ​​​​​"am_ET", ​​​​​"en_VC", ​​​​​"fr_DJ", ​​​​​"fr_CF", ​​​​​"es_SV", ​​​​​"en_MS", ​​​​​"pt_ST", ​​​​​"ar_SD", ​​​​​"luy_KE", ​​​​​"swc", ​​​​​"de_LI", ​​​​​"fr_CG", ​​​​​"zh_Hans_SG", ​​​​​"en_MT", ​​​​​"ewo", ​​​​​"af_ZA", ​​​​​"om_KE", ​​​​​"nl_SR", ​​​​​"es_ES", ​​​​​"es_DO", ​​​​​"ar_IQ", ​​​​​"fr_CH", ​​​​​"nnh_CM", ​​​​​"es_419", ​​​​​"en_MU", ​​​​​"en_US_POSIX", ​​​​​"yav_CM", ​​​​​"luo_KE", ​​​​​"dua_CM", ​​​​​"et_EE", ​​​​​"en_IE", ​​​​​"ak_GH", ​​​​​"rwk", ​​​​​"es_CL", ​​​​​"kea_CV", ​​​​​"fr_CI", ​​​​​"fr_BE", ​​​​​"en_NZ", ​​​​​"ky_Cyrl_KG", ​​​​​"en_LR", ​​​​​"en_KN", ​​​​​"nb_SJ", ​​​​​"sg", ​​​​​"sr_Cyrl_RS", ​​​​​"ru_RU", ​​​​​"en_ZW", ​​​​​"sv_AX", ​​​​​"si", ​​​​​"ga_IE", ​​​​​"en_VG", ​​​​​"sk", ​​​​​"agq_CM", ​​​​​"fr_BF", ​​​​​"naq_NA", ​​​​​"sl", ​​​​​"en_MW", ​​​​​"mr_IN", ​​​​​"az_Latn", ​​​​​"en_LS", ​​​​​"de_AT", ​​​​​"ka", ​​​​​"sn", ​​​​​"sr_Latn_ME", ​​​​​"fr_NC", ​​​​​"so", ​​​​​"is_IS", ​​​​​"twq", ​​​​​"ig_NG", ​​​​​"sq", ​​​​​"fo_FO", ​​​​​"sr", ​​​​​"tzm", ​​​​​"ga", ​​​​​"om", ​​​​​"en_LT", ​​​​​"bas_CM", ​​​​​"ki", ​​​​​"nl_BE", ​​​​​"ar_QA", ​​​​​"sv", ​​​​​"kk", ​​​​​"sw", ​​​​​"es_CO", ​​​​​"az_Latn_AZ", ​​​​​"rn_BI", ​​​​​"or", ​​​​​"kl", ​​​​​"ca", ​​​​​"en_VI", ​​​​​"km", ​​​​​"kn", ​​​​​"en_LU", ​​​​​"fr_SY", ​​​​​"ar_TN", ​​​​​"en_JM", ​​​​​"fr_PM", ​​​​​"ko", ​​​​​"fr_NE", ​​​​​"fr_MA", ​​​​​"gl", ​​​​​"ru_MD", ​​​​​"saq_KE", ​​​​​"ks", ​​​​​"fr_CM", ​​​​​"gv_IM", ​​​​​"fr_BI", ​​​​​"en_LV", ​​​​​"ks_Arab_IN", ​​​​​"es_NI", ​​​​​"en_GB", ​​​​​"kw", ​​​​​"nl_SX", ​​​​​"dav_KE", ​​​​​"tr_CY", ​​​​​"ky", ​​​​​"en_UG", ​​​​​"tzm_Latn", ​​​​​"en_TC", ​​​​​"nus_SD", ​​​​​"ar_EG", ​​​​​"fr_BJ", ​​​​​"gu", ​​​​​"es_PR", ​​​​​"fr_RW", ​​​​​"sr_Cyrl_BA", ​​​​​"gv", ​​​​​"fr_MC", ​​​​​"cs", ​​​​​"bez_TZ", ​​​​​"es_CR", ​​​​​"asa_TZ", ​​​​​"ar_EH", ​​​​​"ms_Arab_BN", ​​​​​"mn_Cyrl", ​​​​​"sbp_TZ", ​​​​​"ha_Latn_NE", ​​​​​"lt_LT", ​​​​​"mfe", ​​​​​"en_GD", ​​​​​"cy", ​​​​​"ca_FR", ​​​​​"es_BO", ​​​​​"fr_BL", ​​​​​"bn_IN", ​​​​​"uz_Cyrl_UZ", ​​​​​"az_Cyrl", ​​​​​"en_IM", ​​​​​"sw_KE", ​​​​​"en_SB", ​​​​​"ur_PK", ​​​​​"pa_Arab", ​​​​​"haw_US", ​​​​​"ar_SO", ​​​​​"en_IN", ​​​​​"ha_Latn", ​​​​​"fil", ​​​​​"fr_MF", ​​​​​"en_WS", ​​​​​"es_CU", ​​​​​"ja_JP", ​​​​​"en_SC", ​​​​​"en_IO", ​​​​​"pt_PT", ​​​​​"en_HK", ​​​​​"en_GG", ​​​​​"fr_MG", ​​​​​"de_LU", ​​​​​"ms_Latn_MY", ​​​​​"tg_Cyrl", ​​​​​"en_SD", ​​​​​"shi_Tfng", ​​​​​"ln_AO", ​​​​​"ug_Arab_CN", ​​​​​"as_IN", ​​​​​"en_GH", ​​​​​"ro_RO", ​​​​​"jgo_CM", ​​​​​"dua", ​​​​​"en_UM", ​​​​​"en_SE", ​​​​​"kn_IN", ​​​​​"en_KY", ​​​​​"vun_TZ", ​​​​​"kln", ​​​​​"en_GI", ​​​​​"ca_ES", ​​​​​"rof", ​​​​​"pt_CV", ​​​​​"kok", ​​​​​"pt_BR", ​​​​​"ar_DJ", ​​​​​"zh", ​​​​​"fi_FI", ​​​​​"tg_Cyrl_TJ", ​​​​​"es_PY", ​​​​​"ar_SS", ​​​​​"mua", ​​​​​"sr_Cyrl_ME", ​​​​​"vai_Vaii_LR", ​​​​​"en_001", ​​​​​"xog_UG", ​​​​​"en_TK", ​​​​​"si_LK", ​​​​​"en_SG", ​​​​​"nl_NL", ​​​​​"vi", ​​​​​"sv_SE", ​​​​​"pt_AO", ​​​​​"fr_DZ", ​​​​​"ca_AD", ​​​​​"xog", ​​​​​"en_IS", ​​​​​"nb", ​​​​​"seh_MZ", ​​​​​"es_AR", ​​​​​"sk_SK", ​​​​​"en_SH", ​​​​​"ti_ER", ​​​​​"nd", ​​​​​"az_Cyrl_AZ", ​​​​​"zu", ​​​​​"ne", ​​​​​"nd_ZW", ​​​​​"el_CY", ​​​​​"en_IT", ​​​​​"nl_BQ", ​​​​​"da_GL", ​​​​​"ja", ​​​​​"rm", ​​​​​"fr_ML", ​​​​​"rn", ​​​​​"en_VU", ​​​​​"rof_TZ", ​​​​​"ro", ​​​​​"ebu_KE", ​​​​​"ru_KG", ​​​​​"en_SI", ​​​​​"sg_CF", ​​​​​"mfe_MU", ​​​​​"nl", ​​​​​"brx", ​​​​​"bs_Latn", ​​​​​"fa", ​​​​​"zgh_MA", ​​​​​"en_GM", ​​​​​"shi_Latn", ​​​​​"en_FI", ​​​​​"nn", ​​​​​"en_EE", ​​​​​"ru", ​​​​​"kam_KE", ​​​​​"vai_Vaii", ​​​​​"ar_ER", ​​​​​"ti_ET", ​​​​​"rw", ​​​​​"ff", ​​​​​"luo", ​​​​​"fa_AF", ​​​​​"ha_Latn_NG", ​​​​​"nl_CW", ​​​​​"en_HR", ​​​​​"en_FJ", ​​​​​"fi", ​​​​​"pt_MO", ​​​​​"be", ​​​​​"en_US", ​​​​​"en_TO", ​​​​​"en_SK", ​​​​​"bg", ​​​​​"ru_BY", ​​​​​"it_IT", ​​​​​"ml_IN", ​​​​​"gsw_CH", ​​​​​"fo", ​​​​​"sv_FI", ​​​​​"en_FK", ​​​​​"nus", ​​​​​"ta_LK", ​​​​​"vun", ​​​​​"sr_Latn", ​​​​​"fr", ​​​​​"en_SL", ​​​​​"bm", ​​​​​"ar_BH", ​​​​​"guz", ​​​​​"bn", ​​​​​"bo", ​​​​​"ar_SY", ​​​​​"lo_LA", ​​​​​"ne_NP", ​​​​​"uz_Latn", ​​​​​"be_BY", ​​​​​"es_IC", ​​​​​"sr_Latn_XK", ​​​​​"ar_MA", ​​​​​"pa_Guru_IN", ​​​​​"br", ​​​​​"luy", ​​​​​"kde_TZ", ​​​​​"bs", ​​​​​"hu_HU", ​​​​​"ar_AE", ​​​​​"en_HU", ​​​​​"zh_Hans", ​​​​​"en_FM", ​​​​​"sq_AL", ​​​​​"ko_KP", ​​​​​"en_150", ​​​​​"en_DE", ​​​​​"fr_MQ", ​​​​​"en_CA", ​​​​​"en_TR", ​​​​​"ro_MD", ​​​​​"es_VE", ​​​​​"fr_WF", ​​​​​"mt_MT", ​​​​​"kab", ​​​​​"nmg_CM", ​​​​​"ru_UA", ​​​​​"fr_MR", ​​​​​"tk_Latn_TM", ​​​​​"zh_Hans_MO", ​​​​​"mn_Cyrl_MN", ​​​​​"bs_Cyrl", ​​​​​"sw_UG", ​​​​​"ko_KR", ​​​​​"en_DG", ​​​​​"bo_IN", ​​​​​"en_CC", ​​​​​"shi_Tfng_MA", ​​​​​"lag", ​​​​​"it_SM", ​​​​​"en_TT", ​​​​​"ms_Arab_MY", ​​​​​"sq_MK", ​​​​​"ms_Latn", ​​​​​"bem_ZM", ​​​​​"kde", ​​​​​"ar_OM", ​​​​​"cgg", ​​​​​"bas", ​​​​​"kam", ​​​​​"zh_Hant", ​​​​​"es_MX", ​​​​​"en_GU", ​​​​​"fr_MU", ​​​​​"fr_KM", ​​​​​"ar_LB", ​​​​​"en_BA", ​​​​​"en_TV", ​​​​​"sr_Cyrl", ​​​​​"dje", ​​​​​"kab_DZ", ​​​​​"fil_PH", ​​​​​"vai", ​​​​​"hr_HR", ​​​​​"bs_Latn_BA", ​​​​​"nl_AW", ​​​​​"dav", ​​​​​"so_SO", ​​​​​"ar_PS", ​​​​​"en_FR", ​​​​​"uz_Cyrl", ​​​​​"ff_SN", ​​​​​"en_BB", ​​​​​"ki_KE", ​​​​​"naq", ​​​​​"en_SS", ​​​​​"mg_MG", ​​​​​"mas_KE", ​​​​​"en_RO", ​​​​​"en_PG", ​​​​​"mgh", ​​​​​"dyo_SN", ​​​​​"mas", ​​​​​"agq", ​​​​​"bn_BD", ​​​​​"haw", ​​​​​"nb_NO", ​​​​​"da_DK", ​​​​​"en_DK", ​​​​​"saq", ​​​​​"ug", ​​​​​"cy_GB", ​​​​​"fr_YT", ​​​​​"jmc", ​​​​​"ses_ML", ​​​​​"en_PH", ​​​​​"de_DE", ​​​​​"ar_YE", ​​​​​"bm_ML", ​​​​​"yo", ​​​​​"lkt_US", ​​​​​"uz_Arab_AF", ​​​​​"jgo", ​​​​​"uk", ​​​​​"sl_SI", ​​​​​"en_CH", ​​​​​"asa", ​​​​​"lg_UG", ​​​​​"mgo", ​​​​​"id_ID", ​​​​​"en_NA", ​​​​​"en_GY", ​​​​​"zgh", ​​​​​"pt_MZ", ​​​​​"fr_LU", ​​​​​"kk_Cyrl", ​​​​​"mas_TZ", ​​​​​"ur", ​​​​​"en_DM", ​​​​​"ta_MY", ​​​​​"en_BE", ​​​​​"mg", ​​​​​"fr_GA", ​​​​​"ka_GE", ​​​​​"nmg", ​​​​​"en_TZ", ​​​​​"eu_ES", ​​​​​"ar_DZ", ​​​​​"id", ​​​​​"so_DJ", ​​​​​"yav", ​​​​​"mk", ​​​​​"pa_Arab_PK", ​​​​​"ml", ​​​​​"en_ER", ​​​​​"ig", ​​​​​"mn", ​​​​​"ksb", ​​​​​"uz", ​​​​​"vi_VN", ​​​​​"ii", ​​​​​"en_PK", ​​​​​"ee", ​​​​​"mr", ​​​​​"ms", ​​​​​"en_ES", ​​​​​"sq_XK", ​​​​​"it_CH", ​​​​​"mt", ​​​​​"en_CK", ​​​​​"br_FR", ​​​​​"sr_Cyrl_XK", ​​​​​"ksf", ​​​​​"en_SX", ​​​​​"bg_BG", ​​​​​"en_PL", ​​​​​"af", ​​​​​"el", ​​​​​"cs_CZ", ​​​​​"fr_TD", ​​​​​"zh_Hans_HK", ​​​​​"is", ​​​​​"my", ​​​​​"en", ​​​​​"it", ​​​​​"ii_CN", ​​​​​"eo", ​​​​​"iu", ​​​​​"en_ZA", ​​​​​"en_AD", ​​​​​"ak", ​​​​​"en_RU", ​​​​​"kkj_CM", ​​​​​"am", ​​​​​"es", ​​​​​"et", ​​​​​"uk_UA"​​​}

set isoLang to (current application’s NSLocale’s ISOLanguageCodes()) as anything
log isoLang
–>  {​​​​​"aa", ​​​​​"ab", ​​​​​"ace", ​​​​​"ach", ​​​​​"ada", ​​​​​"ady", ​​​​​"ae", ​​​​​"af", ​​​​​"afa", ​​​​​"afh", ​​​​​"agq", ​​​​​"ain", ​​​​​"ak", ​​​​​"akk", ​​​​​"ale", ​​​​​"alg", ​​​​​"alt", ​​​​​"am", ​​​​​"an", ​​​​​"ang", ​​​​​"anp", ​​​​​"apa", ​​​​​"ar", ​​​​​"arc", ​​​​​"arn", ​​​​​"arp", ​​​​​"art", ​​​​​"arw", ​​​​​"as", ​​​​​"asa", ​​​​​"ast", ​​​​​"ath", ​​​​​"aus", ​​​​​"av", ​​​​​"awa", ​​​​​"ay", ​​​​​"az", ​​​​​"ba", ​​​​​"bad", ​​​​​"bai", ​​​​​"bal", ​​​​​"ban", ​​​​​"bas", ​​​​​"bat", ​​​​​"bax", ​​​​​"bbj", ​​​​​"be", ​​​​​"bej", ​​​​​"bem", ​​​​​"ber", ​​​​​"bez", ​​​​​"bfd", ​​​​​"bg", ​​​​​"bh", ​​​​​"bho", ​​​​​"bi", ​​​​​"bik", ​​​​​"bin", ​​​​​"bkm", ​​​​​"bla", ​​​​​"bm", ​​​​​"bn", ​​​​​"bnt", ​​​​​"bo", ​​​​​"br", ​​​​​"bra", ​​​​​"brx", ​​​​​"bs", ​​​​​"bss", ​​​​​"btk", ​​​​​"bua", ​​​​​"bug", ​​​​​"bum", ​​​​​"byn", ​​​​​"byv", ​​​​​"ca", ​​​​​"cad", ​​​​​"cai", ​​​​​"car", ​​​​​"cau", ​​​​​"cay", ​​​​​"cch", ​​​​​"ce", ​​​​​"ceb", ​​​​​"cel", ​​​​​"cgg", ​​​​​"ch", ​​​​​"chb", ​​​​​"chg", ​​​​​"chk", ​​​​​"chm", ​​​​​"chn", ​​​​​"cho", ​​​​​"chp", ​​​​​"chr", ​​​​​"chy", ​​​​​"ckb", ​​​​​"cmc", ​​​​​"co", ​​​​​"cop", ​​​​​"cpe", ​​​​​"cpf", ​​​​​"cpp", ​​​​​"cr", ​​​​​"crh", ​​​​​"crp", ​​​​​"cs", ​​​​​"csb", ​​​​​"cu", ​​​​​"cus", ​​​​​"cv", ​​​​​"cy", ​​​​​"da", ​​​​​"dak", ​​​​​"dar", ​​​​​"dav", ​​​​​"day", ​​​​​"de", ​​​​​"del", ​​​​​"den", ​​​​​"dgr", ​​​​​"din", ​​​​​"dje", ​​​​​"doi", ​​​​​"dra", ​​​​​"dsb", ​​​​​"dua", ​​​​​"dum", ​​​​​"dv", ​​​​​"dyo", ​​​​​"dyu", ​​​​​"dz", ​​​​​"dzg", ​​​​​"ebu", ​​​​​"ee", ​​​​​"efi", ​​​​​"egy", ​​​​​"eka", ​​​​​"el", ​​​​​"elx", ​​​​​"en", ​​​​​"enm", ​​​​​"eo", ​​​​​"es", ​​​​​"et", ​​​​​"eu", ​​​​​"ewo", ​​​​​"fa", ​​​​​"fan", ​​​​​"fat", ​​​​​"ff", ​​​​​"fi", ​​​​​"fil", ​​​​​"fiu", ​​​​​"fj", ​​​​​"fo", ​​​​​"fon", ​​​​​"fr", ​​​​​"frm", ​​​​​"fro", ​​​​​"frr", ​​​​​"frs", ​​​​​"fur", ​​​​​"fy", ​​​​​"ga", ​​​​​"gaa", ​​​​​"gay", ​​​​​"gba", ​​​​​"gd", ​​​​​"gem", ​​​​​"gez", ​​​​​"gil", ​​​​​"gl", ​​​​​"gmh", ​​​​​"gn", ​​​​​"goh", ​​​​​"gon", ​​​​​"gor", ​​​​​"got", ​​​​​"grb", ​​​​​"grc", ​​​​​"gsw", ​​​​​"gu", ​​​​​"guz", ​​​​​"gv", ​​​​​"gwi", ​​​​​"ha", ​​​​​"hai", ​​​​​"haw", ​​​​​"he", ​​​​​"hi", ​​​​​"hil", ​​​​​"him", ​​​​​"hit", ​​​​​"hmn", ​​​​​"ho", ​​​​​"hr", ​​​​​"hsb", ​​​​​"ht", ​​​​​"hu", ​​​​​"hup", ​​​​​"hy", ​​​​​"hz", ​​​​​"ia", ​​​​​"iba", ​​​​​"ibb", ​​​​​"id", ​​​​​"ie", ​​​​​"ig", ​​​​​"ii", ​​​​​"ijo", ​​​​​"ik", ​​​​​"ilo", ​​​​​"inc", ​​​​​"ine", ​​​​​"inh", ​​​​​"io", ​​​​​"ira", ​​​​​"iro", ​​​​​"is", ​​​​​"it", ​​​​​"iu", ​​​​​"ja", ​​​​​"jbo", ​​​​​"jgo", ​​​​​"jmc", ​​​​​"jpr", ​​​​​"jrb", ​​​​​"jv", ​​​​​"ka", ​​​​​"kaa", ​​​​​"kab", ​​​​​"kac", ​​​​​"kaj", ​​​​​"kam", ​​​​​"kar", ​​​​​"kaw", ​​​​​"kbd", ​​​​​"kbl", ​​​​​"kcg", ​​​​​"kde", ​​​​​"kea", ​​​​​"kfo", ​​​​​"kg", ​​​​​"kha", ​​​​​"khi", ​​​​​"kho", ​​​​​"khq", ​​​​​"ki", ​​​​​"kj", ​​​​​"kk", ​​​​​"kkj", ​​​​​"kl", ​​​​​"kln", ​​​​​"km", ​​​​​"kmb", ​​​​​"kn", ​​​​​"ko", ​​​​​"kok", ​​​​​"kos", ​​​​​"kpe", ​​​​​"kr", ​​​​​"krc", ​​​​​"krl", ​​​​​"kro", ​​​​​"kru", ​​​​​"ks", ​​​​​"ksb", ​​​​​"ksf", ​​​​​"ksh", ​​​​​"ku", ​​​​​"kum", ​​​​​"kut", ​​​​​"kv", ​​​​​"kw", ​​​​​"ky", ​​​​​"la", ​​​​​"lad", ​​​​​"lag", ​​​​​"lah", ​​​​​"lam", ​​​​​"lb", ​​​​​"lez", ​​​​​"lg", ​​​​​"li", ​​​​​"lkt", ​​​​​"ln", ​​​​​"lo", ​​​​​"lol", ​​​​​"loz", ​​​​​"lt", ​​​​​"lu", ​​​​​"lua", ​​​​​"lui", ​​​​​"lun", ​​​​​"luo", ​​​​​"lus", ​​​​​"luy", ​​​​​"lv", ​​​​​"mad", ​​​​​"maf", ​​​​​"mag", ​​​​​"mai", ​​​​​"mak", ​​​​​"man", ​​​​​"map", ​​​​​"mas", ​​​​​"mde", ​​​​​"mdf", ​​​​​"mdr", ​​​​​"men", ​​​​​"mer", ​​​​​"mfe", ​​​​​"mg", ​​​​​"mga", ​​​​​"mgh", ​​​​​"mgo", ​​​​​"mh", ​​​​​"mi", ​​​​​"mic", ​​​​​"min", ​​​​​"mis", ​​​​​"mk", ​​​​​"mkh", ​​​​​"ml", ​​​​​"mn", ​​​​​"mnc", ​​​​​"mni", ​​​​​"mno", ​​​​​"mo", ​​​​​"moh", ​​​​​"mos", ​​​​​"mr", ​​​​​"ms", ​​​​​"mt", ​​​​​"mua", ​​​​​"mul", ​​​​​"mun", ​​​​​"mus", ​​​​​"mwl", ​​​​​"mwr", ​​​​​"my", ​​​​​"mye", ​​​​​"myn", ​​​​​"myv", ​​​​​"na", ​​​​​"nah", ​​​​​"nai", ​​​​​"nap", ​​​​​"naq", ​​​​​"nb", ​​​​​"nd", ​​​​​"nds", ​​​​​"ne", ​​​​​"new", ​​​​​"ng", ​​​​​"nia", ​​​​​"nic", ​​​​​"niu", ​​​​​"nl", ​​​​​"nmg", ​​​​​"nn", ​​​​​"nnh", ​​​​​"no", ​​​​​"nog", ​​​​​"non", ​​​​​"nqo", ​​​​​"nr", ​​​​​"nso", ​​​​​"nub", ​​​​​"nus", ​​​​​"nv", ​​​​​"nwc", ​​​​​"ny", ​​​​​"nym", ​​​​​"nyn", ​​​​​"nyo", ​​​​​"nzi", ​​​​​"oc", ​​​​​"oj", ​​​​​"om", ​​​​​"or", ​​​​​"os", ​​​​​"osa", ​​​​​"ota", ​​​​​"oto", ​​​​​"pa", ​​​​​"paa", ​​​​​"pag", ​​​​​"pal", ​​​​​"pam", ​​​​​"pap", ​​​​​"pau", ​​​​​"peo", ​​​​​"phi", ​​​​​"phn", ​​​​​"pi", ​​​​​"pl", ​​​​​"pon", ​​​​​"pra", ​​​​​"pro", ​​​​​"ps", ​​​​​"pt", ​​​​​"qu", ​​​​​"raj", ​​​​​"rap", ​​​​​"rar", ​​​​​"rm", ​​​​​"rn", ​​​​​"ro", ​​​​​"roa", ​​​​​"rof", ​​​​​"rom", ​​​​​"ru", ​​​​​"rup", ​​​​​"rw", ​​​​​"rwk", ​​​​​"sa", ​​​​​"sad", ​​​​​"sah", ​​​​​"sai", ​​​​​"sal", ​​​​​"sam", ​​​​​"saq", ​​​​​"sas", ​​​​​"sat", ​​​​​"sba", ​​​​​"sbp", ​​​​​"sc", ​​​​​"scn", ​​​​​"sco", ​​​​​"sd", ​​​​​"se", ​​​​​"see", ​​​​​"seh", ​​​​​"sel", ​​​​​"sem", ​​​​​"ses", ​​​​​"sg", ​​​​​"sga", ​​​​​"sgn", ​​​​​"shi", ​​​​​"shn", ​​​​​"shu", ​​​​​"si", ​​​​​"sid", ​​​​​"sio", ​​​​​"sit", ​​​​​"sk", ​​​​​"sl", ​​​​​"sla", ​​​​​"sm", ​​​​​"sma", ​​​​​"smi", ​​​​​"smj", ​​​​​"smn", ​​​​​"sms", ​​​​​"sn", ​​​​​"snk", ​​​​​"so", ​​​​​"sog", ​​​​​"son", ​​​​​"sq", ​​​​​"sr", ​​​​​"srn", ​​​​​"srr", ​​​​​"ss", ​​​​​"ssa", ​​​​​"ssy", ​​​​​"st", ​​​​​"su", ​​​​​"suk", ​​​​​"sus", ​​​​​"sux", ​​​​​"sv", ​​​​​"sw", ​​​​​"swb", ​​​​​"swc", ​​​​​"syc", ​​​​​"syr", ​​​​​"ta", ​​​​​"tai", ​​​​​"te", ​​​​​"tem", ​​​​​"teo", ​​​​​"ter", ​​​​​"tet", ​​​​​"tg", ​​​​​"th", ​​​​​"ti", ​​​​​"tig", ​​​​​"tiv", ​​​​​"tk", ​​​​​"tkl", ​​​​​"tl", ​​​​​"tlh", ​​​​​"tli", ​​​​​"tmh", ​​​​​"tn", ​​​​​"to", ​​​​​"tog", ​​​​​"tpi", ​​​​​"tr", ​​​​​"trv", ​​​​​"ts", ​​​​​"tsi", ​​​​​"tt", ​​​​​"tum", ​​​​​"tup", ​​​​​"tut", ​​​​​"tvl", ​​​​​"tw", ​​​​​"twq", ​​​​​"ty", ​​​​​"tyv", ​​​​​"tzm", ​​​​​"udm", ​​​​​"ug", ​​​​​"uga", ​​​​​"uk", ​​​​​"umb", ​​​​​"und", ​​​​​"ur", ​​​​​"uz", ​​​​​"vai", ​​​​​"ve", ​​​​​"vi", ​​​​​"vo", ​​​​​"vot", ​​​​​"vun", ​​​​​"wa", ​​​​​"wae", ​​​​​"wak", ​​​​​"wal", ​​​​​"war", ​​​​​"was", ​​​​​"wen", ​​​​​"wo", ​​​​​"xal", ​​​​​"xh", ​​​​​"xog", ​​​​​"yao", ​​​​​"yap", ​​​​​"yav", ​​​​​"ybb", ​​​​​"yi", ​​​​​"yo", ​​​​​"ypk", ​​​​​"yue", ​​​​​"za", ​​​​​"zap", ​​​​​"zbl", ​​​​​"zen", ​​​​​"zgh", ​​​​​"zh", ​​​​​"znd", ​​​​​"zu", ​​​​​"zun", ​​​​​"zxx", ​​​​​"zza"​​​}

set commonCurrency to (current application’s NSLocale’s commonISOCurrencyCodes()) as anything
log commonCurrency
–>  (NSArray) {​​​​​"AED", ​​​​​"AFN", ​​​​​"ALL", ​​​​​"AMD", ​​​​​"ANG", ​​​​​"AOA", ​​​​​"ARS", ​​​​​"AUD", ​​​​​"AWG", ​​​​​"AZN", ​​​​​"BAM", ​​​​​"BBD", ​​​​​"BDT", ​​​​​"BGN", ​​​​​"BHD", ​​​​​"BIF", ​​​​​"BMD", ​​​​​"BND", ​​​​​"BOB", ​​​​​"BRL", ​​​​​"BSD", ​​​​​"BTN", ​​​​​"BWP", ​​​​​"BYR", ​​​​​"BZD", ​​​​​"CAD", ​​​​​"CDF", ​​​​​"CHF", ​​​​​"CLP", ​​​​​"CNY", ​​​​​"COP", ​​​​​"CRC", ​​​​​"CUC", ​​​​​"CUP", ​​​​​"CVE", ​​​​​"CZK", ​​​​​"DJF", ​​​​​"DKK", ​​​​​"DOP", ​​​​​"DZD", ​​​​​"EGP", ​​​​​"ERN", ​​​​​"ETB", ​​​​​"EUR", ​​​​​"FJD", ​​​​​"FKP", ​​​​​"GBP", ​​​​​"GEL", ​​​​​"GHS", ​​​​​"GIP", ​​​​​"GMD", ​​​​​"GNF", ​​​​​"GTQ", ​​​​​"GWP", ​​​​​"GYD", ​​​​​"HKD", ​​​​​"HNL", ​​​​​"HRK", ​​​​​"HTG", ​​​​​"HUF", ​​​​​"IDR", ​​​​​"ILS", ​​​​​"INR", ​​​​​"IQD", ​​​​​"IRR", ​​​​​"ISK", ​​​​​"JMD", ​​​​​"JOD", ​​​​​"JPY", ​​​​​"KES", ​​​​​"KGS", ​​​​​"KHR", ​​​​​"KMF", ​​​​​"KPW", ​​​​​"KRW", ​​​​​"KWD", ​​​​​"KYD", ​​​​​"KZT", ​​​​​"LAK", ​​​​​"LBP", ​​​​​"LKR", ​​​​​"LRD", ​​​​​"LSL", ​​​​​"LTL", ​​​​​"LVL", ​​​​​"LYD", ​​​​​"MAD", ​​​​​"MDL", ​​​​​"MGA", ​​​​​"MKD", ​​​​​"MMK", ​​​​​"MNT", ​​​​​"MOP", ​​​​​"MRO", ​​​​​"MUR", ​​​​​"MVR", ​​​​​"MWK", ​​​​​"MXN", ​​​​​"MYR", ​​​​​"MZE", ​​​​​"MZN", ​​​​​"NAD", ​​​​​"NGN", ​​​​​"NIO", ​​​​​"NOK", ​​​​​"NPR", ​​​​​"NZD", ​​​​​"OMR", ​​​​​"PAB", ​​​​​"PEN", ​​​​​"PGK", ​​​​​"PHP", ​​​​​"PKR", ​​​​​"PLN", ​​​​​"PYG", ​​​​​"QAR", ​​​​​"RON", ​​​​​"RSD", ​​​​​"RUB", ​​​​​"RWF", ​​​​​"SAR", ​​​​​"SBD", ​​​​​"SCR", ​​​​​"SDG", ​​​​​"SEK", ​​​​​"SGD", ​​​​​"SHP", ​​​​​"SKK", ​​​​​"SLL", ​​​​​"SOS", ​​​​​"SRD", ​​​​​"SSP", ​​​​​"STD", ​​​​​"SVC", ​​​​​"SYP", ​​​​​"SZL", ​​​​​"THB", ​​​​​"TJS", ​​​​​"TMT", ​​​​​"TND", ​​​​​"TOP", ​​​​​"TRY", ​​​​​"TTD", ​​​​​"TWD", ​​​​​"TZS", ​​​​​"UAH", ​​​​​"UGX", ​​​​​"USD", ​​​​​"UYU", ​​​​​"UZS", ​​​​​"VEF", ​​​​​"VND", ​​​​​"VUV", ​​​​​"WST", ​​​​​"XAF", ​​​​​"XCD", ​​​​​"XOF", ​​​​​"XPF", ​​​​​"YER", ​​​​​"ZAR", ​​​​​"ZMW"​​​}

set aLoc to (current application’s NSLocale’s localeIdentifierFromWindowsLocaleCode:1041) as anything
log aLoc
–>  "ja_JP"
— https://msdn.microsoft.com/ja-jp/library/Cc392381.aspx

set aLocID to (current application’s NSLocale’s windowsLocaleCodeFromLocaleIdentifier:"ja_JP") as anything
log aLocID
–>  1041

set prefLang to (current application’s NSLocale’s preferredLanguages()) as anything
log prefLang
–>   {​​​​​"ja", ​​​​​"en-US", ​​​​​"en-GB", ​​​​​"fr", ​​​​​"en"​​​}

set aLangDIrect1 to (current application’s NSLocale’s characterDirectionForLanguage:"ja") as anything –日本語
log aLangDIrect1
–>  1 –NSLocaleLanguageDirectionLeftToRight
set aLangDIrect2 to (current application’s NSLocale’s characterDirectionForLanguage:"ar") as anything –アラビア語
log aLangDIrect2
–>  2 –NSLocaleLanguageDirectionRightToLeft

set aLangLineDIrect1 to (current application’s NSLocale’s lineDirectionForLanguage:"ja") as anything –日本語
log aLangLineDIrect1
–>  3 –NSLocaleLanguageDirectionTopToBottom
set aLangLineDIrect2 to (current application’s NSLocale’s lineDirectionForLanguage:"ar") as anything –アラビア語
log aLangLineDIrect2
–>  3 –NSLocaleLanguageDirectionTopToBottom

★Click Here to Open This Script 

Posted in Calendar System Text | Tagged 10.11savvy 10.12savvy 10.13savvy | Leave a comment

すべてのLocaleから各種情報を取得

Posted on 2月 22, 2018 by Takaaki Naganoya
AppleScript名:すべてのLocaleから各種情報を取得
— Created 2015-10-03 by Takaaki Naganoya
— 2015 Piyomaru Software
use AppleScript version "2.4"
use scripting additions
use framework "Foundation"

set allLocaleIdentifiers to (current application’s NSLocale’s availableLocaleIdentifiers()) as list

set cList to {}
repeat with i in allLocaleIdentifiers
  set j to contents of i
  
  
set tmpLoc to (current application’s NSLocale’s alloc()’s initWithLocaleIdentifier:j)
  
set aLangCode to (tmpLoc’s objectForKey:(current application’s NSLocaleLanguageCode)) as text
  
set aCountryCode to (tmpLoc’s objectForKey:(current application’s NSLocaleCountryCode)) as text
  
set aCCYSymbol to (tmpLoc’s objectForKey:(current application’s NSLocaleCurrencySymbol)) as text
  
set aLocID to (tmpLoc’s objectForKey:(current application’s NSLocaleIdentifier)) as text
  
–set aCountryName to (tmpLoc’s displayNameForKey:(current application’s NSLocaleCountryCode))
  
set locIDDisplayName to (tmpLoc’s displayNameForKey:(current application’s NSLocaleIdentifier) value:aLocID) as text
  
  
set the end of cList to {aLocID, aLangCode, aCountryCode, aCCYSymbol, locIDDisplayName}
end repeat

cList

–>  {​​​​​{​​​​​​​"eu", ​​​​​​​"eu", ​​​​​​​"missing value", ​​​​​​​"¤", ​​​​​​​"euskara"​​​​​},…. ​​​​​ ​​​​​{​​​​​​​"ja_JP", ​​​​​​​"ja", ​​​​​​​"JP", ​​​​​​​"¥", ​​​​​​​"日本語 (日本)"​​​​​}, ​​​​​….. ​​​​​{​​​​​​​"ja", ​​​​​​​"ja", ​​​​​​​"missing value", ​​​​​​​"¤", ​​​​​​​"日本語"​​​​​}, ​​​​​……….​​​, ​​​​​{​​​​​​​"en_US", ​​​​​​​"en", ​​​​​​​"US", ​​​​​​​"$", ​​​​​​​"English (United States)"​​​​​}, ​​​​​{​​​​​​​"en_US_POSIX", ​​​​​​​"en", ​​​​​​​"US", ​​​​​​​"$", ​​​​​​​"English (United States, Computer)"​​​​​}, ​​​​​ ​​​​​ ​​​​​{​​​​​​​"zh-Hans", ​​​​​​​"zh", ​​​​​​​"missing value", ​​​​​​​"¤", ​​​​​​​"中文(简体)"​​​​​},….. ​​​​​{​​​​​​​"zh-Hant", ​​​​​​​"zh", ​​​​​​​"missing value", ​​​​​​​"¤", ​​​​​​​"中文(繁體)"​​​​​}, ​​​​​….{​​​​​​​"zh-Hans_HK", ​​​​​​​"zh", ​​​​​​​"HK", ​​​​​​​"HK$", ​​​​​​​"中文(简体、中国香港特别行政区)"​​​​​},​​​}

★Click Here to Open This Script 

Posted in Calendar System Text | Tagged 10.11savvy 10.12savvy 10.13savvy | Leave a comment

Current Localeから各種情報を取得する

Posted on 2月 22, 2018 by Takaaki Naganoya
AppleScript名:Current Localeから各種情報を取得する
— Created 2016-10-12 by Takaaki Naganoya
— 2016 Piyomaru Software
use AppleScript version "2.4"
use scripting additions
use framework "Foundation"

set curLocale to current application’s NSLocale’s currentLocale()

set aDS1 to curLocale’s objectForKey:(current application’s NSLocaleDecimalSeparator)
–>  (NSString) "."

set aDS2 to curLocale’s objectForKey:(current application’s NSLocaleGroupingSeparator)
–>  (NSString) ","

set aDS3 to curLocale’s objectForKey:(current application’s NSLocaleCurrencySymbol)
–>  (NSString) "¥"

set aDS4 to curLocale’s objectForKey:(current application’s NSLocaleCurrencyCode)
–>  (NSString) "JPY"

set aDS5 to curLocale’s objectForKey:(current application’s NSLocaleCollatorIdentifier)
–>  (NSString) "ja-JP"

set aDS6 to curLocale’s objectForKey:(current application’s NSLocaleQuotationBeginDelimiterKey)
–>  (NSString) "「"

set aDS7 to curLocale’s objectForKey:(current application’s NSLocaleQuotationEndDelimiterKey)
–>  (NSString) "」"

set aDS8 to curLocale’s objectForKey:(current application’s NSLocaleAlternateQuotationBeginDelimiterKey)
–>  (NSString) "『"

set aDS9 to curLocale’s objectForKey:(current application’s NSLocaleAlternateQuotationEndDelimiterKey)
–>  (NSString) "』"

set aDS10 to curLocale’s objectForKey:(current application’s NSLocaleIdentifier)
–>  (NSString) "ja_JP"

set aDS11 to curLocale’s objectForKey:(current application’s NSLocaleLanguageCode)
–>  (NSString) "ja"

set aDS12 to curLocale’s objectForKey:(current application’s NSLocaleCountryCode)
–>  (NSString) "JP"

set aDS13 to curLocale’s objectForKey:(current application’s NSLocaleScriptCode)
–>  missing value

set aDS14 to curLocale’s objectForKey:(current application’s NSLocaleVariantCode)
–>  missing value

set aDS15 to curLocale’s objectForKey:(current application’s NSLocaleExemplarCharacterSet)
–>  (__NSCFCharacterSet) <__NSCFCharacterSet: 0x60800124d890>

set aDS16 to curLocale’s objectForKey:(current application’s NSLocaleCalendar)
–>  (_NSCopyOnWriteCalendarWrapper) <_NSCopyOnWriteCalendarWrapper: 0x610000232ca0>

set aDS17 to curLocale’s objectForKey:(current application’s NSLocaleCollationIdentifier)
–>  missing value

set aDS18 to curLocale’s objectForKey:(current application’s NSLocaleUsesMetricSystem)
–>  (NSNumber) 1

set aDS19 to curLocale’s objectForKey:(current application’s NSLocaleMeasurementSystem)
–>  (NSString) "Metric"

★Click Here to Open This Script 

Posted in Calendar System Text | Tagged 10.11savvy 10.12savvy 10.13savvy | Leave a comment

Locale情報を取得する

Posted on 2月 22, 2018 by Takaaki Naganoya
AppleScript名:Locale情報を取得する
— Created 2015-09-11 by Takaaki Naganoya
— 2015 Piyomaru Software
use AppleScript version "2.4"
use scripting additions
use framework "Foundation"

set aLocale to (current application’s NSLocale’s currentLocale’s objectForKey:(current application’s NSLocaleIdentifier)) as list of string or string –as anything
–>  "ja_JP"

set aLangList to (current application’s NSLocale’s preferredLanguages()) as list of string or string –as anything
–>   {​​​​​"ja", ​​​​​"en-US", ​​​​​"en-GB", ​​​​​"fr", ​​​​​"en"​​​}

set aLocList to (current application’s NSLocale’s availableLocaleIdentifiers()) as list of string or string –as anything
–>   {​​​​​"eu", ​​​​​"hr_BA", ​​​​​"en_CM", ​​​​​"rw_RW", ​​​​​"en_SZ", ​​​​​"tk_Latn", ​​​​​"uz_Arab", ​​​​​"he_IL", ​​​​​"ar", ​​​​​"en_PN", ​​​​​"as", ​​​​​"en_NF", ​​​​​"rwk_TZ", ​​​​​"zh_Hant_TW", ​​​​​"gsw_LI", ​​​​​"th_TH", ​​​​​"ta_IN", ​​​​​"es_EA", ​​​​​"fr_GF", ​​​​​"ar_001", ​​​​​"en_RW", ​​​​​"tr_TR", ​​​​​"de_CH", ​​​​​"ee_TG", ​​​​​"en_NG", ​​​​​"fr_TG", ​​​​​"az", ​​​​​"fr_SC", ​​​​​"es_HN", ​​​​​"en_AG", ​​​​​"ru_KZ", ​​​​​"gsw", ​​​​​"dyo", ​​​​​"so_ET", ​​​​​"zh_Hant_MO", ​​​​​"de_BE", ​​​​​"km_KH", ​​​​​"my_MM", ​​​​​"mgh_MZ", ​​​​​"ee_GH", ​​​​​"es_EC", ​​​​​"kw_GB", ​​​​​"rm_CH", ​​​​​"en_ME", ​​​​​"nyn", ​​​​​"mk_MK", ​​​​​"bs_Cyrl_BA", ​​​​​"ar_MR", ​​​​​"en_BM", ​​​​​"ms_Arab", ​​​​​"en_AI", ​​​​​"gl_ES", ​​​​​"en_PR", ​​​​​"ha_Latn_GH", ​​​​​"ne_IN", ​​​​​"or_IN", ​​​​​"khq_ML", ​​​​​"en_MG", ​​​​​"pt_TL", ​​​​​"en_LC", ​​​​​"ta_SG", ​​​​​"jmc_TZ", ​​​​​"om_ET", ​​​​​"lv_LV", ​​​​​"es_US", ​​​​​"en_PT", ​​​​​"vai_Latn_LR", ​​​​​"to_TO", ​​​​​"en_NL", ​​​​​"cgg_UG", ​​​​​"ta", ​​​​​"en_MH", ​​​​​"iu_Cans_CA", ​​​​​"zu_ZA", ​​​​​"shi_Latn_MA", ​​​​​"brx_IN", ​​​​​"ar_KM", ​​​​​"en_AL", ​​​​​"te", ​​​​​"chr_US", ​​​​​"yo_BJ", ​​​​​"fr_VU", ​​​​​"pa", ​​​​​"tg", ​​​​​"ks_Arab", ​​​​​"kea", ​​​​​"te_IN", ​​​​​"th", ​​​​​"fr_RE", ​​​​​"ur_IN", ​​​​​"yo_NG", ​​​​​"ti", ​​​​​"guz_KE", ​​​​​"tk", ​​​​​"kl_GL", ​​​​​"ksf_CM", ​​​​​"mua_CM", ​​​​​"lag_TZ", ​​​​​"fr_TN", ​​​​​"es_PA", ​​​​​"pl_PL", ​​​​​"to", ​​​​​"hi_IN", ​​​​​"dje_NE", ​​​​​"es_GQ", ​​​​​"kok_IN", ​​​​​"pl", ​​​​​"tr", ​​​​​"bem", ​​​​​"ha", ​​​​​"ckb", ​​​​​"lg", ​​​​​"fr_GN", ​​​​​"en_PW", ​​​​​"en_NO", ​​​​​"nyn_UG", ​​​​​"sr_Latn_RS", ​​​​​"pa_Guru", ​​​​​"he", ​​​​​"swc_CD", ​​​​​"ug_Arab", ​​​​​"lu_CD", ​​​​​"mgo_CM", ​​​​​"sn_ZW", ​​​​​"en_BS", ​​​​​"ps_AF", ​​​​​"da", ​​​​​"ms_Latn_SG", ​​​​​"ps", ​​​​​"ln", ​​​​​"pt", ​​​​​"iu_Cans", ​​​​​"hi", ​​​​​"lo", ​​​​​"ebu", ​​​​​"de", ​​​​​"gu_IN", ​​​​​"seh", ​​​​​"en_CX", ​​​​​"en_ZM", ​​​​​"tzm_Latn_MA", ​​​​​"fr_HT", ​​​​​"fr_GP", ​​​​​"lt", ​​​​​"lu", ​​​​​"ln_CD", ​​​​​"vai_Latn", ​​​​​"el_GR", ​​​​​"lv", ​​​​​"en_KE", ​​​​​"sbp", ​​​​​"hr", ​​​​​"en_CY", ​​​​​"es_GT", ​​​​​"twq_NE", ​​​​​"zh_Hant_HK", ​​​​​"kln_KE", ​​​​​"fr_GQ", ​​​​​"chr", ​​​​​"hu", ​​​​​"es_UY", ​​​​​"fr_CA", ​​​​​"en_NR", ​​​​​"mer", ​​​​​"shi", ​​​​​"es_PE", ​​​​​"fr_SN", ​​​​​"bez", ​​​​​"sw_TZ", ​​​​​"kkj", ​​​​​"hy", ​​​​​"kk_Cyrl_KZ", ​​​​​"en_CZ", ​​​​​"teo_KE", ​​​​​"teo", ​​​​​"dz_BT", ​​​​​"ar_JO", ​​​​​"mer_KE", ​​​​​"khq", ​​​​​"ln_CF", ​​​​​"nn_NO", ​​​​​"en_MO", ​​​​​"ar_TD", ​​​​​"dz", ​​​​​"ses", ​​​​​"en_BW", ​​​​​"en_AS", ​​​​​"ar_IL", ​​​​​"ms_Latn_BN", ​​​​​"bo_CN", ​​​​​"nnh", ​​​​​"teo_UG", ​​​​​"hy_AM", ​​​​​"ln_CG", ​​​​​"sr_Latn_BA", ​​​​​"en_MP", ​​​​​"ksb_TZ", ​​​​​"ar_SA", ​​​​​"ar_LY", ​​​​​"en_AT", ​​​​​"so_KE", ​​​​​"fr_CD", ​​​​​"af_NA", ​​​​​"en_NU", ​​​​​"es_PH", ​​​​​"en_KI", ​​​​​"en_JE", ​​​​​"lkt", ​​​​​"en_AU", ​​​​​"fa_IR", ​​​​​"uz_Latn_UZ", ​​​​​"ky_Cyrl", ​​​​​"zh_Hans_CN", ​​​​​"ewo_CM", ​​​​​"fr_PF", ​​​​​"ca_IT", ​​​​​"en_BZ", ​​​​​"ar_KW", ​​​​​"pt_GW", ​​​​​"fr_FR", ​​​​​"am_ET", ​​​​​"en_VC", ​​​​​"fr_DJ", ​​​​​"fr_CF", ​​​​​"es_SV", ​​​​​"en_MS", ​​​​​"pt_ST", ​​​​​"ar_SD", ​​​​​"luy_KE", ​​​​​"swc", ​​​​​"de_LI", ​​​​​"fr_CG", ​​​​​"zh_Hans_SG", ​​​​​"en_MT", ​​​​​"ewo", ​​​​​"af_ZA", ​​​​​"om_KE", ​​​​​"nl_SR", ​​​​​"es_ES", ​​​​​"es_DO", ​​​​​"ar_IQ", ​​​​​"fr_CH", ​​​​​"nnh_CM", ​​​​​"es_419", ​​​​​"en_MU", ​​​​​"en_US_POSIX", ​​​​​"yav_CM", ​​​​​"luo_KE", ​​​​​"dua_CM", ​​​​​"et_EE", ​​​​​"en_IE", ​​​​​"ak_GH", ​​​​​"rwk", ​​​​​"es_CL", ​​​​​"kea_CV", ​​​​​"fr_CI", ​​​​​"fr_BE", ​​​​​"en_NZ", ​​​​​"ky_Cyrl_KG", ​​​​​"en_LR", ​​​​​"en_KN", ​​​​​"nb_SJ", ​​​​​"sg", ​​​​​"sr_Cyrl_RS", ​​​​​"ru_RU", ​​​​​"en_ZW", ​​​​​"sv_AX", ​​​​​"si", ​​​​​"ga_IE", ​​​​​"en_VG", ​​​​​"sk", ​​​​​"agq_CM", ​​​​​"fr_BF", ​​​​​"naq_NA", ​​​​​"sl", ​​​​​"en_MW", ​​​​​"mr_IN", ​​​​​"az_Latn", ​​​​​"en_LS", ​​​​​"de_AT", ​​​​​"ka", ​​​​​"sn", ​​​​​"sr_Latn_ME", ​​​​​"fr_NC", ​​​​​"so", ​​​​​"is_IS", ​​​​​"twq", ​​​​​"ig_NG", ​​​​​"sq", ​​​​​"fo_FO", ​​​​​"sr", ​​​​​"tzm", ​​​​​"ga", ​​​​​"om", ​​​​​"en_LT", ​​​​​"bas_CM", ​​​​​"ki", ​​​​​"nl_BE", ​​​​​"ar_QA", ​​​​​"sv", ​​​​​"kk", ​​​​​"sw", ​​​​​"es_CO", ​​​​​"az_Latn_AZ", ​​​​​"rn_BI", ​​​​​"or", ​​​​​"kl", ​​​​​"ca", ​​​​​"en_VI", ​​​​​"km", ​​​​​"kn", ​​​​​"en_LU", ​​​​​"fr_SY", ​​​​​"ar_TN", ​​​​​"en_JM", ​​​​​"fr_PM", ​​​​​"ko", ​​​​​"fr_NE", ​​​​​"fr_MA", ​​​​​"gl", ​​​​​"ru_MD", ​​​​​"saq_KE", ​​​​​"ks", ​​​​​"fr_CM", ​​​​​"gv_IM", ​​​​​"fr_BI", ​​​​​"en_LV", ​​​​​"ks_Arab_IN", ​​​​​"es_NI", ​​​​​"en_GB", ​​​​​"kw", ​​​​​"nl_SX", ​​​​​"dav_KE", ​​​​​"tr_CY", ​​​​​"ky", ​​​​​"en_UG", ​​​​​"tzm_Latn", ​​​​​"en_TC", ​​​​​"nus_SD", ​​​​​"ar_EG", ​​​​​"fr_BJ", ​​​​​"gu", ​​​​​"es_PR", ​​​​​"fr_RW", ​​​​​"sr_Cyrl_BA", ​​​​​"gv", ​​​​​"fr_MC", ​​​​​"cs", ​​​​​"bez_TZ", ​​​​​"es_CR", ​​​​​"asa_TZ", ​​​​​"ar_EH", ​​​​​"ms_Arab_BN", ​​​​​"mn_Cyrl", ​​​​​"sbp_TZ", ​​​​​"ha_Latn_NE", ​​​​​"lt_LT", ​​​​​"mfe", ​​​​​"en_GD", ​​​​​"cy", ​​​​​"ca_FR", ​​​​​"es_BO", ​​​​​"fr_BL", ​​​​​"bn_IN", ​​​​​"uz_Cyrl_UZ", ​​​​​"az_Cyrl", ​​​​​"en_IM", ​​​​​"sw_KE", ​​​​​"en_SB", ​​​​​"ur_PK", ​​​​​"pa_Arab", ​​​​​"haw_US", ​​​​​"ar_SO", ​​​​​"en_IN", ​​​​​"ha_Latn", ​​​​​"fil", ​​​​​"fr_MF", ​​​​​"en_WS", ​​​​​"es_CU", ​​​​​"ja_JP", ​​​​​"en_SC", ​​​​​"en_IO", ​​​​​"pt_PT", ​​​​​"en_HK", ​​​​​"en_GG", ​​​​​"fr_MG", ​​​​​"de_LU", ​​​​​"ms_Latn_MY", ​​​​​"tg_Cyrl", ​​​​​"en_SD", ​​​​​"shi_Tfng", ​​​​​"ln_AO", ​​​​​"ug_Arab_CN", ​​​​​"as_IN", ​​​​​"en_GH", ​​​​​"ro_RO", ​​​​​"jgo_CM", ​​​​​"dua", ​​​​​"en_UM", ​​​​​"en_SE", ​​​​​"kn_IN", ​​​​​"en_KY", ​​​​​"vun_TZ", ​​​​​"kln", ​​​​​"en_GI", ​​​​​"ca_ES", ​​​​​"rof", ​​​​​"pt_CV", ​​​​​"kok", ​​​​​"pt_BR", ​​​​​"ar_DJ", ​​​​​"zh", ​​​​​"fi_FI", ​​​​​"tg_Cyrl_TJ", ​​​​​"es_PY", ​​​​​"ar_SS", ​​​​​"mua", ​​​​​"sr_Cyrl_ME", ​​​​​"vai_Vaii_LR", ​​​​​"en_001", ​​​​​"xog_UG", ​​​​​"en_TK", ​​​​​"si_LK", ​​​​​"en_SG", ​​​​​"nl_NL", ​​​​​"vi", ​​​​​"sv_SE", ​​​​​"pt_AO", ​​​​​"fr_DZ", ​​​​​"ca_AD", ​​​​​"xog", ​​​​​"en_IS", ​​​​​"nb", ​​​​​"seh_MZ", ​​​​​"es_AR", ​​​​​"sk_SK", ​​​​​"en_SH", ​​​​​"ti_ER", ​​​​​"nd", ​​​​​"az_Cyrl_AZ", ​​​​​"zu", ​​​​​"ne", ​​​​​"nd_ZW", ​​​​​"el_CY", ​​​​​"en_IT", ​​​​​"nl_BQ", ​​​​​"da_GL", ​​​​​"ja", ​​​​​"rm", ​​​​​"fr_ML", ​​​​​"rn", ​​​​​"en_VU", ​​​​​"rof_TZ", ​​​​​"ro", ​​​​​"ebu_KE", ​​​​​"ru_KG", ​​​​​"en_SI", ​​​​​"sg_CF", ​​​​​"mfe_MU", ​​​​​"nl", ​​​​​"brx", ​​​​​"bs_Latn", ​​​​​"fa", ​​​​​"zgh_MA", ​​​​​"en_GM", ​​​​​"shi_Latn", ​​​​​"en_FI", ​​​​​"nn", ​​​​​"en_EE", ​​​​​"ru", ​​​​​"kam_KE", ​​​​​"vai_Vaii", ​​​​​"ar_ER", ​​​​​"ti_ET", ​​​​​"rw", ​​​​​"ff", ​​​​​"luo", ​​​​​"fa_AF", ​​​​​"ha_Latn_NG", ​​​​​"nl_CW", ​​​​​"en_HR", ​​​​​"en_FJ", ​​​​​"fi", ​​​​​"pt_MO", ​​​​​"be", ​​​​​"en_US", ​​​​​"en_TO", ​​​​​"en_SK", ​​​​​"bg", ​​​​​"ru_BY", ​​​​​"it_IT", ​​​​​"ml_IN", ​​​​​"gsw_CH", ​​​​​"fo", ​​​​​"sv_FI", ​​​​​"en_FK", ​​​​​"nus", ​​​​​"ta_LK", ​​​​​"vun", ​​​​​"sr_Latn", ​​​​​"fr", ​​​​​"en_SL", ​​​​​"bm", ​​​​​"ar_BH", ​​​​​"guz", ​​​​​"bn", ​​​​​"bo", ​​​​​"ar_SY", ​​​​​"lo_LA", ​​​​​"ne_NP", ​​​​​"uz_Latn", ​​​​​"be_BY", ​​​​​"es_IC", ​​​​​"sr_Latn_XK", ​​​​​"ar_MA", ​​​​​"pa_Guru_IN", ​​​​​"br", ​​​​​"luy", ​​​​​"kde_TZ", ​​​​​"bs", ​​​​​"hu_HU", ​​​​​"ar_AE", ​​​​​"en_HU", ​​​​​"zh_Hans", ​​​​​"en_FM", ​​​​​"sq_AL", ​​​​​"ko_KP", ​​​​​"en_150", ​​​​​"en_DE", ​​​​​"fr_MQ", ​​​​​"en_CA", ​​​​​"en_TR", ​​​​​"ro_MD", ​​​​​"es_VE", ​​​​​"fr_WF", ​​​​​"mt_MT", ​​​​​"kab", ​​​​​"nmg_CM", ​​​​​"ru_UA", ​​​​​"fr_MR", ​​​​​"tk_Latn_TM", ​​​​​"zh_Hans_MO", ​​​​​"mn_Cyrl_MN", ​​​​​"bs_Cyrl", ​​​​​"sw_UG", ​​​​​"ko_KR", ​​​​​"en_DG", ​​​​​"bo_IN", ​​​​​"en_CC", ​​​​​"shi_Tfng_MA", ​​​​​"lag", ​​​​​"it_SM", ​​​​​"en_TT", ​​​​​"ms_Arab_MY", ​​​​​"sq_MK", ​​​​​"ms_Latn", ​​​​​"bem_ZM", ​​​​​"kde", ​​​​​"ar_OM", ​​​​​"cgg", ​​​​​"bas", ​​​​​"kam", ​​​​​"zh_Hant", ​​​​​"es_MX", ​​​​​"en_GU", ​​​​​"fr_MU", ​​​​​"fr_KM", ​​​​​"ar_LB", ​​​​​"en_BA", ​​​​​"en_TV", ​​​​​"sr_Cyrl", ​​​​​"dje", ​​​​​"kab_DZ", ​​​​​"fil_PH", ​​​​​"vai", ​​​​​"hr_HR", ​​​​​"bs_Latn_BA", ​​​​​"nl_AW", ​​​​​"dav", ​​​​​"so_SO", ​​​​​"ar_PS", ​​​​​"en_FR", ​​​​​"uz_Cyrl", ​​​​​"ff_SN", ​​​​​"en_BB", ​​​​​"ki_KE", ​​​​​"naq", ​​​​​"en_SS", ​​​​​"mg_MG", ​​​​​"mas_KE", ​​​​​"en_RO", ​​​​​"en_PG", ​​​​​"mgh", ​​​​​"dyo_SN", ​​​​​"mas", ​​​​​"agq", ​​​​​"bn_BD", ​​​​​"haw", ​​​​​"nb_NO", ​​​​​"da_DK", ​​​​​"en_DK", ​​​​​"saq", ​​​​​"ug", ​​​​​"cy_GB", ​​​​​"fr_YT", ​​​​​"jmc", ​​​​​"ses_ML", ​​​​​"en_PH", ​​​​​"de_DE", ​​​​​"ar_YE", ​​​​​"bm_ML", ​​​​​"yo", ​​​​​"lkt_US", ​​​​​"uz_Arab_AF", ​​​​​"jgo", ​​​​​"uk", ​​​​​"sl_SI", ​​​​​"en_CH", ​​​​​"asa", ​​​​​"lg_UG", ​​​​​"mgo", ​​​​​"id_ID", ​​​​​"en_NA", ​​​​​"en_GY", ​​​​​"zgh", ​​​​​"pt_MZ", ​​​​​"fr_LU", ​​​​​"kk_Cyrl", ​​​​​"mas_TZ", ​​​​​"ur", ​​​​​"en_DM", ​​​​​"ta_MY", ​​​​​"en_BE", ​​​​​"mg", ​​​​​"fr_GA", ​​​​​"ka_GE", ​​​​​"nmg", ​​​​​"en_TZ", ​​​​​"eu_ES", ​​​​​"ar_DZ", ​​​​​"id", ​​​​​"so_DJ", ​​​​​"yav", ​​​​​"mk", ​​​​​"pa_Arab_PK", ​​​​​"ml", ​​​​​"en_ER", ​​​​​"ig", ​​​​​"mn", ​​​​​"ksb", ​​​​​"uz", ​​​​​"vi_VN", ​​​​​"ii", ​​​​​"en_PK", ​​​​​"ee", ​​​​​"mr", ​​​​​"ms", ​​​​​"en_ES", ​​​​​"sq_XK", ​​​​​"it_CH", ​​​​​"mt", ​​​​​"en_CK", ​​​​​"br_FR", ​​​​​"sr_Cyrl_XK", ​​​​​"ksf", ​​​​​"en_SX", ​​​​​"bg_BG", ​​​​​"en_PL", ​​​​​"af", ​​​​​"el", ​​​​​"cs_CZ", ​​​​​"fr_TD", ​​​​​"zh_Hans_HK", ​​​​​"is", ​​​​​"my", ​​​​​"en", ​​​​​"it", ​​​​​"ii_CN", ​​​​​"eo", ​​​​​"iu", ​​​​​"en_ZA", ​​​​​"en_AD", ​​​​​"ak", ​​​​​"en_RU", ​​​​​"kkj_CM", ​​​​​"am", ​​​​​"es", ​​​​​"et", ​​​​​"uk_UA"​​​}

★Click Here to Open This Script 

Posted in Calendar System Text | Tagged 10.11savvy 10.12savvy 10.13savvy | Leave a comment

指定言語環境(Locale)の月名、曜日名を取得する

Posted on 2月 22, 2018 by Takaaki Naganoya
AppleScript名:指定言語環境(Locale)の月名、曜日名を取得する
use AppleScript version "2.4"
use scripting additions
use framework "Foundation"

set aList to getLocalizedDaynames("en_US")
–>  {​​​​​"Sunday", ​​​​​"Monday", ​​​​​"Tuesday", ​​​​​"Wednesday", ​​​​​"Thursday", ​​​​​"Friday", ​​​​​"Saturday"​​​}
set aList to getLocalizedDaynames("fr_FR")
–>  {​​​​​"Dimanche", ​​​​​"Lundi", ​​​​​"Mardi", ​​​​​"Mercredi", ​​​​​"Jeudi", ​​​​​"Vendredi", ​​​​​"Samedi"​​​}
set aList to getLocalizedDaynames("ja_JP")
–>  {​​​​​"日曜日", ​​​​​"月曜日", ​​​​​"火曜日", ​​​​​"水曜日", ​​​​​"木曜日", ​​​​​"金曜日", ​​​​​"土曜日"​​​}
set aList to getLocalizedDaynames("zh-Hans")
–>  {​​​​​"星期日", ​​​​​"星期一", ​​​​​"星期二", ​​​​​"星期三", ​​​​​"星期四", ​​​​​"星期五", ​​​​​"星期六"​​​}

set bList to getLocalizedMonthnames("en_US")
–>  {​​​​​"January", ​​​​​"February", ​​​​​"March", ​​​​​"April", ​​​​​"May", ​​​​​"June", ​​​​​"July", ​​​​​"August", ​​​​​"September", ​​​​​"October", ​​​​​"November", ​​​​​"December"​​​}
set bList to getLocalizedMonthnames("fr_FR")
–>  {​​​​​"janvier", ​​​​​"février", ​​​​​"mars", ​​​​​"avril", ​​​​​"mai", ​​​​​"juin", ​​​​​"juillet", ​​​​​"août", ​​​​​"septembre", ​​​​​"octobre", ​​​​​"novembre", ​​​​​"décembre"​​​}
set bList to getLocalizedMonthnames("ja_JP")
–>  {​​​​​"1月", ​​​​​"2月", ​​​​​"3月", ​​​​​"4月", ​​​​​"5月", ​​​​​"6月", ​​​​​"7月", ​​​​​"8月", ​​​​​"9月", ​​​​​"10月", ​​​​​"11月", ​​​​​"12月"​​​}
set bList to getLocalizedMonthnames("zh-Hans")
–>  {​​​​​"一月", ​​​​​"二月", ​​​​​"三月", ​​​​​"四月", ​​​​​"五月", ​​​​​"六月", ​​​​​"七月", ​​​​​"八月", ​​​​​"九月", ​​​​​"十月", ​​​​​"十一月", ​​​​​"十二月"​​​}

–ローカライズされた曜日名称を返す
on getLocalizedDaynames(aLoc)
  set df to current application’s NSDateFormatter’s alloc()’s init()
  
df’s setLocale:(current application’s NSLocale’s localeWithLocaleIdentifier:aLoc)
  
set dayNames to df’s standaloneWeekdaySymbols() as list
  
return dayNames
end getLocalizedDaynames

–ローカライズされた月名称を返す
on getLocalizedMonthnames(aLoc)
  set df to current application’s NSDateFormatter’s alloc()’s init()
  
df’s setLocale:(current application’s NSLocale’s localeWithLocaleIdentifier:aLoc)
  
set monthNames to df’s standaloneMonthSymbols() as list
  
return monthNames
end getLocalizedMonthnames

★Click Here to Open This Script 

Posted in Calendar Text | Tagged 10.11savvy 10.12savvy 10.13savvy | 1 Comment

GHKitのじっけん

Posted on 2月 13, 2018 by Takaaki Naganoya

–> GHKit.framework

AppleScript名:GHKitのじっけん
— Created 2016-04-12 by Takaaki Naganoya
— 2016 Piyomaru Software
use AppleScript version "2.4"
use scripting additions
use framework "Foundation"
use framework "GHKit" –https://github.com/gabriel/GHKit
–AppleScriptObjC uses "_" as special character (equivalent to ":" in method names). So, I changed them in whole project.
–  Original Method Name: gh_parseISO8601:
–  Converted Method Name: GHparseISO8601:

set aStr to current application’s NSString’s stringWithString:"Sun, 06 Nov 1994 08:49:37 +0000"
set aDate to (current application’s NSDate’s GHparseRFC822:aStr) as date
–>  date "1994年11月6日日曜日 17:49:37"

set bStr to current application’s NSString’s stringWithString:"1997-07-16T19:20:30.045Z"
set bDate to (current application’s NSDate’s GHparseISO8601:bStr) as date
–>  date "1997年7月17日木曜日 4:20:30"

set cDateStr to bDate’s GHformatHTTP()
–>  (NSString) "Wed, 16 Jul 1997 19:20:30 GMT"

set dDate to current application’s NSDate’s GHparseTimeSinceEpoch:(1.23456789E+9)
–>  (NSDate) 2009-02-13 23:31:30 +0000

set eDate to current application’s NSDate’s |date|()
eDate’s GHisToday() as boolean
–>  true
—–GHyesterday() cause error..

set fDate to eDate’s GHaddDays:-1
fDate’s GHwasYesterday() as boolean
–>  true

set ffRes to ((fDate’s GHtimeAgo:false)’s |description|()) as string
–> "1 day"

set anArray to current application’s NSArray’s arrayWithArray:{1, 1, 3}
set cArray to anArray’s GHuniq() as list
–>   {​​​​​1, ​​​​​3​​​}

set aDic to current application’s NSDictionary’s dictionaryWithDictionary:{key1:2, key2:3.1, key3:true}
set aJSONstr to (aDic’s GHtoJSON:(current application’s NSJSONWritingPrettyPrinted) |error|:(missing value)) as string
(*
–> (NSString) "{\n "key1" : 2,\n "key3" : true,\n "key2" : 3.1\n}"
*)

(current application’s NSString’s GHisBlank:" ") as boolean
–>  true

(current application’s NSString’s GHisBlank:(missing value)) as boolean
–>  true

set aStr to current application’s NSString’s stringWithString:" some text "
set a1Str to (aStr’s GHstrip()) as string
–> "some text"

set a2Str to (aStr’s GHpresent()) as string
–> " some text "

set a3Str to aStr’s GHreverse()
–>   " txet emos "

set a4Str to aStr’s GHcount:"e"
–> 2

★Click Here to Open This Script 

Posted in Calendar System Text | Tagged 10.11savvy 10.12savvy 10.13savvy | Leave a comment

Absolute Timeを取得

Posted on 2月 13, 2018 by Takaaki Naganoya
AppleScript名:Absolute Timeを取得
— Created 2016-07-12 by Takaaki Naganoya
— 2016 Piyomaru Software
use AppleScript version "2.4"
use scripting additions
use framework "Foundation"

–タイムスタンプ取得(Jan 1 2001 00:00:00 GMTからの相対秒、Absolute Timeで取得)
set aTime to current application’s NSString’s stringWithFormat_("%@", current application’s CFAbsoluteTimeGetCurrent()) as string
–>  "490022703.57607"

★Click Here to Open This Script 

Posted in Calendar System Text | Tagged 10.11savvy 10.12savvy 10.13savvy | Leave a comment

自然言語テキストから日付を抽出

Posted on 2月 13, 2018 by Takaaki Naganoya

NSDataDetectorを用いて、自然言語テキスト(ここでは日本語のテキスト)から日付の情報を抽出するAppleScriptです。

AppleScript名:自然言語テキストから日付を抽出
— Created 2015-10-08 by Takaaki Naganoya
— 2015 Piyomaru Software
use AppleScript version "2.5"
use framework "Foundation"
use scripting additions

set theDate to my getDatesIn:"本テキストには次の火曜日という日付情報を含んでいる。"
log theDate
–>  date "2015年10月13日火曜日 12:00:00"

set theDate to my getDatesIn:"本テキストには今度の土曜日という日付情報を含んでいる。"
log theDate
–>  date "2015年10月10日土曜日 12:00:00"

set theDate to my getDatesIn:"昨日うな重を食べた。"
log theDate
–>  date "2015年10月7日水曜日 12:00:00"

–set theDate to my getDatesIn:"一昨日何を食べたか覚えていない。"
–>  error number -2700 No date found

–set theDate to my getDatesIn:"The day after tommorow."

–set theDate to my getDatesIn:"相対日付の認識能力は低い。明後日はいつだ?"
–>  error number -2700 No date found

–set theDate to my getDatesIn:"本テキストには元旦という日付情報を含んでいる。" –This means 1/1 in next year
–>  error number -2700 No date found

on getDatesIn:aString
  set anNSString to current application’s NSString’s stringWithString:aString
  
set theDetector to current application’s NSDataDetector’s dataDetectorWithTypes:(current application’s NSTextCheckingTypeDate) |error|:(missing value)
  
set theMatch to theDetector’s firstMatchInString:anNSString options:0 range:{0, anNSString’s |length|()}
  
if theMatch = missing value then error "No date found with String:" & aString
  
set theDate to theMatch’s |date|()
  
return theDate as date
end getDatesIn:

★Click Here to Open This Script 

Posted in Calendar System Text | Tagged 10.11savvy 10.12savvy 10.13savvy | Leave a comment

GMTとの時差を求める

Posted on 2月 13, 2018 by Takaaki Naganoya
AppleScript名:GMTとの時差を求める
set tDIff to (time to GMT) / 3600
–> 9.0

★Click Here to Open This Script 

Posted in Calendar System Text | Tagged 10.11savvy 10.12savvy 10.13savvy | Leave a comment

UTCTime StringとNSDateの相互変換

Posted on 2月 13, 2018 by Takaaki Naganoya
AppleScript名:UTCTime StringとNSDateの相互変換
— Created 2015-02-24 by Shane Stanley
— Changed 2015-02-25 By Takaaki Naganoya
use AppleScript version "2.4"
use scripting additions
use framework "Foundation"

set aStr to retUTCTimeString()
–>   "2018-02-13T12:40:01.936"

set aNSDate to retNSDateFromUTCString(aStr) as date
–> date "2018年2月13日火曜日 21:39:43"

–Current Date -> UTCTime String
on retUTCTimeString()
  –There is need to get Current Calendar in my Time Zone
  
set aCalendar to current application’s NSCalendar’s currentCalendar()
  
set aTimeZone to (aCalendar’s timeZone)
  
set tDiff to (aTimeZone’s secondsFromGMT())
  
  
set theNSDateFormatter to current application’s NSDateFormatter’s alloc()’s init()
  
  
theNSDateFormatter’s setDateFormat:"yyyy-MM-dd’T’HH:mm:ss.SSS"
  
theNSDateFormatter’s setTimeZone:(current application’s NSTimeZone’s timeZoneForSecondsFromGMT:tDiff)
  
  
return (theNSDateFormatter’s stringFromDate:(current application’s NSDate’s |date|())) as text
end retUTCTimeString

–UTCTime String -> NSDate
on retNSDateFromUTCString(aText)
  set aStr to current application’s NSString’s stringWithString:aText
  
  
set theNSDateFormatter to current application’s NSDateFormatter’s alloc()’s init()
  
theNSDateFormatter’s setDateFormat:"yyyy-MM-dd’T’HH:mm:ss.SSS"
  
theNSDateFormatter’s setTimeZone:(current application’s NSTimeZone’s timeZoneForSecondsFromGMT:0)
  
  
return theNSDateFormatter’s dateFromString:aStr
end retNSDateFromUTCString

★Click Here to Open This Script 

Posted in Calendar System Text | Tagged 10.11savvy 10.12savvy 10.13savvy | Leave a comment

ISO8601を考慮した週カウント v2

Posted on 2月 13, 2018 by Takaaki Naganoya

AppleScript名:ISO8601を考慮した週カウント v2
— Created 2016-02-10 by Takaaki Naganoya
— Modified 2016-03-26 by Takaaki Naganoya
— NSGregorianCalendar -> NSCalendarIdentifierGregorian
— 2016 Piyomaru Software
use AppleScript version "2.4"
use scripting additions
use framework "Foundation"

set aNSDate to makeNSDate(2016, 1, 1) of me
set aCal to current application’s NSCalendar’s currentCalendar()
aCal’s setMinimumDaysInFirstWeek:1
set aWN to (aCal’s components:(current application’s NSWeekCalendarUnit) fromDate:aNSDate)’s week()

aCal’s setMinimumDaysInFirstWeek:4 –ISO8601 Week Count
set bWN to (aCal’s components:(current application’s NSWeekCalendarUnit) fromDate:aNSDate)’s week()

return {aWN, bWN}
–>  {1, 52}

–Y,M,Dを指定してNSDateを作成
on makeNSDate(aYear as integer, aMonth as integer, aDay as integer)
  set aComp to current application’s NSDateComponents’s alloc()’s init()
  
aComp’s setDay:aDay
  
aComp’s setMonth:aMonth
  
aComp’s setYear:aYear
  
set aGrego to current application’s NSCalendar’s calendarWithIdentifier:(current application’s NSCalendarIdentifierGregorian)
  
set aDate to aGrego’s dateFromComponents:aComp
  
return aDate
end makeNSDate

★Click Here to Open This Script 

Posted in Calendar System | Tagged 10.11savvy 10.12savvy 10.13savvy | Leave a comment

ISO8601フォーマット日付のテキストをdateに変換

Posted on 2月 13, 2018 by Takaaki Naganoya
AppleScript名:ISO8601フォーマット日付のテキストをdateに変換
— Created 2015-08-28 20:19:04 +0900 by Takaaki Naganoya
— 2015 Piyomaru Software
— http://www.tondering.dk/claus/cal/iso8601.php
use AppleScript version "2.4"
use scripting additions
use framework "Foundation"
use BridgePlus : script "BridgePlus" –https://www.macosxautomation.com/applescript/apps/BridgePlus.html

set aStr to "2010-12-01T21:35:43+09:00"
BridgePlus’s datesFromStrings:{aStr} inFormat:"yyyy-MM-dd’T’HH:mm:ssZ"
–>  {​​​​​date "2010年12月1日水曜日 21:35:43"​​​}

set aStr to "2010-12-01 21:35:43"
BridgePlus’s datesFromStrings:{aStr} inFormat:"yyyy-MM-dd HH:mm:ss"
–>  {​​​​​date "2010年12月1日水曜日 21:35:43"​​​}

★Click Here to Open This Script 

Posted in Calendar System Text | Tagged 10.11savvy 10.12savvy 10.13savvy | Leave a comment

ISO8601日付文字列を生成 v2

Posted on 2月 13, 2018 by Takaaki Naganoya
AppleScript名:ISO8601日付文字列を生成 v2
use AppleScript version "2.5"
use scripting additions
use framework "Foundation"

set aDate to getDateInternational(2018, 12, 18, 9, 59, 35, "CET") –―year, month, date, hour, minute, second, time zone abbreviation.
set bStr to retISO8601DateTimeString(aDate, "CET") as string
–> "2018-12-18T09:59:35+01:00"

–NSDate -> ISO8601 Date & Time String
on retISO8601DateTimeString(targDate, timeZoneAbbreviation)
  set theNSDateFormatter to current application’s NSDateFormatter’s alloc()’s init()
  
theNSDateFormatter’s setDateFormat:"yyyy-MM-dd’T’HH:mm:ssZZZZZ" — Five zeds to get a colon in the time offset (except with GMT).
  
theNSDateFormatter’s setTimeZone:(current application’s NSTimeZone’s timeZoneWithAbbreviation:(timeZoneAbbreviation))
  
return (theNSDateFormatter’s stringFromDate:targDate) as text
end retISO8601DateTimeString

–Make a GMT Date Object with parameters from a given time zone.
on getDateInternational(aYear, aMonth, aDay, anHour, aMinute, aSecond, timeZoneAbbreviation)
  set theNSCalendar to current application’s NSCalendar’s currentCalendar()
  
theNSCalendar’s setTimeZone:(current application’s NSTimeZone’s timeZoneWithAbbreviation:(timeZoneAbbreviation))
  
set theDate to theNSCalendar’s dateWithEra:1 |year|:aYear |month|:aMonth |day|:aDay hour:anHour minute:aMinute |second|:aSecond nanosecond:0
  
return theDate as date
end getDateInternational

★Click Here to Open This Script 

Posted in Calendar System Text | Tagged 10.11savvy 10.12savvy 10.13savvy | Leave a comment

date objectをRFC2822 date stringに変換

Posted on 2月 13, 2018 by Takaaki Naganoya
AppleScript名:date objectをRFC2822 date stringに変換
— Created 2017-12-19 by Takaaki Naganoya
— 2017 Piyomaru Software
use AppleScript version "2.4"
use scripting additions
use framework "Foundation"

set aDate to getDateInternational(2018, 2, 1) of me
set bStr to rfc2822DateTimeString(aDate, "JST") as string
–>  "Thu, 01 Feb 2018 00:00:00 +0900"

–date -> RFC2822 Date & Time String
on rfc2822DateTimeString(targDate, timeZoneName as string)
  set theNSDateFormatter to current application’s NSDateFormatter’s alloc()’s init()
  
theNSDateFormatter’s setDateFormat:"EEE, dd MMM yyyy HH:mm:ss Z"
  
theNSDateFormatter’s setTimeZone:(current application’s NSTimeZone’s alloc()’s initWithName:timeZoneName)
  
theNSDateFormatter’s setLocale:(current application’s NSLocale’s alloc()’s initWithLocaleIdentifier:"en_US_POSIX")
  
return (theNSDateFormatter’s stringFromDate:targDate) as text
end rfc2822DateTimeString

–Make Date Object from parameters
on getDateInternational(aYear as integer, aMonth as integer, aDay as integer)
  set theNSCalendar to current application’s NSCalendar’s currentCalendar()
  
set theDate to theNSCalendar’s dateWithEra:1 |year|:aYear |month|:aMonth |day|:aDay hour:0 minute:0 |second|:0 nanosecond:0
  
return theDate as date
end getDateInternational

★Click Here to Open This Script 

Posted in Calendar System Text | Tagged 10.11savvy 10.12savvy 10.13savvy | Leave a comment

date pickerによる日付選択

Posted on 2月 8, 2018 by Takaaki Naganoya

AppleScript名:date pickerによる日付選択
— Created 2015-08-20 by Shane Stanley
use AppleScript version "2.4"
use scripting additions
use framework "Foundation"
use framework "AppKit"
use script "BridgePlus" — https://www.macosxautomation.com/applescript/apps/BridgePlus.html

if not (current application’s NSThread’s isMainThread()) as boolean then
  display alert "This script must be run from the main thread." buttons {"Cancel"} as critical
  
error number -128
end if

— create a view
set theView to current application’s NSView’s alloc()’s initWithFrame:(current application’s NSMakeRect(0, 0, 100, 200))

— create date picker
set datePicker to current application’s NSDatePicker’s alloc()’s initWithFrame:(current application’s NSMakeRect(0, 0, 100, 100))

— set style: choices are NSTextFieldAndStepperDatePickerStyle, NSClockAndCalendarDatePickerStyle, or NSTextFieldDatePickerStyle
datePicker’s setDatePickerStyle:(current application’s NSClockAndCalendarDatePickerStyle)

— set elements: choices include NSHourMinuteDatePickerElementFlag, NSHourMinuteSecondDatePickerElementFlag, NSTimeZoneDatePickerElementFlag, NSYearMonthDatePickerElementFlag, and NSEraDatePickerElementFlag
datePicker’s setDatePickerElements:((current application’s NSYearMonthDayDatePickerElementFlag) + (current application’s NSHourMinuteSecondDatePickerElementFlag as integer))

— set initial date
datePicker’s setDateValue:(current application’s NSDate’s |date|())

— get the size it needs
set theSize to datePicker’s fittingSize()

–resize the picker and view accordingly
theView’s setFrameSize:theSize
datePicker’s setFrameSize:theSize

— add the picker to the view
theView’s setSubviews:{datePicker}

— create an alert
set theAlert to current application’s NSAlert’s alloc()’s init()

— set up alert
tell theAlert
  its setMessageText:"Pick a date"
  
its setInformativeText:"Any date"
  
its addButtonWithTitle:"OK"
  
its addButtonWithTitle:"Cancel"
  
its setAccessoryView:theView
end tell

— show alert in modal loop
set returnCode to theAlert’s runModal()
if returnCode = (current application’s NSAlertSecondButtonReturn) then error number -128

— retrieve date
set theDate to ASify from (datePicker’s dateValue()) — or simply coerce to date in 10.11

–>  date "2015年8月20日木曜日 19:43:58"

★Click Here to Open This Script 

Posted in Calendar dialog | Tagged 10.11savvy 10.12savvy 10.13savvy | Leave a comment

国民の祝日を求める v4

Posted on 2月 6, 2018 by Takaaki Naganoya
AppleScript名:国民の祝日を求める v4
use AppleScript version "2.5"
use scripting additions
use framework "Foundation"

(*

本バージョンのテーマ:

日付ベースだけでカレンダー計算を行うのではなく、祝日の名称や振替休日といった属性情報を考慮しつつ計算を行う
元日の振替休日に対応

*)

set aList to retHolidayRec(2018) of me

–> {{date "2018年1月1日月曜日 0:00:00", "元旦"}, {date "2018年1月8日月曜日 0:00:00", "成人の日"}, {date "2018年2月11日日曜日 0:00:00", "建国記念日"}, {date "2018年2月12日月曜日 0:00:00", "振替休日"}, {date "2018年3月21日水曜日 0:00:00", "春分の日"}, {date "2018年4月29日日曜日 0:00:00", "昭和の日"}, {date "2018年4月30日月曜日 0:00:00", "振替休日"}, {date "2018年5月3日木曜日 0:00:00", "憲法記念日"}, {date "2018年5月4日金曜日 0:00:00", "みどりの日"}, {date "2018年5月5日土曜日 0:00:00", "こどもの日"}, {date "2018年7月16日月曜日 0:00:00", "海の日"}, {date "2018年9月17日月曜日 0:00:00", "敬老の日"}, {date "2018年9月23日日曜日 0:00:00", "秋分の日"}, {date "2018年9月24日月曜日 0:00:00", "振替休日"}, {date "2018年10月8日月曜日 0:00:00", "体育の日"}, {date "2018年11月3日土曜日 0:00:00", "文化の日"}, {date "2018年11月23日金曜日 0:00:00", "勤労感謝の日"}, {date "2018年12月23日日曜日 0:00:00", "天皇誕生日"}, {date "2018年12月24日月曜日 0:00:00", "振替休日"}}

–国民の祝日を求める(属性つき)
on retHolidayRec(aYear)
  set holidayList to {{"1/1", "元旦"}, {"2/11", "建国記念日"}, {"4/29", "昭和の日"}, {"5/3", "憲法記念日"}, {"5/4", "みどりの日"}, {"5/5", "こどもの日"}, {"11/3", "文化の日"}, {"11/23", "勤労感謝の日"}, {"12/23", "天皇誕生日"}}
  
  
set the end of holidayList to {get_specifiedDay(aYear, 1, 2, 2), "成人の日"} –成人の日–1月の第2月曜日
  
set the end of holidayList to {get_specifiedDay(aYear, 7, 2, 3), "海の日"} –海の日–7月の第3月曜日
  
set the end of holidayList to {get_specifiedDay(aYear, 9, 2, 3), "敬老の日"} –敬老の日–9月の第3月曜日
  
set the end of holidayList to {get_specifiedDay(aYear, 10, 2, 2), "体育の日"} –体育の日–10月の第2月曜日
  
set the end of holidayList to {"3/" & get_ShunbunNoHi(aYear), "春分の日"} –春分の日
  
set the end of holidayList to {"9/" & get_ShuubunNoHi(aYear), "秋分の日"} –秋分の日
  
  
set holiDate to {}
  
repeat with i in holidayList
    set holiD to date (((aYear as text) & "/" & item 1 of i) as text)
    
set holiNum to weekday of holiD as number
    
    
–元日以外を対象とする(元旦に振替休日なし)–> いや、ある(汗)
    
–if ((item 1 of i) as text) is not "1/1" then
    
–振替休日付加処理
    
if holiNum = 1 then –祝祭日が日曜日だったら
      –日付を動かすのではなく、振替休日を追加する
      
set holiD_furikae to holiD + (1 * days)
      
set the end of holiDate to {holiD_furikae, "振替休日"}
    end if
    
–end if
    
set the end of holiDate to {holiD, item 2 of i}
    
  end repeat
  
  
  
–重複した休日が発生した場合の再振替処理  
  
–基本ルール:  振替休日を後に送る
  
–        「振替休日」が重複リストに入っていないかどうかをチェックし、振替休日の再配置を行う
  
set itemNum to 1
  
set holiDateDup to detectDuplicatesFromNestedList(holiDate, itemNum) of me
  
  
set huriList to {}
  
repeat with i in holiDateDup
    set iCount to length of i
    
repeat with ii in i
      set {aDate, aDateName} to ii
      
if aDateName = "振替休日" then
        set the end of huriList to contents of ii
      end if
    end repeat
  end repeat
  
  
set holiDate to shellSortListAscending(holiDate, 1) of me
  
set holiDateList to spritOrderedItemFromNestedList(holiDate, 1) of me
  
  
repeat with i in huriList
    set {aDate, aName} to i
    
set j to contents of i
    
set offsetDate to 1
    
repeat
      set bDate to aDate + (offsetDate * days)
      
if bDate is not in holiDateList then
        exit repeat
      end if
      
set offsetDate to offsetDate + 1
    end repeat
    
    
set iCount to 1
    
repeat with ii in holiDate
      set jj to contents of ii
      
if jj = j then
        –「複数要素一括削除サブルーチン」などという高機能すぎるサブルーチンを使用。ちょっともったいない
        
set holiDate to itemsDelete(holiDate, {iCount}) of me
      end if
      
set iCount to iCount + 1
    end repeat
    
    
set the end of holiDate to {bDate, "振替休日"}
    
  end repeat
  
  
  
–秋分の日と敬老の日の「間の日」の休日判定処理
  
–参考文献:
  
–http://ja.wikipedia.org/wiki/秋分の日
  
set septDL to {}
  
set the end of septDL to "9/" & get_ShuubunNoHi(aYear) of me –秋分の日
  
set the end of septDL to get_specifiedDay(aYear, 9, 2, 3) –敬老の日 –9月の第3月曜日
  
set septDL to shellSort(septDL) of me
  
if septDL = {"9/21", "9/23"} then
    set kokuminShukujitu to (aYear as string) & "/9/22"
    
set kokuminShukujitu to date kokuminShukujitu
    
set the end of holiDate to {kokuminShukujitu, "国民の祝日"}
  end if
  
  
–最後に、並べ替えを行って仕上げ
  
set holiDate to shellSortListAscending(holiDate, 1) of me
  
  
return holiDate
  
end retHolidayRec

–春分の日を求める
–2000年から2099年の間まで計算可能
on get_ShunbunNoHi(aYear)
  set a to 20.69115
  
set b to (aYear – 2000) * 0.2421904
  
set c to round ((aYear – 2000) / 4) rounding toward zero
  
set d to round (a + b – c) rounding toward zero
  
return d
end get_ShunbunNoHi

–秋分の日を求める
–2000年から2099年の間まで計算可能
on get_ShuubunNoHi(aYear)
  set a to 23.09
  
set b to (aYear – 2000) * 0.2421904
  
set c to round ((aYear – 2000) / 4) rounding toward zero
  
set d to round (a + b – c) rounding toward zero
  
return d
end get_ShuubunNoHi

–指定月の第x指定曜日に該当する日付を求める(mm/dd形式)
– 曜日の指定を数値(weekday of (current date) as number)で行えるようにした。
– 曜日を「日曜日」などの日本語ローカライズド文字列で指定するのをやめた
–パラメータ: 年, 月, 曜日番号, 順番
on get_specifiedDay(aYear as integer, aMonth as integer, Youbi as integer, orderNum as integer)
  set sDat to date ((aYear & "/" & aMonth & "/1") as text)
  
set eDat to getMlenInternational(aYear, aMonth) of me
  
  
set countNum to 0
  
  
repeat with i from 1 to eDat
    set aCal to date ((aYear & "/" & aMonth & "/" & (i as text)) as text)
    
set aWeekDayNum to weekday of aCal as number
    
if Youbi = aWeekDayNum then
      set countNum to countNum + 1
      
if countNum is orderNum then
        set aCalText to (aMonth & "/" & i as text)
        
return aCalText
      end if
    end if
  end repeat
end get_specifiedDay

–指定日の月のみ返す
on getMonth(aDat as date)
  set bDate to month of aDat
  
return bDate as number
end getMonth

–指定日の日付のみ返す
on getDate(aDat as date)
  set bDate to day of aDat
  
return bDate as number
end getDate

–指定日の年のみ返す
on getYear(aDat as date)
  set bDate to year of aDat
  
return bDate as number
end getYear

–現在のカレンダーで指定年月の日数を返す(getMlenから置き換えた)
on getMlenInternational(aYear, aMonth)
  set theNSCalendar to current application’s NSCalendar’s currentCalendar() — do *not* use initWithCalendarIdentifier:
  
set theDate to theNSCalendar’s dateWithEra:1 |year|:aYear |month|:aMonth |day|:1 hour:0 minute:0 |second|:0 nanosecond:0
  
set theResult to theNSCalendar’s rangeOfUnit:(current application’s NSDayCalendarUnit) inUnit:(current application’s NSMonthCalendarUnit) forDate:theDate
  
return |length| of theResult
end getMlenInternational

–リスト中から重複項目をリストアップする
on detectDuplicates(aList)
  set aCount to length of aList
  
  
set duplicationList to {}
  
repeat aCount times
    set anItem to contents of (first item of aList)
    
set aList to rest of aList
    
if anItem is in aList then
      set the end of duplicationList to anItem
    end if
  end repeat
  
  
return duplicationList
end detectDuplicates

–リストから重複部分を除外
on removeDuplicates(aList)
  set newList to {}
  
repeat with i from 1 to (length of aList)
    set anItem to item 1 of aList
    
set aList to rest of aList
    
if {anItem} is not in aList then set end of newList to anItem
  end repeat
  
return newList
end removeDuplicates

–シェルソート
on shellSort(aSortList)
  script oBj
    property list : aSortList
  end script
  
set len to count oBj’s list’s items
  
set gap to 1
  
repeat while (gap ≤ len)
    set gap to ((gap * 3) + 1)
  end repeat
  
repeat while (gap > 0)
    set gap to (gap div 3)
    
if (gap < len) then
      repeat with i from gap to (len – 1)
        set temp to oBj’s list’s item (i + 1)
        
set j to i
        
repeat while ((j ≥ gap) and (oBj’s list’s item (j – gap + 1) > temp))
          set oBj’s list’s item (j + 1) to oBj’s list’s item (j – gap + 1)
          
set j to j – gap
        end repeat
        
set oBj’s list’s item (j + 1) to temp
      end repeat
    end if
  end repeat
  
return oBj’s list
end shellSort

–シェルソートで入れ子のリストを昇順ソート
on shellSortListAscending(a, keyItem)
  set n to length of a
  
set cols to {1391376, 463792, 198768, 86961, 33936, 13776, 4592, 1968, 861, 336, 112, 48, 21, 7, 3, 1}
  
repeat with h in cols
    if (h ≤ (n – 1)) then
      repeat with i from h to (n – 1)
        set v to item (i + 1) of a
        
set j to i
        
repeat while (j ≥ h) and ((contents of item keyItem of item (j – h + 1) of a) > (item keyItem of v))
          set (item (j + 1) of a) to (item (j – h + 1) of a)
          
set j to j – h
        end repeat
        
set item (j + 1) of a to v
      end repeat
    end if
  end repeat
  
return a
end shellSortListAscending

–シェルソートで入れ子のリストを降順ソート
on shellSortListDecending(a, keyItem)
  set n to length of a
  
set cols to {1391376, 463792, 198768, 86961, 33936, 13776, 4592, 1968, 861, 336, 112, 48, 21, 7, 3, 1}
  
repeat with h in cols
    if (h ≤ (n – 1)) then
      repeat with i from h to (n – 1)
        set v to item (i + 1) of a
        
set j to i
        
repeat while (j ≥ h) and ((contents of item keyItem of item (j – h + 1) of a) < (item keyItem of v))
          set (item (j + 1) of a) to (item (j – h + 1) of a)
          
set j to j – h
        end repeat
        
set item (j + 1) of a to v
      end repeat
    end if
  end repeat
  
return a
end shellSortListDecending

–入れ子のリスト中から重複項目をアイテム番号つきでリストアップする
on detectDuplicatesFromNestedList(aList, itemNum)
  set aCount to length of aList
  
copy aList to orig_aList
  
  
set duplicationList to {}
  
repeat aCount times
    set anItem to contents of (first item of aList)
    
set aList to rest of aList
    
    
–指定アイテムだけのリストを毎回再生成して存在確認を行う
    
set aaList to spritOrderedItemFromNestedList(aList, itemNum) of me
    
if (contents of (item itemNum of anItem)) is in aaList then
      set the end of duplicationList to anItem
    end if
    
  end repeat
  
  
–検出した重複データを元に、該当するデータをリストアップ
  
set detectList to {}
  
repeat with i in duplicationList
    set j to contents of (item itemNum of i)
    
set detectItem to {}
    
repeat with ii in orig_aList
      set jj to contents of (item itemNum of ii)
      
      
if jj = j then
        set the end of detectItem to (contents of ii)
      end if
    end repeat
    
set the end of detectList to detectItem
  end repeat
  
  
return detectList
end detectDuplicatesFromNestedList

–入れ子のリストの全要素から指定アイテム目の要素だけを取り出してリストで返す
on spritOrderedItemFromNestedList(aList, itemNum)
  set aaList to {}
  
repeat with i in aList
    set the end of aaList to contents of (item itemNum of i)
  end repeat
  
return aaList
end spritOrderedItemFromNestedList

–リスト中の指定要素を削除して返す
on itemsDelete(aList, delNumList)
  set delLen to length of delNumList
  
  
repeat with i from 1 to delLen
    
    
set newList to {}
    
set aLen to length of aList
    
    
set ii to item i of delNumList
    
    
if ii = 1 then
      set maeList to items 2 thru aLen of aList
      
set newList to maeList
      
    else if ii = aLen then
      set maeList to items 1 thru (aLen – 1) of aList
      
set newList to maeList
      
    else
      set maeList to items 1 thru (ii – 1) of aList
      
set atoList to items (ii + 1) thru -1 of aList
      
set newList to maeList & atoList
    end if
    
    
–アイテム指定の補正
    
set delNumList to adjustItemNo(ii, delNumList) of me
    
log delNumList
    
    
set aList to newList
  end repeat
  
  
return newList
end itemsDelete

–itemsDeleteのサブルーチン
–リストに対して複数アイテムの削除を行う場合に、1つ削除した後にはアイテム指定が
–狂ってしまうため、毎回削除するたびにアイテム指定の補正を行う
–paramNumとelemListの間でのパラメータの衝突は関知しない

–項目要素補正をリストに対して行う
on adjustItemNo(paramNum, elemList)
  –項目ゼロを指定してきた場合には、そのままelemListを戻す
  
if paramNum = 0 then return elemList
  
–プラス方向のレンジ外判定は行っていない。elemListのlengthよりも大きな値は関知しない
  
set retList to {}
  
repeat with i in elemList
    set j to contents of i
    
if j > paramNum then
      set ansNum to j – 1
    else
      set ansNum to j
    end if
    
set the end of retList to ansNum
  end repeat
  
  
return retList
end adjustItemNo

–現在のカレンダーで指定年月のdate objectを返す(年、月、日、時、分、秒)
on getDateInternationalYMDhms(aYear, aMonth, aDay, anHour, aMinute, aSecond)
  set theNSCalendar to current application’s NSCalendar’s currentCalendar()
  
set theDate to theNSCalendar’s dateWithEra:1 |year|:aYear |month|:aMonth |day|:aDay hour:anHour minute:aMinute |second|:aSecond nanosecond:0
  
return theDate as date
end getDateInternationalYMDhms

–現在のカレンダーで指定年月のdate objectを返す(年、月、日)
on getDateInternational(aYear, aMonth, aDay)
  set theNSCalendar to current application’s NSCalendar’s currentCalendar()
  
set theDate to theNSCalendar’s dateWithEra:1 |year|:aYear |month|:aMonth |day|:aDay hour:0 minute:0 |second|:0 nanosecond:0
  
return theDate as date
end getDateInternational

★Click Here to Open This Script 

Posted in Calendar | Tagged 10.11savvy 10.12savvy 10.13savvy Calendar | Leave a comment

Post navigation

  • Older posts
  • Newer posts

電子書籍(PDF)をオンラインストアで販売中!

Google Search

Popular posts

  • 開発機としてM2 Mac miniが来たのでガチレビュー
  • CotEditorで2つの書類の行単位での差分検出
  • macOS 15, Sequoia
  • 指定のWordファイルをPDFに書き出す
  • Pages本執筆中に、2つの書類モード切り替えに気がついた
  • Adobe AcrobatをAppleScriptから操作してPDF圧縮
  • Numbersで選択範囲のセルの前後の空白を削除
  • メキシカンハットの描画
  • Pixelmator Pro v3.6.4でAppleScriptからの操作時の挙動に違和感が
  • AdobeがInDesign v19.4からPOSIX pathを採用
  • Safariで「プロファイル」機能を使うとAppleScriptの処理に影響
  • Cocoa Scripting Course 続刊計画
  • AppleScriptによる並列処理
  • macOS 14.xでScript Menuの実行速度が大幅に下がるバグ
  • NaturalLanguage.frameworkでNLEmbeddingの処理が可能な言語をチェック
  • AppleScript入門③AppleScriptを使った「自動化」とは?
  • Keynote/Pagesで選択中の表カラムの幅を均等割
  • Keynote、Pages、Numbers Ver.14.0が登場
  • macOS 15 リモートApple Eventsにバグ?
  • デフォルトインストールされたフォント名を取得するAppleScript

Tags

10.11savvy (1102) 10.12savvy (1243) 10.13savvy (1392) 10.14savvy (587) 10.15savvy (438) 11.0savvy (283) 12.0savvy (212) 13.0savvy (190) 14.0savvy (142) 15.0savvy (120) CotEditor (66) Finder (51) iTunes (19) Keynote (116) NSAlert (61) NSArray (51) NSBitmapImageRep (20) NSBundle (20) NSButton (34) NSColor (53) NSDictionary (28) NSFileManager (23) NSFont (21) NSImage (41) NSJSONSerialization (21) NSMutableArray (63) NSMutableDictionary (22) NSPredicate (36) NSRunningApplication (56) NSScreen (30) NSScrollView (22) NSString (119) NSURL (98) NSURLRequest (23) NSUTF8StringEncoding (30) NSView (33) NSWorkspace (20) Numbers (76) Pages (54) Safari (44) Script Editor (27) WKUserContentController (21) WKUserScript (20) WKWebView (23) WKWebViewConfiguration (22)

カテゴリー

  • 2D Bin Packing
  • 3D
  • AirDrop
  • AirPlay
  • Animation
  • AppleScript Application on Xcode
  • Beginner
  • Benchmark
  • beta
  • Bluetooth
  • Books
  • boolean
  • bounds
  • Bug
  • Calendar
  • call by reference
  • check sum
  • Clipboard
  • Cocoa-AppleScript Applet
  • Code Sign
  • Color
  • Custom Class
  • dialog
  • diff
  • drive
  • Droplet
  • exif
  • file
  • File path
  • filter
  • folder
  • Font
  • Font
  • GAME
  • geolocation
  • GUI
  • GUI Scripting
  • Hex
  • History
  • How To
  • iCloud
  • Icon
  • Image
  • Input Method
  • Internet
  • iOS App
  • JavaScript
  • JSON
  • JXA
  • Keychain
  • Keychain
  • Language
  • Library
  • list
  • Locale
  • Localize
  • Machine Learning
  • Map
  • Markdown
  • Menu
  • Metadata
  • MIDI
  • MIME
  • Natural Language Processing
  • Network
  • news
  • Noification
  • Notarization
  • Number
  • Object control
  • OCR
  • OSA
  • parallel processing
  • PDF
  • Peripheral
  • PRODUCTS
  • QR Code
  • Raw AppleEvent Code
  • Record
  • rectangle
  • recursive call
  • regexp
  • Release
  • Remote Control
  • Require Control-Command-R to run
  • REST API
  • Review
  • RTF
  • Sandbox
  • Screen Saver
  • Script Libraries
  • sdef
  • search
  • Security
  • selection
  • shell script
  • Shortcuts Workflow
  • Sort
  • Sound
  • Spellchecker
  • Spotlight
  • SVG
  • System
  • Tag
  • Telephony
  • Text
  • Text to Speech
  • timezone
  • Tools
  • Update
  • URL
  • UTI
  • Web Contents Control
  • WiFi
  • XML
  • XML-RPC
  • イベント(Event)
  • 未分類

アーカイブ

  • 2025年3月
  • 2025年2月
  • 2025年1月
  • 2024年12月
  • 2024年11月
  • 2024年10月
  • 2024年9月
  • 2024年8月
  • 2024年7月
  • 2024年6月
  • 2024年5月
  • 2024年4月
  • 2024年3月
  • 2024年2月
  • 2024年1月
  • 2023年12月
  • 2023年11月
  • 2023年10月
  • 2023年9月
  • 2023年8月
  • 2023年7月
  • 2023年6月
  • 2023年5月
  • 2023年4月
  • 2023年3月
  • 2023年2月
  • 2023年1月
  • 2022年12月
  • 2022年11月
  • 2022年10月
  • 2022年9月
  • 2022年8月
  • 2022年7月
  • 2022年6月
  • 2022年5月
  • 2022年4月
  • 2022年3月
  • 2022年2月
  • 2022年1月
  • 2021年12月
  • 2021年11月
  • 2021年10月
  • 2021年9月
  • 2021年8月
  • 2021年7月
  • 2021年6月
  • 2021年5月
  • 2021年4月
  • 2021年3月
  • 2021年2月
  • 2021年1月
  • 2020年12月
  • 2020年11月
  • 2020年10月
  • 2020年9月
  • 2020年8月
  • 2020年7月
  • 2020年6月
  • 2020年5月
  • 2020年4月
  • 2020年3月
  • 2020年2月
  • 2020年1月
  • 2019年12月
  • 2019年11月
  • 2019年10月
  • 2019年9月
  • 2019年8月
  • 2019年7月
  • 2019年6月
  • 2019年5月
  • 2019年4月
  • 2019年3月
  • 2019年2月
  • 2019年1月
  • 2018年12月
  • 2018年11月
  • 2018年10月
  • 2018年9月
  • 2018年8月
  • 2018年7月
  • 2018年6月
  • 2018年5月
  • 2018年4月
  • 2018年3月
  • 2018年2月

https://piyomarusoft.booth.pm/items/301502

メタ情報

  • ログイン
  • 投稿フィード
  • コメントフィード
  • WordPress.org

Forum Posts

  • 人気のトピック
  • 返信がないトピック

メタ情報

  • ログイン
  • 投稿フィード
  • コメントフィード
  • WordPress.org
Proudly powered by WordPress
Theme: Flint by Star Verte LLC