prg_001.go 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626
  1. package prg_001
  2. import (
  3. "math"
  4. "strconv"
  5. "time"
  6. "github.com/go-playground/locales"
  7. "github.com/go-playground/locales/currency"
  8. )
  9. type prg_001 struct {
  10. locale string
  11. pluralsCardinal []locales.PluralRule
  12. pluralsOrdinal []locales.PluralRule
  13. pluralsRange []locales.PluralRule
  14. decimal string
  15. group string
  16. minus string
  17. percent string
  18. perMille string
  19. timeSeparator string
  20. inifinity string
  21. currencies []string // idx = enum of currency code
  22. currencyPositiveSuffix string
  23. currencyNegativeSuffix string
  24. monthsAbbreviated []string
  25. monthsNarrow []string
  26. monthsWide []string
  27. daysAbbreviated []string
  28. daysNarrow []string
  29. daysShort []string
  30. daysWide []string
  31. periodsAbbreviated []string
  32. periodsNarrow []string
  33. periodsShort []string
  34. periodsWide []string
  35. erasAbbreviated []string
  36. erasNarrow []string
  37. erasWide []string
  38. timezones map[string]string
  39. }
  40. // New returns a new instance of translator for the 'prg_001' locale
  41. func New() locales.Translator {
  42. return &prg_001{
  43. locale: "prg_001",
  44. pluralsCardinal: []locales.PluralRule{1, 2, 6},
  45. pluralsOrdinal: []locales.PluralRule{6},
  46. pluralsRange: nil,
  47. decimal: ",",
  48. group: " ",
  49. minus: "-",
  50. percent: "%",
  51. timeSeparator: ":",
  52. currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNH", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "STN", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"},
  53. currencyPositiveSuffix: " ",
  54. currencyNegativeSuffix: " ",
  55. monthsAbbreviated: []string{"", "rag", "was", "pūl", "sak", "zal", "sīm", "līp", "dag", "sil", "spa", "lap", "sal"},
  56. monthsNarrow: []string{"", "R", "W", "P", "S", "Z", "S", "L", "D", "S", "S", "L", "S"},
  57. monthsWide: []string{"", "rags", "wassarins", "pūlis", "sakkis", "zallaws", "sīmenis", "līpa", "daggis", "sillins", "spallins", "lapkrūtis", "sallaws"},
  58. daysAbbreviated: []string{"nad", "pan", "wis", "pus", "ket", "pēn", "sab"},
  59. daysNarrow: []string{"N", "P", "W", "P", "K", "P", "S"},
  60. daysWide: []string{"nadīli", "panadīli", "wisasīdis", "pussisawaiti", "ketwirtiks", "pēntniks", "sabattika"},
  61. periodsAbbreviated: []string{"AM", "PM"},
  62. periodsWide: []string{"ankstāinan", "pa pussideinan"},
  63. erasAbbreviated: []string{"BC", "AD"},
  64. erasNarrow: []string{"", ""},
  65. erasWide: []string{"", ""},
  66. timezones: map[string]string{"JDT": "JDT", "HEOG": "HEOG", "ACWDT": "ACWDT", "HNEG": "HNEG", "WART": "WART", "VET": "VET", "WAT": "WAT", "COST": "COST", "UYST": "UYST", "AEDT": "AEDT", "HAT": "HAT", "ART": "ART", "GMT": "Greenwich kerdā", "ChST": "ChST", "CST": "Centrālas Amērikas zēimas kerdā", "GFT": "GFT", "CAT": "CAT", "HADT": "HADT", "ARST": "ARST", "WAST": "WAST", "TMT": "TMT", "HAST": "HAST", "AWST": "AWST", "ACDT": "ACDT", "WITA": "WITA", "HENOMX": "HENOMX", "CDT": "Centrālas Amērikas daggas kerdā", "NZST": "NZST", "ECT": "ECT", "SAST": "SAST", "HNPMX": "HNPMX", "JST": "JST", "WARST": "WARST", "HNT": "HNT", "SRT": "SRT", "CLST": "CLST", "COT": "COT", "HEPM": "HEPM", "TMST": "TMST", "MYT": "MYT", "MEZ": "Centrālas Eurōpas zēimas kerdā", "LHDT": "LHDT", "EAT": "EAT", "MST": "Amērikas gārban zēimas kerdā", "AKDT": "AKDT", "EST": "Dēiniskas Amērikas zēimas kerdā", "HEEG": "HEEG", "HNNOMX": "HNNOMX", "GYT": "GYT", "CHADT": "CHADT", "PST": "Pacīfiskas Amērikas zēimas kerdā", "PDT": "Pacīfiskas Amērikas daggas kerdā", "MDT": "Amērikas gārban daggas kerdā", "WEZ": "Wakkariskas Eurōpas zēimas kerdā", "ACWST": "ACWST", "HNPM": "HNPM", "CHAST": "CHAST", "HEPMX": "HEPMX", "WIB": "WIB", "AKST": "AKST", "EDT": "Dēiniskas Amērikas daggas kerdā", "LHST": "LHST", "HECU": "HECU", "AST": "Atlāntiska zēimas kerdā", "HKST": "HKST", "WIT": "WIT", "HNCU": "HNCU", "AEST": "AEST", "BOT": "BOT", "ACST": "ACST", "MESZ": "Centrālas Eurōpas daggas kerdā", "OEZ": "Dēiniskas Eurōpas zēimas kerdā", "NZDT": "NZDT", "SGT": "SGT", "IST": "IST", "BT": "BT", "OESZ": "Dēiniskas Eurōpas daggas kerdā", "UYT": "UYT", "AWDT": "AWDT", "ADT": "Atlāntiska daggas kerdā", "WESZ": "Wakkariskas Eurōpas daggas kerdā", "HNOG": "HNOG", "HKT": "HKT", "∅∅∅": "∅∅∅", "CLT": "CLT"},
  67. }
  68. }
  69. // Locale returns the current translators string locale
  70. func (prg *prg_001) Locale() string {
  71. return prg.locale
  72. }
  73. // PluralsCardinal returns the list of cardinal plural rules associated with 'prg_001'
  74. func (prg *prg_001) PluralsCardinal() []locales.PluralRule {
  75. return prg.pluralsCardinal
  76. }
  77. // PluralsOrdinal returns the list of ordinal plural rules associated with 'prg_001'
  78. func (prg *prg_001) PluralsOrdinal() []locales.PluralRule {
  79. return prg.pluralsOrdinal
  80. }
  81. // PluralsRange returns the list of range plural rules associated with 'prg_001'
  82. func (prg *prg_001) PluralsRange() []locales.PluralRule {
  83. return prg.pluralsRange
  84. }
  85. // CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'prg_001'
  86. func (prg *prg_001) CardinalPluralRule(num float64, v uint64) locales.PluralRule {
  87. n := math.Abs(num)
  88. f := locales.F(n, v)
  89. nMod10 := math.Mod(n, 10)
  90. nMod100 := math.Mod(n, 100)
  91. fMod100 := f % 100
  92. fMod10 := f % 10
  93. if (nMod10 == 0) || (nMod100 >= 11 && nMod100 <= 19) || (v == 2 && fMod100 >= 11 && fMod100 <= 19) {
  94. return locales.PluralRuleZero
  95. } else if (nMod10 == 1 && nMod100 != 11) || (v == 2 && fMod10 == 1 && fMod100 != 11) || (v != 2 && fMod10 == 1) {
  96. return locales.PluralRuleOne
  97. }
  98. return locales.PluralRuleOther
  99. }
  100. // OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'prg_001'
  101. func (prg *prg_001) OrdinalPluralRule(num float64, v uint64) locales.PluralRule {
  102. return locales.PluralRuleOther
  103. }
  104. // RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'prg_001'
  105. func (prg *prg_001) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule {
  106. return locales.PluralRuleUnknown
  107. }
  108. // MonthAbbreviated returns the locales abbreviated month given the 'month' provided
  109. func (prg *prg_001) MonthAbbreviated(month time.Month) string {
  110. return prg.monthsAbbreviated[month]
  111. }
  112. // MonthsAbbreviated returns the locales abbreviated months
  113. func (prg *prg_001) MonthsAbbreviated() []string {
  114. return prg.monthsAbbreviated[1:]
  115. }
  116. // MonthNarrow returns the locales narrow month given the 'month' provided
  117. func (prg *prg_001) MonthNarrow(month time.Month) string {
  118. return prg.monthsNarrow[month]
  119. }
  120. // MonthsNarrow returns the locales narrow months
  121. func (prg *prg_001) MonthsNarrow() []string {
  122. return prg.monthsNarrow[1:]
  123. }
  124. // MonthWide returns the locales wide month given the 'month' provided
  125. func (prg *prg_001) MonthWide(month time.Month) string {
  126. return prg.monthsWide[month]
  127. }
  128. // MonthsWide returns the locales wide months
  129. func (prg *prg_001) MonthsWide() []string {
  130. return prg.monthsWide[1:]
  131. }
  132. // WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided
  133. func (prg *prg_001) WeekdayAbbreviated(weekday time.Weekday) string {
  134. return prg.daysAbbreviated[weekday]
  135. }
  136. // WeekdaysAbbreviated returns the locales abbreviated weekdays
  137. func (prg *prg_001) WeekdaysAbbreviated() []string {
  138. return prg.daysAbbreviated
  139. }
  140. // WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided
  141. func (prg *prg_001) WeekdayNarrow(weekday time.Weekday) string {
  142. return prg.daysNarrow[weekday]
  143. }
  144. // WeekdaysNarrow returns the locales narrow weekdays
  145. func (prg *prg_001) WeekdaysNarrow() []string {
  146. return prg.daysNarrow
  147. }
  148. // WeekdayShort returns the locales short weekday given the 'weekday' provided
  149. func (prg *prg_001) WeekdayShort(weekday time.Weekday) string {
  150. return prg.daysShort[weekday]
  151. }
  152. // WeekdaysShort returns the locales short weekdays
  153. func (prg *prg_001) WeekdaysShort() []string {
  154. return prg.daysShort
  155. }
  156. // WeekdayWide returns the locales wide weekday given the 'weekday' provided
  157. func (prg *prg_001) WeekdayWide(weekday time.Weekday) string {
  158. return prg.daysWide[weekday]
  159. }
  160. // WeekdaysWide returns the locales wide weekdays
  161. func (prg *prg_001) WeekdaysWide() []string {
  162. return prg.daysWide
  163. }
  164. // Decimal returns the decimal point of number
  165. func (prg *prg_001) Decimal() string {
  166. return prg.decimal
  167. }
  168. // Group returns the group of number
  169. func (prg *prg_001) Group() string {
  170. return prg.group
  171. }
  172. // Group returns the minus sign of number
  173. func (prg *prg_001) Minus() string {
  174. return prg.minus
  175. }
  176. // FmtNumber returns 'num' with digits/precision of 'v' for 'prg_001' and handles both Whole and Real numbers based on 'v'
  177. func (prg *prg_001) FmtNumber(num float64, v uint64) string {
  178. s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
  179. l := len(s) + 2 + 2*len(s[:len(s)-int(v)-1])/3
  180. count := 0
  181. inWhole := v == 0
  182. b := make([]byte, 0, l)
  183. for i := len(s) - 1; i >= 0; i-- {
  184. if s[i] == '.' {
  185. b = append(b, prg.decimal[0])
  186. inWhole = true
  187. continue
  188. }
  189. if inWhole {
  190. if count == 3 {
  191. for j := len(prg.group) - 1; j >= 0; j-- {
  192. b = append(b, prg.group[j])
  193. }
  194. count = 1
  195. } else {
  196. count++
  197. }
  198. }
  199. b = append(b, s[i])
  200. }
  201. if num < 0 {
  202. b = append(b, prg.minus[0])
  203. }
  204. // reverse
  205. for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
  206. b[i], b[j] = b[j], b[i]
  207. }
  208. return string(b)
  209. }
  210. // FmtPercent returns 'num' with digits/precision of 'v' for 'prg_001' and handles both Whole and Real numbers based on 'v'
  211. // NOTE: 'num' passed into FmtPercent is assumed to be in percent already
  212. func (prg *prg_001) FmtPercent(num float64, v uint64) string {
  213. s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
  214. l := len(s) + 3
  215. b := make([]byte, 0, l)
  216. for i := len(s) - 1; i >= 0; i-- {
  217. if s[i] == '.' {
  218. b = append(b, prg.decimal[0])
  219. continue
  220. }
  221. b = append(b, s[i])
  222. }
  223. if num < 0 {
  224. b = append(b, prg.minus[0])
  225. }
  226. // reverse
  227. for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
  228. b[i], b[j] = b[j], b[i]
  229. }
  230. b = append(b, prg.percent...)
  231. return string(b)
  232. }
  233. // FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'prg_001'
  234. func (prg *prg_001) FmtCurrency(num float64, v uint64, currency currency.Type) string {
  235. s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
  236. symbol := prg.currencies[currency]
  237. l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3
  238. count := 0
  239. inWhole := v == 0
  240. b := make([]byte, 0, l)
  241. for i := len(s) - 1; i >= 0; i-- {
  242. if s[i] == '.' {
  243. b = append(b, prg.decimal[0])
  244. inWhole = true
  245. continue
  246. }
  247. if inWhole {
  248. if count == 3 {
  249. for j := len(prg.group) - 1; j >= 0; j-- {
  250. b = append(b, prg.group[j])
  251. }
  252. count = 1
  253. } else {
  254. count++
  255. }
  256. }
  257. b = append(b, s[i])
  258. }
  259. if num < 0 {
  260. b = append(b, prg.minus[0])
  261. }
  262. // reverse
  263. for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
  264. b[i], b[j] = b[j], b[i]
  265. }
  266. if int(v) < 2 {
  267. if v == 0 {
  268. b = append(b, prg.decimal...)
  269. }
  270. for i := 0; i < 2-int(v); i++ {
  271. b = append(b, '0')
  272. }
  273. }
  274. b = append(b, prg.currencyPositiveSuffix...)
  275. b = append(b, symbol...)
  276. return string(b)
  277. }
  278. // FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'prg_001'
  279. // in accounting notation.
  280. func (prg *prg_001) FmtAccounting(num float64, v uint64, currency currency.Type) string {
  281. s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
  282. symbol := prg.currencies[currency]
  283. l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3
  284. count := 0
  285. inWhole := v == 0
  286. b := make([]byte, 0, l)
  287. for i := len(s) - 1; i >= 0; i-- {
  288. if s[i] == '.' {
  289. b = append(b, prg.decimal[0])
  290. inWhole = true
  291. continue
  292. }
  293. if inWhole {
  294. if count == 3 {
  295. for j := len(prg.group) - 1; j >= 0; j-- {
  296. b = append(b, prg.group[j])
  297. }
  298. count = 1
  299. } else {
  300. count++
  301. }
  302. }
  303. b = append(b, s[i])
  304. }
  305. if num < 0 {
  306. b = append(b, prg.minus[0])
  307. }
  308. // reverse
  309. for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
  310. b[i], b[j] = b[j], b[i]
  311. }
  312. if int(v) < 2 {
  313. if v == 0 {
  314. b = append(b, prg.decimal...)
  315. }
  316. for i := 0; i < 2-int(v); i++ {
  317. b = append(b, '0')
  318. }
  319. }
  320. if num < 0 {
  321. b = append(b, prg.currencyNegativeSuffix...)
  322. b = append(b, symbol...)
  323. } else {
  324. b = append(b, prg.currencyPositiveSuffix...)
  325. b = append(b, symbol...)
  326. }
  327. return string(b)
  328. }
  329. // FmtDateShort returns the short date representation of 't' for 'prg_001'
  330. func (prg *prg_001) FmtDateShort(t time.Time) string {
  331. b := make([]byte, 0, 32)
  332. if t.Day() < 10 {
  333. b = append(b, '0')
  334. }
  335. b = strconv.AppendInt(b, int64(t.Day()), 10)
  336. b = append(b, []byte{0x2e}...)
  337. if t.Month() < 10 {
  338. b = append(b, '0')
  339. }
  340. b = strconv.AppendInt(b, int64(t.Month()), 10)
  341. b = append(b, []byte{0x2e}...)
  342. if t.Year() > 9 {
  343. b = append(b, strconv.Itoa(t.Year())[2:]...)
  344. } else {
  345. b = append(b, strconv.Itoa(t.Year())[1:]...)
  346. }
  347. return string(b)
  348. }
  349. // FmtDateMedium returns the medium date representation of 't' for 'prg_001'
  350. func (prg *prg_001) FmtDateMedium(t time.Time) string {
  351. b := make([]byte, 0, 32)
  352. if t.Day() < 10 {
  353. b = append(b, '0')
  354. }
  355. b = strconv.AppendInt(b, int64(t.Day()), 10)
  356. b = append(b, []byte{0x2e}...)
  357. if t.Month() < 10 {
  358. b = append(b, '0')
  359. }
  360. b = strconv.AppendInt(b, int64(t.Month()), 10)
  361. b = append(b, []byte{0x20, 0x73, 0x74}...)
  362. b = append(b, []byte{0x2e, 0x20}...)
  363. if t.Year() > 0 {
  364. b = strconv.AppendInt(b, int64(t.Year()), 10)
  365. } else {
  366. b = strconv.AppendInt(b, int64(-t.Year()), 10)
  367. }
  368. return string(b)
  369. }
  370. // FmtDateLong returns the long date representation of 't' for 'prg_001'
  371. func (prg *prg_001) FmtDateLong(t time.Time) string {
  372. b := make([]byte, 0, 32)
  373. if t.Year() > 0 {
  374. b = strconv.AppendInt(b, int64(t.Year()), 10)
  375. } else {
  376. b = strconv.AppendInt(b, int64(-t.Year()), 10)
  377. }
  378. b = append(b, []byte{0x20, 0x6d, 0x65, 0x74, 0x74, 0x61, 0x73}...)
  379. b = append(b, []byte{0x20}...)
  380. b = strconv.AppendInt(b, int64(t.Day()), 10)
  381. b = append(b, []byte{0x2e, 0x20}...)
  382. b = append(b, prg.monthsWide[t.Month()]...)
  383. return string(b)
  384. }
  385. // FmtDateFull returns the full date representation of 't' for 'prg_001'
  386. func (prg *prg_001) FmtDateFull(t time.Time) string {
  387. b := make([]byte, 0, 32)
  388. b = append(b, prg.daysWide[t.Weekday()]...)
  389. b = append(b, []byte{0x2c, 0x20}...)
  390. if t.Year() > 0 {
  391. b = strconv.AppendInt(b, int64(t.Year()), 10)
  392. } else {
  393. b = strconv.AppendInt(b, int64(-t.Year()), 10)
  394. }
  395. b = append(b, []byte{0x20, 0x6d, 0x65, 0x74, 0x74, 0x61, 0x73}...)
  396. b = append(b, []byte{0x20}...)
  397. b = strconv.AppendInt(b, int64(t.Day()), 10)
  398. b = append(b, []byte{0x2e, 0x20}...)
  399. b = append(b, prg.monthsWide[t.Month()]...)
  400. return string(b)
  401. }
  402. // FmtTimeShort returns the short time representation of 't' for 'prg_001'
  403. func (prg *prg_001) FmtTimeShort(t time.Time) string {
  404. b := make([]byte, 0, 32)
  405. if t.Hour() < 10 {
  406. b = append(b, '0')
  407. }
  408. b = strconv.AppendInt(b, int64(t.Hour()), 10)
  409. b = append(b, prg.timeSeparator...)
  410. if t.Minute() < 10 {
  411. b = append(b, '0')
  412. }
  413. b = strconv.AppendInt(b, int64(t.Minute()), 10)
  414. return string(b)
  415. }
  416. // FmtTimeMedium returns the medium time representation of 't' for 'prg_001'
  417. func (prg *prg_001) FmtTimeMedium(t time.Time) string {
  418. b := make([]byte, 0, 32)
  419. if t.Hour() < 10 {
  420. b = append(b, '0')
  421. }
  422. b = strconv.AppendInt(b, int64(t.Hour()), 10)
  423. b = append(b, prg.timeSeparator...)
  424. if t.Minute() < 10 {
  425. b = append(b, '0')
  426. }
  427. b = strconv.AppendInt(b, int64(t.Minute()), 10)
  428. b = append(b, prg.timeSeparator...)
  429. if t.Second() < 10 {
  430. b = append(b, '0')
  431. }
  432. b = strconv.AppendInt(b, int64(t.Second()), 10)
  433. return string(b)
  434. }
  435. // FmtTimeLong returns the long time representation of 't' for 'prg_001'
  436. func (prg *prg_001) FmtTimeLong(t time.Time) string {
  437. b := make([]byte, 0, 32)
  438. if t.Hour() < 10 {
  439. b = append(b, '0')
  440. }
  441. b = strconv.AppendInt(b, int64(t.Hour()), 10)
  442. b = append(b, prg.timeSeparator...)
  443. if t.Minute() < 10 {
  444. b = append(b, '0')
  445. }
  446. b = strconv.AppendInt(b, int64(t.Minute()), 10)
  447. b = append(b, prg.timeSeparator...)
  448. if t.Second() < 10 {
  449. b = append(b, '0')
  450. }
  451. b = strconv.AppendInt(b, int64(t.Second()), 10)
  452. b = append(b, []byte{0x20}...)
  453. tz, _ := t.Zone()
  454. b = append(b, tz...)
  455. return string(b)
  456. }
  457. // FmtTimeFull returns the full time representation of 't' for 'prg_001'
  458. func (prg *prg_001) FmtTimeFull(t time.Time) string {
  459. b := make([]byte, 0, 32)
  460. if t.Hour() < 10 {
  461. b = append(b, '0')
  462. }
  463. b = strconv.AppendInt(b, int64(t.Hour()), 10)
  464. b = append(b, prg.timeSeparator...)
  465. if t.Minute() < 10 {
  466. b = append(b, '0')
  467. }
  468. b = strconv.AppendInt(b, int64(t.Minute()), 10)
  469. b = append(b, prg.timeSeparator...)
  470. if t.Second() < 10 {
  471. b = append(b, '0')
  472. }
  473. b = strconv.AppendInt(b, int64(t.Second()), 10)
  474. b = append(b, []byte{0x20}...)
  475. tz, _ := t.Zone()
  476. if btz, ok := prg.timezones[tz]; ok {
  477. b = append(b, btz...)
  478. } else {
  479. b = append(b, tz...)
  480. }
  481. return string(b)
  482. }