AppleScript名:今日のYYYY,MM,DDを取得する |
— Created 2015-12-26 by Takaaki Naganoya — 2015 Piyomaru Software use AppleScript version "2.4" use scripting additions use framework "Foundation" use framework "AppKit" set aCalend to current application’s NSCalendar’s currentCalendar() set aDate to current application’s NSDate’s |date|() set aYear to aCalend’s component:(current application’s NSCalendarUnitYear) fromDate:aDate set aYearStr to numToZeroPaddingStr(aYear, 4, "0") of me set aMonth to aCalend’s component:(current application’s NSCalendarUnitMonth) fromDate:aDate set aMonthStr to numToZeroPaddingStr(aMonth, 2, "0") of me set aDay to aCalend’s component:(current application’s NSCalendarUnitDay) fromDate:aDate set aDayStr to numToZeroPaddingStr(aDay, 2, "0") of me set dStr to aYearStr & aMonthStr & aDayStr –> "20171219" –整数の値に指定桁数ゼロパディングして文字列で返す on numToZeroPaddingStr(aNum as integer, aDigit as integer, paddingChar as text) set aNumForm to current application’s NSNumberFormatter’s alloc()’s init() aNumForm’s setPaddingPosition:(current application’s NSNumberFormatterPadBeforePrefix) aNumForm’s setPaddingCharacter:paddingChar aNumForm’s setMinimumIntegerDigits:aDigit set bNum to current application’s NSNumber’s numberWithInt:aNum set aStr to aNumForm’s stringFromNumber:bNum return aStr as text end numToZeroPaddingStr |
More from my site
(Visited 47 times, 1 visits today)