@@ -10,6 +10,9 @@ module Data.Date.Locale
10
10
, minuteOfHour
11
11
, secondOfMinute
12
12
, millisecondOfSecond
13
+ , toLocaleString
14
+ , toLocaleTimeString
15
+ , toLocaleDateString
13
16
) where
14
17
15
18
import Control.Monad.Eff (Eff ())
@@ -76,6 +79,25 @@ secondOfMinute d = runFn2 dateMethod "getSeconds" d
76
79
millisecondOfSecond :: forall e . Date -> Eff (locale :: Locale | e ) MillisecondOfSecond
77
80
millisecondOfSecond d = runFn2 dateMethod " getMilliseconds" d
78
81
82
+ -- | Format a date as a human-readable string (including the date and the
83
+ -- | time), based on the current machine's locale. Example output:
84
+ -- | "Fri May 22 2015 19:45:07 GMT+0100 (BST)", although bear in mind that this
85
+ -- | can vary significantly across platforms.
86
+ toLocaleString :: forall e . Date -> Eff (locale :: Locale | e ) String
87
+ toLocaleString d = runFn2 dateMethod " toLocaleString" d
88
+
89
+ -- | Format a time as a human-readable string, based on the current machine's
90
+ -- | locale. Example output: "19:45:07", although bear in mind that this
91
+ -- | can vary significantly across platforms.
92
+ toLocaleTimeString :: forall e . Date -> Eff (locale :: Locale | e ) String
93
+ toLocaleTimeString d = runFn2 dateMethod " toLocaleTimeString" d
94
+
95
+ -- | Format a date as a human-readable string, based on the current machine's
96
+ -- | locale. Example output: "Friday, May 22, 2015", although bear in mind that
97
+ -- | this can vary significantly across platforms.
98
+ toLocaleDateString :: forall e . Date -> Eff (locale :: Locale | e ) String
99
+ toLocaleDateString d = runFn2 dateMethod " toLocaleDateString" d
100
+
79
101
foreign import dateMethod
80
102
" " "
81
103
function dateMethod(method, date) {
0 commit comments