1 // Code generated by running "go generate" in golang.org/x/text. DO NOT EDIT.
8 "golang.org/x/text/language"
11 // This file contains code common to gen.go and the package code.
20 // currencyInfo contains information about a currency.
21 // bits 0..2: index into roundings for standard rounding
22 // bits 3..5: index into roundings for cash rounding
23 type currencyInfo byte
25 // roundingType defines the scale (number of fractional decimals) and increments
26 // in terms of units of size 10^-scale. For example, for scale == 2 and
27 // increment == 1, the currency is rounded to units of 0.01.
28 type roundingType struct {
29 scale, increment uint8
32 // roundings contains rounding data for currencies. This struct is
33 // created by hand as it is very unlikely to change much.
34 var roundings = [...]roundingType{
40 {2, 5}, // cash rounding alternative
43 // regionToCode returns a 16-bit region code. Only two-letter codes are
44 // supported. (Three-letter codes are not needed.)
45 func regionToCode(r language.Region) uint16 {
46 if s := r.String(); len(s) == 2 {
47 return uint16(s[0])<<8 | uint16(s[1])
52 func toDate(t time.Time) uint32 {
57 date := uint32(y) << 4
58 date |= uint32(t.Month())
60 date |= uint32(t.Day())
64 func fromDate(date uint32) time.Time {
65 return time.Date(int(date>>9), time.Month((date>>5)&0xf), int(date&0x1f), 0, 0, 0, 0, time.UTC)