8
8
-- | a `Generic` instance.
9
9
module Data.JSDate
10
10
( JSDate
11
- , LOCALE
12
11
, readDate
13
12
, isValid
14
13
, fromDateTime
@@ -48,21 +47,19 @@ module Data.JSDate
48
47
49
48
import Prelude
50
49
51
- import Control.Monad.Eff (kind Effect , Eff )
52
- import Control.Monad.Eff.Exception (EXCEPTION )
53
- import Control.Monad.Eff.Now (NOW )
54
50
import Data.Date as Date
55
51
import Data.DateTime (DateTime (..), Date )
56
52
import Data.DateTime as DateTime
57
53
import Data.DateTime.Instant (Instant )
58
54
import Data.DateTime.Instant as Instant
59
55
import Data.Enum (fromEnum )
60
- import Data.Foreign (F , Foreign , unsafeReadTagged )
61
56
import Data.Function.Uncurried (Fn2 , runFn2 )
62
57
import Data.Int (toNumber )
63
58
import Data.Maybe (Maybe (..))
64
59
import Data.Time as Time
65
60
import Data.Time.Duration (Milliseconds (..))
61
+ import Effect (Effect )
62
+ import Foreign (F , Foreign , unsafeReadTagged )
66
63
67
64
-- | The type of JavaScript `Date` objects.
68
65
foreign import data JSDate :: Type
@@ -76,10 +73,6 @@ instance ordJSDate :: Ord JSDate where
76
73
instance showJSDate :: Show JSDate where
77
74
show a = " (fromTime " <> show (getTime a) <> " )"
78
75
79
- -- | The effect type used when indicating the current machine's date/time locale
80
- -- | is used in computing a value.
81
- foreign import data LOCALE :: Effect
82
-
83
76
-- | Attempts to read a `Foreign` value as a `JSDate`.
84
77
readDate :: Foreign -> F JSDate
85
78
readDate = unsafeReadTagged " Date"
@@ -142,18 +135,17 @@ foreign import jsdate
142
135
-- | Constructs a new `JSDate` from component values using the current machine's
143
136
-- | locale. If any of the values are `NaN` the resulting date will be invalid.
144
137
foreign import jsdateLocal
145
- :: forall eff
146
- . { year :: Number
138
+ :: { year :: Number
147
139
, month :: Number
148
140
, day :: Number
149
141
, hour :: Number
150
142
, minute :: Number
151
143
, second :: Number
152
144
, millisecond :: Number
153
145
}
154
- -> Eff ( locale :: LOCALE | eff ) JSDate
146
+ -> Effect JSDate
155
147
156
- foreign import dateMethodEff :: forall eff a . Fn2 String JSDate (Eff eff a )
148
+ foreign import dateMethodEff :: forall a . Fn2 String JSDate (Effect a )
157
149
foreign import dateMethod :: forall a . Fn2 String JSDate a
158
150
159
151
-- | Attempts to parse a date from a string. The behaviour of this function is
@@ -163,15 +155,14 @@ foreign import dateMethod :: forall a. Fn2 String JSDate a
163
155
-- |
164
156
-- | The `LOCALE` effect is present here as if no time zone is specified in the
165
157
-- | string the current locale's time zone will be used instead.
166
- foreign import parse
167
- :: forall eff . String -> Eff (locale :: LOCALE | eff ) JSDate
158
+ foreign import parse :: String -> Effect JSDate
168
159
169
160
-- | Gets a `JSDate` value for the date and time according to the current
170
161
-- | machine's clock.
171
162
-- |
172
163
-- | Unless a `JSDate` is required specifically, consider using the functions in
173
- -- | `Control.Monad.Eff .Now` instead.
174
- foreign import now :: forall eff . Eff ( now :: NOW | eff ) JSDate
164
+ -- | `Effect .Now` instead.
165
+ foreign import now :: Effect JSDate
175
166
176
167
-- | Returns the date as a number of milliseconds since 1970-01-01 00:00:00 UTC.
177
168
getTime :: JSDate -> Number
@@ -211,55 +202,55 @@ getUTCSeconds dt = runFn2 dateMethod "getUTCSeconds" dt
211
202
212
203
-- | Returns the day of the month for a date, according to the current
213
204
-- | machine's date/time locale.
214
- getDate :: forall eff . JSDate -> Eff ( locale :: LOCALE | eff ) Number
205
+ getDate :: JSDate -> Effect Number
215
206
getDate dt = runFn2 dateMethodEff " getDate" dt
216
207
217
208
-- | Returns the day of the week for a date, according to the current
218
209
-- | machine's date/time locale.
219
- getDay :: forall eff . JSDate -> Eff ( locale :: LOCALE | eff ) Number
210
+ getDay :: JSDate -> Effect Number
220
211
getDay dt = runFn2 dateMethodEff " getDay" dt
221
212
222
213
-- | Returns the year for a date, according to the current machine's date/time
223
214
-- | locale.
224
- getFullYear :: forall eff . JSDate -> Eff ( locale :: LOCALE | eff ) Number
215
+ getFullYear :: JSDate -> Effect Number
225
216
getFullYear dt = runFn2 dateMethodEff " getFullYear" dt
226
217
227
218
-- | Returns the hour for a date, according to the current machine's date/time
228
219
-- | locale.
229
- getHours :: forall eff . JSDate -> Eff ( locale :: LOCALE | eff ) Number
220
+ getHours :: JSDate -> Effect Number
230
221
getHours dt = runFn2 dateMethodEff " getHours" dt
231
222
232
223
-- | Returns the milliseconds for a date, according to the current machine's
233
224
-- | date/time locale.
234
- getMilliseconds :: forall eff . JSDate -> Eff ( locale :: LOCALE | eff ) Number
225
+ getMilliseconds :: JSDate -> Effect Number
235
226
getMilliseconds dt = runFn2 dateMethodEff " getMilliseconds" dt
236
227
237
228
-- | Returns the minutes for a date, according to the current machine's
238
229
-- | date/time locale.
239
- getMinutes :: forall eff . JSDate -> Eff ( locale :: LOCALE | eff ) Number
230
+ getMinutes :: JSDate -> Effect Number
240
231
getMinutes dt = runFn2 dateMethodEff " getMinutes" dt
241
232
242
233
-- | Returns the month for a date, according to the current machine's
243
234
-- | date/time locale.
244
- getMonth :: forall eff . JSDate -> Eff ( locale :: LOCALE | eff ) Number
235
+ getMonth :: JSDate -> Effect Number
245
236
getMonth dt = runFn2 dateMethodEff " getMonth" dt
246
237
247
238
-- | Returns the seconds for a date, according to the current machine's
248
239
-- | date/time locale.
249
- getSeconds :: forall eff . JSDate -> Eff ( locale :: LOCALE | eff ) Number
240
+ getSeconds :: JSDate -> Effect Number
250
241
getSeconds dt = runFn2 dateMethodEff " getSeconds" dt
251
242
252
243
-- | Returns the time-zone offset for a date, according to the current machine's
253
244
-- | date/time locale.
254
- getTimezoneOffset :: forall eff . JSDate -> Eff ( locale :: LOCALE | eff ) Number
245
+ getTimezoneOffset :: JSDate -> Effect Number
255
246
getTimezoneOffset dt = runFn2 dateMethodEff " getTimezoneOffset" dt
256
247
257
248
-- | Returns the date portion of a date value as a human-readable string.
258
249
toDateString :: JSDate -> String
259
250
toDateString dt = runFn2 dateMethod " toDateString" dt
260
251
261
252
-- | Converts a date value to an ISO 8601 Extended format date string.
262
- toISOString :: forall eff . JSDate -> Eff ( exception :: EXCEPTION | eff ) String
253
+ toISOString :: JSDate -> Effect String
263
254
toISOString dt = runFn2 dateMethodEff " toISOString" dt
264
255
265
256
-- | Returns a string representing for a date value.
0 commit comments