Skip to content

Instantly share code, notes, and snippets.

@azonov
Created July 4, 2018 08:52
Show Gist options
  • Save azonov/8e5e34fb61601a11e8b2954552973044 to your computer and use it in GitHub Desktop.
Save azonov/8e5e34fb61601a11e8b2954552973044 to your computer and use it in GitHub Desktop.
on zero_pad(value, string_length)
set string_zeroes to ""
set digits_to_pad to string_length - (length of (value as string))
if digits_to_pad > 0 then
repeat digits_to_pad times
set string_zeroes to string_zeroes & "0" as string
end repeat
end if
set padded_value to string_zeroes & value as string
return padded_value
end zero_pad
on date_formated(date_value, separator)
set currentDate to date_value as string
set currentDate to date currentDate
set result to zero_pad(day of currentDate as integer, 2)
set result to result & separator
set result to result & zero_pad(month of currentDate as integer, 2)
set result to result & separator
set result to result & zero_pad(year of currentDate as integer, 2)
return result
end date_formated
set today to (current date)
set yesterday to short date string of ((current date) - days)
set currentDateString to date_formated(today, ".")
set yesterdayDateString to date_formated(yesterday, ".")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment