Skip to content

Commit

Permalink
Merge pull request #6 from jacereda/master
Browse files Browse the repository at this point in the history
Updates for 0.11
  • Loading branch information
garyb authored Apr 3, 2017
2 parents 37b55a7 + b8c1ffb commit dc6c13b
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 23 deletions.
14 changes: 7 additions & 7 deletions bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@
"package.json"
],
"dependencies": {
"purescript-datetime": "^2.0.0",
"purescript-exceptions": "^2.0.0",
"purescript-foreign": "^3.0.0",
"purescript-integers": "^2.0.0"
"purescript-datetime": "^3.0.0",
"purescript-exceptions": "^3.0.0",
"purescript-foreign": "^4.0.0",
"purescript-integers": "^3.0.0"
},
"devDependencies": {
"purescript-assert": "^2.0.0",
"purescript-console": "^2.0.0",
"purescript-globals": "^2.0.0"
"purescript-assert": "^3.0.0",
"purescript-console": "^3.0.0",
"purescript-globals": "^3.0.0"
}
}
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
"private": true,
"scripts": {
"clean": "rimraf output && rimraf .pulp-cache",
"build": "jshint src && jscs src && pulp build --censor-lib --strict",
"build": "jshint src && jscs src && pulp build -- --censor-lib --strict",
"test": "pulp test"
},
"devDependencies": {
"jscs": "^2.8.0",
"jshint": "^2.9.1",
"pulp": "^9.0.0",
"purescript-psa": "^0.3.8",
"rimraf": "^2.5.0"
"jscs": "^2.11.0",
"jshint": "^2.9.4",
"pulp": "^11.0.0",
"purescript-psa": "^0.5.0",
"rimraf": "^2.6.1"
}
}
13 changes: 6 additions & 7 deletions src/Data/JSDate.purs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ module Data.JSDate where

import Prelude

import Control.Monad.Eff (Eff)
import Control.Monad.Eff (kind Effect, Eff)
import Control.Monad.Eff.Exception (EXCEPTION)

import Data.Date as Date
Expand All @@ -19,19 +19,18 @@ import Data.DateTime as DateTime
import Data.DateTime.Instant (Instant)
import Data.DateTime.Instant as Instant
import Data.Enum (fromEnum)
import Data.Foreign (unsafeReadTagged)
import Data.Foreign.Class (class IsForeign)
import Data.Foreign (F, Foreign, unsafeReadTagged)
import Data.Function.Uncurried (Fn2, runFn2)
import Data.Int (toNumber)
import Data.Maybe (Maybe(..))
import Data.Time as Time
import Data.Time.Duration (Milliseconds(..))

-- | The type of JavaScript `Date` objects.
foreign import data JSDate :: *
foreign import data JSDate :: Type

instance isForeignJSDate :: IsForeign JSDate where
read = unsafeReadTagged "Date"
readDate :: Foreign -> F JSDate
readDate = unsafeReadTagged "Date"

-- | Checks whether a date value is valid. When a date is invalid, the majority
-- | of the functions return `NaN`, `"Invalid Date"`, or throw an exception.
Expand Down Expand Up @@ -114,7 +113,7 @@ foreign import parse

-- | The effect type used when indicating the current machine's date/time locale
-- | is used in computing a value.
foreign import data LOCALE :: !
foreign import data LOCALE :: Effect

-- | Returns the date as a number of milliseconds since 1970-01-01 00:00:00 UTC.
getTime :: JSDate -> Number
Expand Down
5 changes: 2 additions & 3 deletions test/Test/Main.purs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import Data.DateTime as DT
import Data.Enum (toEnum)
import Data.Either (isRight)
import Data.Foreign (F, Foreign)
import Data.Foreign.Class (read)
import Data.JSDate as JSD
import Data.Maybe (Maybe(..), fromJust)
import Partial.Unsafe (unsafePartial)
Expand All @@ -24,8 +23,8 @@ foreign import myDate :: Foreign
main :: forall eff. Eff (console :: CONSOLE, assert :: ASSERT, locale :: JSD.LOCALE | eff) Unit
main = do

log "Check IsForeign intance will read JS date values..."
assert $ isRight $ runExcept $ read myDate :: F JSD.JSDate
log "Checking that readDate will read JS date values..."
assert $ isRight $ runExcept $ JSD.readDate myDate :: F JSD.JSDate

log "Checking that a UTC date constructed with sensible values is valid..."
assert $ JSD.isValid $ JSD.jsdate defaultDateRecord
Expand Down

0 comments on commit dc6c13b

Please sign in to comment.