diff options
author | Corey Hulen <corey@hulen.com> | 2017-03-24 23:31:34 -0700 |
---|---|---|
committer | enahum <nahumhbl@gmail.com> | 2017-03-25 03:31:34 -0300 |
commit | 54d3d47daf9190275bbdaf8703b84969a4593451 (patch) | |
tree | 05899b296d0186c1a0da8a540bc486e34ad8eec9 /vendor/golang.org/x/text/currency/common.go | |
parent | 7460302dec7796e01c98264e84bece8169cb6ed9 (diff) | |
download | chat-54d3d47daf9190275bbdaf8703b84969a4593451.tar.gz chat-54d3d47daf9190275bbdaf8703b84969a4593451.tar.bz2 chat-54d3d47daf9190275bbdaf8703b84969a4593451.zip |
PLT-6076 Adding viper libs for config file changes (#5871)
* Adding viper libs for config file changes
* Removing the old fsnotify lib
* updating some missing libs
Diffstat (limited to 'vendor/golang.org/x/text/currency/common.go')
-rw-r--r-- | vendor/golang.org/x/text/currency/common.go | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/vendor/golang.org/x/text/currency/common.go b/vendor/golang.org/x/text/currency/common.go new file mode 100644 index 000000000..250cb8c66 --- /dev/null +++ b/vendor/golang.org/x/text/currency/common.go @@ -0,0 +1,66 @@ +// Code generated by running "go generate" in golang.org/x/text. DO NOT EDIT. + +package currency + +import ( + "time" + + "golang.org/x/text/language" +) + +// This file contains code common to gen.go and the package code. + +const ( + cashShift = 3 + roundMask = 0x7 + + nonTenderBit = 0x8000 +) + +// currencyInfo contains information about a currency. +// bits 0..2: index into roundings for standard rounding +// bits 3..5: index into roundings for cash rounding +type currencyInfo byte + +// roundingType defines the scale (number of fractional decimals) and increments +// in terms of units of size 10^-scale. For example, for scale == 2 and +// increment == 1, the currency is rounded to units of 0.01. +type roundingType struct { + scale, increment uint8 +} + +// roundings contains rounding data for currencies. This struct is +// created by hand as it is very unlikely to change much. +var roundings = [...]roundingType{ + {2, 1}, // default + {0, 1}, + {1, 1}, + {3, 1}, + {4, 1}, + {2, 5}, // cash rounding alternative +} + +// regionToCode returns a 16-bit region code. Only two-letter codes are +// supported. (Three-letter codes are not needed.) +func regionToCode(r language.Region) uint16 { + if s := r.String(); len(s) == 2 { + return uint16(s[0])<<8 | uint16(s[1]) + } + return 0 +} + +func toDate(t time.Time) uint32 { + y := t.Year() + if y == 1 { + return 0 + } + date := uint32(y) << 4 + date |= uint32(t.Month()) + date <<= 5 + date |= uint32(t.Day()) + return date +} + +func fromDate(date uint32) time.Time { + return time.Date(int(date>>9), time.Month((date>>5)&0xf), int(date&0x1f), 0, 0, 0, 0, time.UTC) +} |