Skip to content

Interval formatters #17

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 90 commits into from
Jun 27, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
90 commits
Select commit Hold shift + click to select a range
5350f8c
WIP Interval formatters
safareli Apr 5, 2017
8e275e4
fix number parser in duration
safareli Apr 6, 2017
f574768
update Data.Interval
safareli Apr 6, 2017
620cc40
refactor Duration parser
safareli Apr 6, 2017
b017f50
add is valid iso duration test
safareli Apr 7, 2017
a03b56d
add interval parsers
safareli Apr 7, 2017
de07f5a
extract parsers in seperate module
safareli Apr 13, 2017
f7aaa52
move 'digit' to parser.number
safareli Apr 14, 2017
c628d7c
remove State from unformatParser
safareli Apr 18, 2017
f61ec8c
use weaker hoistParserT
safareli Apr 18, 2017
b7a8b10
use ParserT instead of Parser
safareli Apr 18, 2017
0f8e48d
use more oneOfAs
safareli Apr 18, 2017
579660d
export unformatParser from DateTime; fix interval related parser tests
safareli Apr 19, 2017
018f2de
un-export HasDuration for Duration (live one for IsoDuration only)
safareli Apr 20, 2017
69895b1
add tests for all variation of valid Recurringinterval
safareli Apr 20, 2017
9dcae78
add Eq and Show instance for datetime.FormatterF
safareli Apr 21, 2017
dcb6815
make formatterF parser error a bit more usable
safareli Apr 21, 2017
59fc87d
include error position in error string of parser result
safareli Apr 21, 2017
d826097
use ps-spec and refactor tests to more generative style
safareli Apr 21, 2017
e468816
remove some outdated commets
safareli Apr 21, 2017
a000e17
fix let usage
safareli Apr 24, 2017
0b30548
remove 'Q', 'X', 'W' from restricted chars of placeholder
safareli Apr 24, 2017
7fe10ed
fix failing test
safareli Apr 24, 2017
3667177
make Number.Formatter newtype
safareli Apr 24, 2017
93d1ae4
refactor numeralTests
safareli Apr 24, 2017
9793999
refactor tests
safareli Apr 24, 2017
8e9cbbd
merge Parser/DateTime back into DateTime
safareli Apr 24, 2017
fb92d50
fix warning
safareli Apr 24, 2017
1c8b519
update ps-parser
safareli Apr 24, 2017
7ea8b84
add invalid interval/durations; fix parsing of PT1M
safareli Apr 24, 2017
a937311
update ps-spec
safareli Apr 25, 2017
87f4e33
update ps-parser
safareli Apr 25, 2017
4c6be25
remove Has{Duration,Date} class; add EOF to runP
safareli Apr 25, 2017
6fd728f
remove unused ps-debug
safareli Apr 25, 2017
e60805c
add format function; refactor interval tests
safareli Apr 25, 2017
3836872
Merge branch 'master' into interval
safareli Apr 25, 2017
7dd6e1b
use forAll for testing
safareli Apr 25, 2017
6e7a1ba
refactor padDoubleDigit
safareli Apr 26, 2017
4a88e5a
add resoliutions
safareli Apr 26, 2017
cd3365c
fix resolution
safareli Apr 26, 2017
8f14790
add space to formatterFShow
safareli Apr 26, 2017
5a66f6e
use <?>
safareli Apr 26, 2017
2ed021e
refactor digit parsing
safareli Apr 26, 2017
13d300d
remove unneeded range checks
safareli Apr 26, 2017
758d9ba
reorder parseInt validations so that we don't need parens
safareli Apr 26, 2017
9862490
add noValidate
safareli Apr 26, 2017
ec0d462
refactor datetime parser
safareli Apr 26, 2017
51eb72e
don't use MonadState with P.ParserT
safareli Apr 26, 2017
b2ecdd7
use readFloat in parseFractional
safareli Apr 26, 2017
68baf7f
refactor parseMaybeInteger
safareli Apr 26, 2017
5ebbb31
refactor unEither
safareli Apr 26, 2017
6bcd941
refactor foldFoldableMaybe
safareli Apr 26, 2017
03b3536
fix where indentation
safareli Apr 26, 2017
58eebcd
more where indentation
safareli Apr 26, 2017
1b7268b
add Newtype instance for Number.Formatter; derive Eq
safareli Apr 26, 2017
ae1a83b
derive Eq for DateTime.FormatterF
safareli Apr 26, 2017
acf9452
derive Functor for DateTime.FormatterF
safareli Apr 26, 2017
56dda42
replace -> with →
safareli Apr 26, 2017
01b6242
replace :: with ∷
safareli Apr 26, 2017
bd57886
replace <- with ←
safareli Apr 26, 2017
a2e6828
replace => with ⇒
safareli Apr 26, 2017
fb169ac
replace forall with ∀
safareli Apr 26, 2017
f02803c
replace more => with ⇒
safareli Apr 26, 2017
b304aa4
use monoid instance of ReaderT in parser validators
safareli Apr 27, 2017
c1a111a
change Formatter to List FormatterCommands
safareli Apr 27, 2017
ea5f038
unflip
safareli Apr 27, 2017
2f61c92
remove unused
safareli May 1, 2017
563c15d
fix parsing formats like 'HHmm' (without seperators)
safareli May 1, 2017
533b2a0
fix build
safareli May 2, 2017
f74ba26
fix 'SS' and 'S' parsing
safareli May 3, 2017
7dfe464
export printFormatterCommand
safareli May 8, 2017
3067b97
update ps-datetime
safareli May 16, 2017
cfcec22
remove unused
safareli May 16, 2017
56d0d38
use published version of purescript-lists
safareli Jun 2, 2017
b74780b
update ps-transformers
safareli Jun 4, 2017
c2cdff6
Merge branch 'master' into interval
safareli Jun 23, 2017
f6601fd
use unsafePartial instead of unsafePartialBecause
safareli Jun 23, 2017
1b4351e
update datetime
safareli Jun 23, 2017
a1338cf
fix number test
safareli Jun 26, 2017
30255e4
remove some old todos
safareli Jun 26, 2017
ce390b3
use released version of ps-datetime
safareli Jun 26, 2017
63d9283
fix first char case in errors.
safareli Jun 26, 2017
06db0d1
add todo on negative numbers
safareli Jun 26, 2017
c0e35f0
fix lifts
safareli Jun 26, 2017
fdfa05e
fix arrows and forall
safareli Jun 27, 2017
d46e986
fix double let
safareli Jun 27, 2017
f97e811
use lift2 and sort imports
safareli Jun 27, 2017
94f64d4
remove outdated anotation
safareli Jun 27, 2017
0add9bc
let on next line
safareli Jun 27, 2017
44c39eb
rename notEmpty to failIfEmpty
safareli Jun 27, 2017
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
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,23 @@ Formatter has following properties

Number will be padded with zeros to have at least this number of leading zeros.
This doesn't restrict number to have more digits then leading zeros in format string.
+ `0000.0` will show 4 digits: `12 -> "0012.0"`, `1234 -> "1234.0"`
+ `00.0` will show only 2 digits : `12 -> "12.0"`, `1234 -> "1234.0"`
+ `0000.0` will show 4 digits: `12 "0012.0"`, `1234 "1234.0"`
+ `00.0` will show only 2 digits : `12 "12.0"`, `1234 "1234.0"`

Number of digits after dot is set by number of trailing zeros (note the rounding)
+ `0.000` will show 3 digits: `0.12345 -> "0.123"`, `12.98765 -> "12.988"`
+ `0.0` will show only 1 digit: `0.12345 -> "0.1"`, `12.98765 -> "13.0"`
+ `0.000` will show 3 digits: `0.12345 "0.123"`, `12.98765 "12.988"`
+ `0.0` will show only 1 digit: `0.12345 "0.1"`, `12.98765 "13.0"`

If number is lesser then zero `-` is always printed. Otherwise you could specify `+` in format string
+ `+0`: `12.0 -> "+12"`, `-34.8 -> "-35"`
+ `0`: `12.0 -> "12"`, `-34.8 -> "-35"`
+ `+0`: `12.0 "+12"`, `-34.8 "-35"`
+ `0`: `12.0 "12"`, `-34.8 "-35"`

Thousands separator is specified as `,0` please note that this `0` isn't counted as leading.
+ `00,0`: `1234567890 -> "1,234,567,890.0", `1 -> "1.0"`
+ `00,0`: `1234567890 "1,234,567,890.0", `1 "1.0"`

For abbreviation one could use `a` flag. In general it tries to find the closest power of thousand and
then use formatter to result of division of input number and that power.
+ `0a`: `1234567 -> "1M"`, `1 -> "1"`
+ `0a`: `1234567 "1M"`, `1 "1"`

## Date/Time formatters

Expand Down
12 changes: 9 additions & 3 deletions bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,20 @@
],
"dependencies": {
"purescript-prelude": "^3.0.0",
"purescript-parsing": "^4.0.0",
"purescript-parsing": "^4.2.1",
"purescript-fixed-points": "^4.0.0",
"purescript-datetime": "^3.0.0"
"purescript-datetime": "^v3.3.0",
"purescript-transformers": "^3.4.0",
"purescript-lists": "^4.3.0",
"purescript-generics-rep": "^5.0.0"
},
"devDependencies": {
"purescript-aff": "^3.0.0",
"purescript-console": "^3.0.0",
"purescript-psci-support": "^3.0.0",
"purescript-debug": "^3.0.0"
"purescript-spec": "^0.14.0"
},
"resolutions": {
"purescript-datetime": "interval"
}
}
Loading