-
Notifications
You must be signed in to change notification settings - Fork 25
Expand file tree
/
Copy pathDates.applescript
More file actions
69 lines (57 loc) · 1.88 KB
/
Copy pathDates.applescript
File metadata and controls
69 lines (57 loc) · 1.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
(*
Dates Library
v1.0
Dov Frankel, 2013
property LibLoader : load script file ((path to scripts folder from user domain as text) & "Libraries:Library Loader.scpt")
property DatesLib : LibLoader's loadScript("Libraries:Dates.applescript")
*)
-- Returns a Date object for Today at the time specified in timeString
(*
DatesLib's timeOfCurrentDate("12:00 am")
*)
on timeOfCurrentDate(timeString)
return my timeOfDate(current date, timeString)
end timeOfCurrentDate
-- Returns a Date object for a particular date at the time specified in timeString
(*
DatesLib's timeOfDate("12:00 am")
*)
on timeOfDate(TheDate, timeString)
return date ((((month of (TheDate) as string) & " " & day of (TheDate) as string) & ", " & year of (TheDate) as string) & " " & timeString)
end timeOfDate
-- Returns true if both dates are either <missing value> or match, disregarding time
(*
DatesLib's datesMatch(dateA, dateB)
*)
on datesMatch(LeftDate, RightDate)
if LeftDate is missing value then return RightDate is missing value
if RightDate is missing value then return LeftDate is missing value
return short date string of LeftDate = short date string of RightDate
end datesMatch
-- Adds the specified number of days onto the date without changing its time
(*
DatesLib's addDays(date("1/1/01"), 2)
*)
on addDays(TheDate, NumDays)
return TheDate + NumDays * days
end addDays
-- Formats the date as mm/dd/yyyy
(*
DatesLib's formatDate(date("1/1/01"))
*)
on formatDate(TheDate)
-- Get day as 'dd'
set theDay to (day of TheDate as number) as text
if theDay's length < 2 then
set theDay to "0" & theDay
end if
-- Get month as 'mm'
set theMonth to (month of TheDate as number) as text
if theMonth's length < 2 then
set theMonth to "0" & theMonth
end if
-- Get year as 'yyyy'
set theYear to (year of TheDate as number) as text
set dateString to theMonth & "/" & theDay & "/" & theYear
return dateString
end formatDate