AppleScript名:2つの日付の期間を日本語表記でていねいに返す |
— Created 2016-01-17 by Takaaki Naganoya — 2016 Piyomaru Software use AppleScript version "2.4" use scripting additions use framework "Foundation" –Date Difference set sDate to "2016/1/15" –Japanese Date format "YYYY/MM/DD" set eDate to "2016/1/20" –Japanese Date format "YYYY/MM/DD" set aDiffStr to retDateDiffStr(sDate, eDate, "/", "/", "", "〜") of me –> "2016/1/15〜20" –Month Difference set sDate to "2016/1/15" –Japanese Date format "YYYY/MM/DD" set eDate to "2016/2/20" –Japanese Date format "YYYY/MM/DD" set bDiffStr to retDateDiffStr(sDate, eDate, "年", "月", "日", "〜") of me –> "2016年1月15日〜2月20日" –Year Difference set sDate to "2015/12/15" –Japanese Date format "YYYY/MM/DD" set eDate to "2016/1/20" –Japanese Date format "YYYY/MM/DD" set bDiffStr to retDateDiffStr(sDate, eDate, "年", "月", "日", "〜") of me –> "2015年12月15日〜2016年1月20日" –2つの日付の期間を日本語表記でていねいに返す on retDateDiffStr(sDate, eDate, ySeparator, mSeparator, dSeparator, diffSeparator) set sDateO to date sDate set eDateO to date eDate set diffY to (year of eDateO) – (year of sDateO) set diffM to (month of eDateO) – (month of sDateO) set diffD to (day of eDateO) – (day of sDateO) set sYstr to (year of sDateO) as string set sMstr to (month of sDateO as number) as string set sDstr to (day of sDateO) as string set eYstr to (year of eDateO) as string set eMstr to (month of eDateO as number) as string set eDstr to (day of eDateO) as string if diffY > 0 then –Year Difference set outStr to sYstr & ySeparator & sMstr & mSeparator & sDstr & dSeparator & diffSeparator & eYstr & ySeparator & eMstr & mSeparator & eDstr & dSeparator else if diffM > 0 then –Month Difference set outStr to sYstr & ySeparator & sMstr & mSeparator & sDstr & dSeparator & diffSeparator & eMstr & mSeparator & eDstr & dSeparator else if diffD > 0 then –Date Difference set outStr to sYstr & ySeparator & sMstr & mSeparator & sDstr & diffSeparator & eDstr & dSeparator end if return outStr end retDateDiffStr |
More from my site
(Visited 38 times, 1 visits today)