Skip to content

Commit

Permalink
release(1.2.0): bump version
Browse files Browse the repository at this point in the history
fix(Hour format): format of %I and %l (upper i and lower L) so that 12 is show not 0. From upstream fix thank you max.
feat(monthList): Added month list, useful for mapping over months.
  • Loading branch information
rluiten committed Jan 11, 2016
1 parent ccdd776 commit 9465db4
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 3 deletions.
2 changes: 1 addition & 1 deletion elm-package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "1.1.0",
"version": "1.2.0",
"summary": "Date Extra library add/subtract/diff/format etc dates.",
"repository": "https://github.com/rluiten/elm-date-extra.git",
"license": "BSD3",
Expand Down
20 changes: 20 additions & 0 deletions src/Date/Core.elm
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
module Date.Core
( monthToInt
, daysInMonth
, monthList
, daysInNextMonth
, daysInPrevMonth
, daysInMonthDate
Expand Down Expand Up @@ -33,6 +34,7 @@ module Date.Core
## Info
@docs monthToInt
@docs daysInMonth
@docs monthList
@docs daysInNextMonth
@docs daysInPrevMonth
@docs daysInMonthDate
Expand Down Expand Up @@ -165,6 +167,24 @@ toTime =
floor << Date.toTime


{-| List of months in order from Jan to Dec. -}
monthList : List Month
monthList =
[ Jan
, Feb
, Mar
, Apr
, May
, Jun
, Jul
, Aug
, Sep
, Oct
, Nov
, Dec
]


{-| Return days in month for year month. -}
daysInMonth : Int -> Month -> Int
daysInMonth year month =
Expand Down
6 changes: 5 additions & 1 deletion src/Date/Format.elm
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,11 @@ formatOffsetStr betweenHoursMinutes offset =
++ (padWith '0' minute)


mod12 h = h % 12
mod12 h =
if h % 12 == 0 then
12
else
h % 12


padWith : Char -> a -> String
Expand Down
18 changes: 17 additions & 1 deletion tests/Date/FormatTests.elm
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import Time exposing (Time)
import Date.Core as Core
import Date.Format as Format
import Date.Config.Config_en_us as English
import Date.Period as DPeriod exposing (Period (Hour))


tests : Test
Expand All @@ -30,13 +31,21 @@ Time : 1407833631116
is : 2014-08-12T18:53:51.116+10:00
is : 2014-08-12T04:53:51.116-04:00
Time : 1407855231116
is : 2014-08-12T14:53:51.116+00:00
is : 2014-08-13T00:53:51.116+10:00
Using floor here to work around bug in Elm 0.16 on Windows
that cant produce this as integer into the javascript source.
-}
aTestTime = floor 1407833631116.0


aTestTime2 = floor 1407855231116.0


formatTest _ =
suite "format tests" <|
List.map runFormatTest formatTestCases
Expand All @@ -56,7 +65,6 @@ formatTestCases =
, ("with %% no space", " %12/08/2014", " %%%d/%m/%Y", aTestTime)
, ("with milliseconds", "2014-08-12 (.116)", "%Y-%m-%d (.%L)", aTestTime)
, ("with milliseconds", "2014-08-12T18:53:51.116", "%Y-%m-%dT%H:%M:%S.%L", aTestTime)

]


Expand Down Expand Up @@ -98,4 +106,12 @@ formatOffsetTestCases =
, ( "get back expected date in utc -12:00", "2014-08-12T20:53:51.116+12:00"
, "%Y-%m-%dT%H:%M:%S.%L%:z", aTestTime, -720
)
, ( "12 hour time %I", "Wednesday, 13 August 2014 12:53:51 AM"
, "%A, %e %B %Y %I:%M:%S %p"
, aTestTime2, -600
)
, ( "12 hour time %l", "Wednesday, 13 August 2014 12:53:51 AM"
, "%A, %e %B %Y %l:%M:%S %p"
, aTestTime2, -600
)
]

0 comments on commit 9465db4

Please sign in to comment.