Commit Graph

85 Commits

Author SHA1 Message Date
re 52f77be4c4 repo fixes 2022-12-12 17:49:39 +03:00
Bjørn Erik Pedersen 2b0eb0f724 Misc number fixes
* Allow strings/json.Number with just zeroes after the decmial point to be converted to integer`
* Allow nil in ToFloat*
* Remove some test duplication
* replace testify with quicktest
* Enable integer and float conversion of time.Weekday values

Fixes #139
Fixes #141
2022-05-11 15:55:47 +02:00
Bjørn Erik Pedersen 36a7d5b5b8 github: Update Go versions in matrix 2022-05-11 15:55:47 +02:00
yveshield 408043c8fa Add support for json.Number
Closes #115
Closes #61
2022-05-11 15:55:47 +02:00
Bjørn Erik Pedersen b481d74679
Add a simple ToInt benchmark 2022-05-11 13:07:20 +02:00
Kento Tsuji 88075729b0
Fix date parse for "2016-03-06 15:28:01 +0900" 2021-08-15 19:48:01 +02:00
Bjørn Erik Pedersen 3f42935ca9
github: Also run tests on Windows 2021-07-27 13:32:42 +02:00
Bjørn Erik Pedersen 02aebd9419
Update README.md 2021-07-27 13:28:33 +02:00
Bjørn Erik Pedersen a9f3cbf098
Remove .travis.yml
Use GitHub actions instead.
2021-07-27 13:24:54 +02:00
Bjørn Erik Pedersen 57c98fb578
Create go.yml 2021-07-27 13:23:44 +02:00
Bjørn Erik Pedersen 22b2b540ce
Adjust timezone logic 2021-07-27 13:05:07 +02:00
Heewa Barfchin e4dda5f5f1
Add ToTimeInDefaultLocation/E
Go's time parsing uses UTC when the format doesn't have a tiemzone, and
has even weirder behavior when it has a zone name but no numeric offset.
A caller to `cast.ToTime` won't know if the returned time was explicitly
in UTC, or defaulted there, so the caller cannot fix it. These new
functions allow a user to supply a different timezone to default to,
with nil using the local zone.
2021-07-27 13:05:07 +02:00
Bjørn Erik Pedersen c3e59ced67
travis: Bump Go versions 2021-07-27 13:03:57 +02:00
Paco Preciado Mendoza 8d17101741
Convert error slice to string slice
* feat: added test case for error slice to parse to string

* feat: added handler to convert an error slice to string slice
2020-07-23 23:45:38 +02:00
zheng 580a25aa7d feat: updating ToStringSliceE to support some other slices 2020-07-10 19:32:20 +02:00
K4rian 1ffadf5510 Fix uint, uint8, uint16, uint32 and uint64 conversion in ToStringE function. 2019-12-18 08:28:14 +01:00
Bjørn Erik Pedersen c01685bb84 travis: Only check gofmt on Go 1.12 2019-05-31 11:32:28 +02:00
Bjørn Erik Pedersen a924560ecf
travis: Add Go 1.12 2019-05-30 20:38:32 +02:00
Bjørn Erik Pedersen 8c9545af88 Fix Travis build 2018-10-25 00:59:28 +02:00
Bjørn Erik Pedersen 76b6d6c500
Add go.mod 2018-10-24 20:03:41 +02:00
Bjørn Erik Pedersen 97e58d71a3
Update Travis config 2018-10-24 20:02:32 +02:00
Theofanis Despoudis 4dd38b8b57 Add support for map of int64 and map of int 2018-10-24 20:00:14 +02:00
Ben Orchard efb632f0f6 tests: +date tests for RFC3339 no TZ colon cases 2018-10-21 23:25:45 +02:00
Ben Orchard 8934aa3ddd StringToDate: +more RFC3339 forms without TZ colon
Adds a form to handle the common format `strftime("%FT%T%z")`, which
omits the (optional) colon from the timezone. Also adds a matching
T-omitted form.
2018-10-21 23:25:45 +02:00
Xavier Vello 8965335b8c Add TestToDurationSliceE cases to reach 100% coverage 2018-02-14 18:49:49 +01:00
Xavier Vello 9ebc15c905 Add support for maps defined as a json string 2018-02-14 18:49:49 +01:00
Roman Volosatovs acbeb36b90 Add ToDurationSlice() 2017-04-13 11:15:03 +02:00
Cameron Moore ce135a4ebe Add Travis CI 2017-03-04 12:22:48 +01:00
Cameron Moore 816e3433fe Small simplifications 2017-03-04 12:22:30 +01:00
Cameron Moore 1ad7d3c5ed Use single defined error for negatives 2017-03-03 22:17:07 +01:00
Cameron Moore 758cd85768 Error on unsigned conversions of negative values 2017-03-03 22:17:07 +01:00
Cameron Moore d37435d953 Add additional type conversions
Adds float32, uint, uint64, uint32, uint16, and uint8 throughout.

Fixes #33
2017-03-03 22:17:07 +01:00
Cameron Moore df9611b942 Refactor tests to get full coverage
Test coverage goes from 75.6% to 100%
2017-03-03 19:55:50 +01:00
Cameron Moore 4f1683a224 Update and standardize error messages 2017-03-03 18:07:04 +01:00
Cameron Moore 1dfd38810f Fix issues found by gosimple 2017-03-03 17:34:16 +01:00
Cameron Moore e71c5a68f1 Update godoc comments 2017-03-03 16:45:07 +01:00
Cameron Moore 2c719d95d6 Fix gofmt and golint errors 2017-03-03 16:44:53 +01:00
Cameron Moore 55be5581bd Add godoc and report card badges to README 2017-03-03 15:55:07 +01:00
Cameron Moore 10b6280cf2 Add Makefile 2017-03-03 15:54:19 +01:00
chyeh e4f8127058 Add `ToInt8`, `ToInt16` and `ToInt32` 2017-03-03 15:54:08 +01:00
Cameron Moore f820543c35 Fix regression in StringToDate
In commit d1139ba, I removed a date format for "RFC3339 without T" that
I misidentified as a reduntant format.  This commit adds it back with a
test.
2017-02-21 16:23:02 +01:00
Cameron Moore d1139bab1c Add missing time formats and tests
Add missing time formats, remove duplicate formats, and test all
supported formats.
2017-01-28 19:09:31 +07:00
Cameron Moore 56a7ecbeb1 Add Unix epoch support to ToTimeE 2016-12-25 13:56:48 +01:00
emacsist 24b6558033 Add "yyyy-MM-dd HH:mm:ss" string format 2016-11-16 02:33:54 +01:00
Bjørn Erik Pedersen 2580bc98dc Remove expensive TRACE logging
```
benchmark              old ns/op     new ns/op     delta
BenchmarkTooBool-4     2671          67.8          -97.46%

benchmark              old allocs     new allocs     delta
BenchmarkTooBool-4     3              1              -66.67%

benchmark              old bytes     new bytes     delta
BenchmarkTooBool-4     49            1             -97.96%
```
2016-09-26 10:42:49 +02:00
Bjørn Erik Pedersen 7c3adfba29 Add benchmark for ToBool
```
BenchmarkTooBool-4   	  500000	      2781 ns/op	      49 B/op	       3 allocs/op
```
2016-09-26 10:25:08 +02:00
M@ 60e7a69a42 Add ToBoolSlice()
Fixes #1
2016-09-19 22:26:41 +02:00
Chih-Hung Yeh fa673d63c1 Fixe `ToDurationE()`
It used to return zero valeus in some cases. The details are described
in [this issue](https://github.com/spf13/viper/issues/203). More cases
were also added in the unit test `TestToDuration()`
2016-09-19 22:24:24 +02:00
Feng 4532b05430 FIx ToStringMapStringSliceE
* Update caste.go

bug fix

json config, for example:
{ "test" : ["abc", "123"] }

* update test
2016-09-19 22:22:46 +02:00
Bjørn Erik Pedersen e31f36ffc9 Log the To* invocations as TRACE
It gets very chatty at DEBUG.
2016-07-30 11:20:37 +02:00