88-- | a `Generic` instance.
99module Data.JSDate
1010 ( JSDate
11- , LOCALE
1211 , readDate
1312 , isValid
1413 , fromDateTime
@@ -48,21 +47,19 @@ module Data.JSDate
4847
4948import Prelude
5049
51- import Control.Monad.Eff (kind Effect , Eff )
52- import Control.Monad.Eff.Exception (EXCEPTION )
53- import Control.Monad.Eff.Now (NOW )
5450import Data.Date as Date
5551import Data.DateTime (DateTime (..), Date )
5652import Data.DateTime as DateTime
5753import Data.DateTime.Instant (Instant )
5854import Data.DateTime.Instant as Instant
5955import Data.Enum (fromEnum )
60- import Data.Foreign (F , Foreign , unsafeReadTagged )
6156import Data.Function.Uncurried (Fn2 , runFn2 )
6257import Data.Int (toNumber )
6358import Data.Maybe (Maybe (..))
6459import Data.Time as Time
6560import Data.Time.Duration (Milliseconds (..))
61+ import Effect (Effect )
62+ import Foreign (F , Foreign , unsafeReadTagged )
6663
6764-- | The type of JavaScript `Date` objects.
6865foreign import data JSDate :: Type
@@ -76,10 +73,6 @@ instance ordJSDate :: Ord JSDate where
7673instance showJSDate :: Show JSDate where
7774 show a = " (fromTime " <> show (getTime a) <> " )"
7875
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-
8376-- | Attempts to read a `Foreign` value as a `JSDate`.
8477readDate :: Foreign -> F JSDate
8578readDate = unsafeReadTagged " Date"
@@ -142,18 +135,17 @@ foreign import jsdate
142135-- | Constructs a new `JSDate` from component values using the current machine's
143136-- | locale. If any of the values are `NaN` the resulting date will be invalid.
144137foreign import jsdateLocal
145- :: forall eff
146- . { year :: Number
138+ :: { year :: Number
147139 , month :: Number
148140 , day :: Number
149141 , hour :: Number
150142 , minute :: Number
151143 , second :: Number
152144 , millisecond :: Number
153145 }
154- -> Eff ( locale :: LOCALE | eff ) JSDate
146+ -> Effect JSDate
155147
156- foreign import dateMethodEff :: forall eff a . Fn2 String JSDate (Eff eff a )
148+ foreign import dateMethodEff :: forall a . Fn2 String JSDate (Effect a )
157149foreign import dateMethod :: forall a . Fn2 String JSDate a
158150
159151-- | 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
163155-- |
164156-- | The `LOCALE` effect is present here as if no time zone is specified in the
165157-- | 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
168159
169160-- | Gets a `JSDate` value for the date and time according to the current
170161-- | machine's clock.
171162-- |
172163-- | 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
175166
176167-- | Returns the date as a number of milliseconds since 1970-01-01 00:00:00 UTC.
177168getTime :: JSDate -> Number
@@ -211,55 +202,55 @@ getUTCSeconds dt = runFn2 dateMethod "getUTCSeconds" dt
211202
212203-- | Returns the day of the month for a date, according to the current
213204-- | machine's date/time locale.
214- getDate :: forall eff . JSDate -> Eff ( locale :: LOCALE | eff ) Number
205+ getDate :: JSDate -> Effect Number
215206getDate dt = runFn2 dateMethodEff " getDate" dt
216207
217208-- | Returns the day of the week for a date, according to the current
218209-- | machine's date/time locale.
219- getDay :: forall eff . JSDate -> Eff ( locale :: LOCALE | eff ) Number
210+ getDay :: JSDate -> Effect Number
220211getDay dt = runFn2 dateMethodEff " getDay" dt
221212
222213-- | Returns the year for a date, according to the current machine's date/time
223214-- | locale.
224- getFullYear :: forall eff . JSDate -> Eff ( locale :: LOCALE | eff ) Number
215+ getFullYear :: JSDate -> Effect Number
225216getFullYear dt = runFn2 dateMethodEff " getFullYear" dt
226217
227218-- | Returns the hour for a date, according to the current machine's date/time
228219-- | locale.
229- getHours :: forall eff . JSDate -> Eff ( locale :: LOCALE | eff ) Number
220+ getHours :: JSDate -> Effect Number
230221getHours dt = runFn2 dateMethodEff " getHours" dt
231222
232223-- | Returns the milliseconds for a date, according to the current machine's
233224-- | date/time locale.
234- getMilliseconds :: forall eff . JSDate -> Eff ( locale :: LOCALE | eff ) Number
225+ getMilliseconds :: JSDate -> Effect Number
235226getMilliseconds dt = runFn2 dateMethodEff " getMilliseconds" dt
236227
237228-- | Returns the minutes for a date, according to the current machine's
238229-- | date/time locale.
239- getMinutes :: forall eff . JSDate -> Eff ( locale :: LOCALE | eff ) Number
230+ getMinutes :: JSDate -> Effect Number
240231getMinutes dt = runFn2 dateMethodEff " getMinutes" dt
241232
242233-- | Returns the month for a date, according to the current machine's
243234-- | date/time locale.
244- getMonth :: forall eff . JSDate -> Eff ( locale :: LOCALE | eff ) Number
235+ getMonth :: JSDate -> Effect Number
245236getMonth dt = runFn2 dateMethodEff " getMonth" dt
246237
247238-- | Returns the seconds for a date, according to the current machine's
248239-- | date/time locale.
249- getSeconds :: forall eff . JSDate -> Eff ( locale :: LOCALE | eff ) Number
240+ getSeconds :: JSDate -> Effect Number
250241getSeconds dt = runFn2 dateMethodEff " getSeconds" dt
251242
252243-- | Returns the time-zone offset for a date, according to the current machine's
253244-- | date/time locale.
254- getTimezoneOffset :: forall eff . JSDate -> Eff ( locale :: LOCALE | eff ) Number
245+ getTimezoneOffset :: JSDate -> Effect Number
255246getTimezoneOffset dt = runFn2 dateMethodEff " getTimezoneOffset" dt
256247
257248-- | Returns the date portion of a date value as a human-readable string.
258249toDateString :: JSDate -> String
259250toDateString dt = runFn2 dateMethod " toDateString" dt
260251
261252-- | 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
263254toISOString dt = runFn2 dateMethodEff " toISOString" dt
264255
265256-- | Returns a string representing for a date value.
0 commit comments