Skip to content

Drop math; update Math imports #94

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ New features:
Bugfixes:

Other improvements:
- Drop deprecated `math` dependency; update imports (#94 by @JordanMartinez)

## [v5.0.2](https://github.com/purescript/purescript-datetime/releases/tag/v5.0.2) - 2021-04-19

Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@
"purescript-gen": "master",
"purescript-integers": "master",
"purescript-lists": "master",
"purescript-math": "master",
"purescript-maybe": "master",
"purescript-newtype": "master",
"purescript-numbers": "master",
"purescript-ordered-collections": "master",
"purescript-partial": "master",
"purescript-prelude": "master",
Expand Down
6 changes: 3 additions & 3 deletions src/Data/Interval/Duration/Iso.purs
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ import Data.List (List(..), reverse, span, null)
import Data.List.NonEmpty (fromList)
import Data.List.Types (NonEmptyList)
import Data.Map as Map
import Data.Number as Number
import Data.Maybe (Maybe(..), isJust)
import Data.Monoid.Additive (Additive(..))
import Data.Newtype (unwrap)
import Data.Tuple (Tuple(..), snd)
import Math as Math

newtype IsoDuration = IsoDuration Duration

Expand Down Expand Up @@ -89,8 +89,8 @@ checkFractionalUse {asList} = case _.rest (span (snd >>> not isFractional) asLis
Cons (Tuple c _) rest | checkRest rest -> pure (InvalidFractionalUse c)
_ -> empty
where
isFractional a = Math.floor a /= a
checkRest rest = unwrap (foldMap (snd >>> Math.abs >>> Additive) rest) > 0.0
isFractional a = Number.floor a /= a
checkRest rest = unwrap (foldMap (snd >>> Number.abs >>> Additive) rest) > 0.0

checkNegativeValues :: CheckEnv -> List Error
checkNegativeValues {asList} = flip foldMap asList \(Tuple c num) ->
Expand Down
10 changes: 5 additions & 5 deletions src/Data/Time.purs
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ import Prelude
import Data.Enum (fromEnum, toEnum)
import Data.Int as Int
import Data.Maybe (fromJust)
import Data.Number as Number
import Data.Newtype (unwrap)
import Data.Time.Component (Hour, Millisecond, Minute, Second)
import Data.Time.Duration (class Duration, Days(..), Milliseconds(..), fromDuration, negateDuration, toDuration)
import Data.Tuple (Tuple(..))
import Math as Math
import Partial.Unsafe (unsafePartial)

data Time = Time Hour Minute Second Millisecond
Expand Down Expand Up @@ -77,7 +77,7 @@ adjust d t =
d' = fromDuration d
tLength = timeToMillis t
dayLength = 86400000.0
wholeDays = Days $ Math.floor (unwrap d' / dayLength)
wholeDays = Days $ Number.floor (unwrap d' / dayLength)
msAdjust = d' <> negateDuration (fromDuration wholeDays)
msAdjusted = tLength <> msAdjust
wrap = if msAdjusted > maxTime then 1.0 else if msAdjusted < minTime then -1.0 else 0.0
Expand Down Expand Up @@ -105,9 +105,9 @@ millisToTime (Milliseconds ms') =
hourLength = 3600000.0
minuteLength = 60000.0
secondLength = 1000.0
hours = Math.floor (ms' / hourLength)
minutes = Math.floor ((ms' - hours * hourLength) / minuteLength)
seconds = Math.floor ((ms' - (hours * hourLength + minutes * minuteLength)) / secondLength)
hours = Number.floor (ms' / hourLength)
minutes = Number.floor ((ms' - hours * hourLength) / minuteLength)
seconds = Number.floor ((ms' - (hours * hourLength + minutes * minuteLength)) / secondLength)
milliseconds = ms' - (hours * hourLength + minutes * minuteLength + seconds * secondLength)
in
unsafePartial fromJust $
Expand Down
2 changes: 1 addition & 1 deletion test/Test/Main.purs
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ import Data.Interval as Interval
import Data.Interval.Duration.Iso as IsoDuration
import Data.Maybe (Maybe(..), fromJust)
import Data.Newtype (over, unwrap)
import Data.Number (floor)
import Data.Time as Time
import Data.Time.Duration as Duration
import Data.Tuple (Tuple(..), snd)
import Math (floor)
import Partial.Unsafe (unsafePartial)
import Test.Assert (assert)
import Type.Proxy (Proxy(..))
Expand Down