Bjørn Erik Pedersen
f31dc0aaab
Adjust timezone logic
...
This commit adjusts the previous commit re. the new `ToTimeInDefaultLocationE` and related functions.
The functional change is that we don't default to any location if not provided from the caller.
This is in line with how `ToTime` worked before we started this, and even if the default behaviour may look weird in some cases, it will not break anything.
Most applications will want to use the new *InDefaultLocation functions and decide which default location to use:
```go
loc := time.Local
if config.Location != "" {
loc = time.LoadLocation(config.Location)
}
t, err := StringToDateInDefaultLocation("2019-01-01", loc)
```
This commit also configure Travis to test on OSX and Windows in addition to Linux.
2019-05-31 17:19:31 +02:00
Heewa Barfchin
b1aa5f0c52
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.
2019-05-31 11:32:53 +02:00
Bjørn Erik Pedersen
8c9545af88
Fix Travis build
2018-10-25 00:59:28 +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
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
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
2c719d95d6
Fix gofmt and golint errors
2017-03-03 16:44:53 +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
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
27b586b42e
Add support for the other html template types
2016-03-14 20:20:28 +01:00
Matt Keller
0eed3d1b35
Add a ToInt64() and necessary plumbing
2016-03-14 20:19:19 +01:00
Matt Keller
7c7add0129
Add ability to cast int64's to strings
...
Resolves #18
2016-03-14 20:18:57 +01:00
Cyrill Schumacher
ee7b3e0353
Add bool case to ToStringE
2015-12-18 08:52:19 -05:00
Tyler Power
6770a32f65
Add int64 and float64 type coercion in ToDuration
2015-11-23 09:21:13 +13:00
jackspirou
d7ba796a5f
adding unit tests for ToStringMapString and ToStringMapStringSlice methods
2015-08-03 12:36:12 -04:00
bep
893a4154d1
Add support for template.URL
...
Fixes #13
2015-08-03 12:35:39 -04:00
bep
4d07383ffe
Make ToIntSliceE more flexible
...
Now it accepts any slice or array type that contains a type supported by ToIntE.
[close #12 ]
2015-05-08 15:17:42 -04:00
bep
2c4fdb5416
Add ToIntSlice
2015-02-24 12:08:11 -05:00
spf13
2318c5caf2
Add support for pointers to basic types
2015-01-01 00:23:46 -05:00
spf13
421411cf35
Add proper support for error -> string and Stringer -> string.
2015-01-01 00:18:13 -05:00
bep
0a58809502
Add support for HTML to String
2014-12-09 09:02:27 -05:00
Steve Francia
fb4a45a374
Merge pull request #5 from txgruppi/master
...
Updated to return bool false only for zero
2014-12-03 08:50:16 +01:00
txgruppi
ed6dd5ade6
Updated to return bool false only for zero
2014-11-19 18:08:49 +00:00
bep
bbe2d4b35d
Add ToStringMapBool
...
ToStringMapBool is useful for a map of flags in a configuration file.
2014-11-06 11:32:02 +01:00
Romain Baugue
075c75a269
Added ToBool case for string, and added ToBool test cases
2014-09-08 12:15:23 -04:00
spf13
5a9b0d4cc3
adding Int to Float. Testing for float
2014-04-07 11:48:02 -04:00
spf13
559d57776b
Writing the README. Handling a few more cases, adding more tests.
2014-04-05 15:18:23 -04:00
spf13
6796452c69
initial commit of library & tests
2014-04-05 01:21:52 -04:00