Last active
December 11, 2015 10:28
-
-
Save ChewingPencils/4587207 to your computer and use it in GitHub Desktop.
Returns the current week in format: YYYY-MM-DD - YYYY-MM-DD. Start of the week is monday. End of the week is Sunday.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Sean Korzdorfer | |
-- 2013-01-21 | |
-- Fork of benwaldie Current Week Range TextExpander snippet: https://gist.github.com/4583398 | |
set theDate to (current date) | |
set theStartDate to theDate | |
repeat until weekday of theStartDate = Monday | |
set theStartDate to theStartDate - 1 * days | |
end repeat | |
set theEndDate to theDate | |
repeat until weekday of theEndDate = Sunday | |
set theEndDate to theEndDate + 1 * days | |
end repeat | |
-- Original Script Date Formatting: | |
-- set theDate to (short date string of theStartDate) & " - " & (short date string of theEndDate) | |
set theDate to (year of theStartDate as string) & "-" & (my add_zero(month of theStartDate as integer)) & "-" & (my add_zero(day of theStartDate as integer)) & " - " & (year of theEndDate as string) & "-" & (my add_zero(month of theEndDate as integer)) & "-" & (my add_zero(day of theEndDate as integer)) | |
on add_zero(theNumber) | |
if theNumber < 10 then | |
return "0" & (theNumber as string) | |
else | |
return theNumber as string | |
end if | |
end add_zero |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment