Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
6
Task/Date-format/AppleScript/date-format-1.applescript
Normal file
6
Task/Date-format/AppleScript/date-format-1.applescript
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
set {year:y, month:m, day:d, weekday:w} to (current date)
|
||||
|
||||
tell (y * 10000 + m * 100 + d) as text to set shortFormat to text 1 thru 4 & "-" & text 5 thru 6 & "-" & text 7 thru 8
|
||||
set longFormat to (w as text) & (", " & m) & (space & d) & (", " & y)
|
||||
|
||||
return (shortFormat & linefeed & longFormat)
|
||||
2
Task/Date-format/AppleScript/date-format-2.applescript
Normal file
2
Task/Date-format/AppleScript/date-format-2.applescript
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
"2020-10-28
|
||||
Wednesday, October 28, 2020"
|
||||
8
Task/Date-format/AppleScript/date-format-3.applescript
Normal file
8
Task/Date-format/AppleScript/date-format-3.applescript
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
tell (the current date)
|
||||
set shortdate to text 1 thru 10 of (it as «class isot» as string)
|
||||
set longdate to the contents of [its weekday, ", ", ¬
|
||||
(its month), " ", day, ", ", year] as text
|
||||
end tell
|
||||
|
||||
log the shortdate
|
||||
log the longdate
|
||||
71
Task/Date-format/AppleScript/date-format-4.applescript
Normal file
71
Task/Date-format/AppleScript/date-format-4.applescript
Normal file
|
|
@ -0,0 +1,71 @@
|
|||
-- iso8601Short :: Date -> String
|
||||
on iso8601Short(dte)
|
||||
text 1 thru 10 of iso8601Local(dte)
|
||||
end iso8601Short
|
||||
|
||||
|
||||
-- longDate :: Date -> String
|
||||
on longDate(dte)
|
||||
tell dte
|
||||
"" & its weekday & ", " & its month & " " & its day & ", " & year
|
||||
end tell
|
||||
end longDate
|
||||
|
||||
|
||||
---------------------------- TEST --------------------------
|
||||
on run
|
||||
|
||||
unlines(apList({iso8601Short, longDate}, ¬
|
||||
{current date}))
|
||||
|
||||
end run
|
||||
|
||||
|
||||
-------------------------- GENERIC -------------------------
|
||||
|
||||
|
||||
-- Each member of a list of functions applied to
|
||||
-- each of a list of arguments, deriving a list of new values
|
||||
-- apList (<*>) :: [(a -> b)] -> [a] -> [b]
|
||||
on apList(fs, xs)
|
||||
set lst to {}
|
||||
repeat with f in fs
|
||||
tell mReturn(contents of f)
|
||||
repeat with x in xs
|
||||
set end of lst to |λ|(contents of x)
|
||||
end repeat
|
||||
end tell
|
||||
end repeat
|
||||
return lst
|
||||
end apList
|
||||
|
||||
|
||||
-- iso8601Local :: Date -> String
|
||||
on iso8601Local(dte)
|
||||
(dte as «class isot» as string)
|
||||
end iso8601Local
|
||||
|
||||
|
||||
-- mReturn :: First-class m => (a -> b) -> m (a -> b)
|
||||
on mReturn(f)
|
||||
-- 2nd class handler function lifted into 1st class script wrapper.
|
||||
if script is class of f then
|
||||
f
|
||||
else
|
||||
script
|
||||
property |λ| : f
|
||||
end script
|
||||
end if
|
||||
end mReturn
|
||||
|
||||
|
||||
-- unlines :: [String] -> String
|
||||
on unlines(xs)
|
||||
-- A single string formed by the intercalation
|
||||
-- of a list of strings with the newline character.
|
||||
set {dlm, my text item delimiters} to ¬
|
||||
{my text item delimiters, linefeed}
|
||||
set s to xs as text
|
||||
set my text item delimiters to dlm
|
||||
s
|
||||
end unlines
|
||||
Loading…
Add table
Add a link
Reference in a new issue