fil_PH.go 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660
  1. package fil_PH
  2. import (
  3. "math"
  4. "strconv"
  5. "time"
  6. "github.com/go-playground/locales"
  7. "github.com/go-playground/locales/currency"
  8. )
  9. type fil_PH 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. currencyNegativePrefix 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 'fil_PH' locale
  41. func New() locales.Translator {
  42. return &fil_PH{
  43. locale: "fil_PH",
  44. pluralsCardinal: []locales.PluralRule{2, 6},
  45. pluralsOrdinal: []locales.PluralRule{2, 6},
  46. pluralsRange: []locales.PluralRule{2, 6},
  47. decimal: ".",
  48. group: ",",
  49. minus: "-",
  50. percent: "%",
  51. perMille: "‰",
  52. timeSeparator: ":",
  53. inifinity: "∞",
  54. 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"},
  55. currencyNegativePrefix: "(",
  56. currencyNegativeSuffix: ")",
  57. monthsAbbreviated: []string{"", "Ene", "Peb", "Mar", "Abr", "May", "Hun", "Hul", "Ago", "Set", "Okt", "Nob", "Dis"},
  58. monthsNarrow: []string{"", "Ene", "Peb", "Mar", "Abr", "May", "Hun", "Hul", "Ago", "Set", "Okt", "Nob", "Dis"},
  59. monthsWide: []string{"", "Enero", "Pebrero", "Marso", "Abril", "Mayo", "Hunyo", "Hulyo", "Agosto", "Setyembre", "Oktubre", "Nobyembre", "Disyembre"},
  60. daysAbbreviated: []string{"Lin", "Lun", "Mar", "Miy", "Huw", "Biy", "Sab"},
  61. daysNarrow: []string{"Lin", "Lun", "Mar", "Miy", "Huw", "Biy", "Sab"},
  62. daysShort: []string{"Li", "Lu", "Ma", "Mi", "Hu", "Bi", "Sa"},
  63. daysWide: []string{"Linggo", "Lunes", "Martes", "Miyerkules", "Huwebes", "Biyernes", "Sabado"},
  64. periodsAbbreviated: []string{"AM", "PM"},
  65. periodsNarrow: []string{"am", "pm"},
  66. periodsWide: []string{"AM", "PM"},
  67. erasAbbreviated: []string{"BC", "AD"},
  68. erasNarrow: []string{"", ""},
  69. erasWide: []string{"Before Christ", "Anno Domini"},
  70. timezones: map[string]string{"EAT": "Oras sa Silangang Africa", "TMST": "Oras sa Tag-init ng Turkmenistan", "COT": "Standard na Oras sa Colombia", "BT": "Oras sa Bhutan", "SGT": "Standard na Oras sa Singapore", "ECT": "Oras sa Ecuador", "ACDT": "Daylight Time sa Gitnang Australya", "WART": "Standard na Oras sa Kanlurang Argentina", "GFT": "Oras sa French Guiana", "ACWST": "Standard Time ng Gitnang Kanluran ng Australya", "ACWDT": "Daylight Time sa Gitnang Kanlurang Australya", "HEEG": "Oras sa Tag-init ng Silangang Greenland", "CST": "Sentral na Karaniwang Oras", "CDT": "Sentral na Daylight Time", "AWST": "Standard na Oras sa Kanlurang Australya", "ADT": "Daylight Time sa Atlantiko", "VET": "Oras sa Venezuela", "CHADT": "Daylight Time sa Chatham", "AST": "Standard na Oras sa Atlantiko", "MDT": "Daylight Time sa Bundok", "HNT": "Standard na Oras sa Newfoundland", "HECU": "Daylight Time sa Cuba", "∅∅∅": "Oras sa Tag-init ng Brasilia", "EST": "Eastern na Standard na Oras", "CLT": "Standard na Oras sa Chile", "ARST": "Oras sa Tag-init ng Argentina", "AKST": "Standard na Oras sa Alaska", "MESZ": "Oras sa Tag-init ng Gitnang Europe", "TMT": "Standard na Oras sa Turkmenistan", "UYST": "Oras sa Tag-init ng Uruguay", "PST": "Standard na Oras sa Pasipiko", "MST": "Standard na Oras sa Bundok", "WAT": "Standard na Oras sa Kanlurang Africa", "NZDT": "Daylight Time sa New Zealand", "OESZ": "Oras sa Tag-init ng Silangang Europe", "LHST": "Standard na Oras sa Lord Howe", "HEPM": "Daylight Time sa Saint Pierre & Miquelon", "SRT": "Oras sa Suriname", "PDT": "Daylight Time sa Pasipiko", "AEST": "Standard na Oras sa Silangang Australya", "WIB": "Oras sa Kanlurang Indonesia", "JST": "Standard na Oras sa Japan", "MYT": "Oras sa Malaysia", "HAST": "Standard na Oras sa Hawaii-Aleutian", "CHAST": "Standard na Oras sa Chatham", "AKDT": "Daylight Time sa Alaska", "EDT": "Eastern Daylight Time", "HNEG": "Standard na Oras sa Silangang Greenland", "HKT": "Standard na Oras sa Hong Kong", "MEZ": "Standard na Oras sa Gitnang Europe", "COST": "Oras sa Tag-init ng Colombia", "HNCU": "Standard na Oras sa Cuba", "HNPMX": "Standard na Oras sa Pasipiko ng Mexico", "HEPMX": "Daylight Time sa Pasipiko ng Mexico", "WESZ": "Oras sa Tag-init ng Kanlurang Europe", "JDT": "Daylight Time sa Japan", "ChST": "Standard na Oras sa Chamorro", "AEDT": "Daylight Time sa Silangang Australya", "HENOMX": "Daylight Time sa Hilagang-kanlurang Mexico", "CAT": "Oras sa Gitnang Africa", "CLST": "Oras sa Tag-init ng Chile", "ART": "Standard na Oras sa Argentina", "GYT": "Oras sa Guyana", "SAST": "Oras sa Timog Africa", "WEZ": "Standard na Oras sa Kanlurang Europe", "HNPM": "Standard na Oras sa Saint Pierre & Miquelon", "HNNOMX": "Standard na Oras sa Hilagang-kanlurang Mexico", "UYT": "Standard na Oras sa Uruguay", "ACST": "Standard na Oras sa Gitnang Australya", "HEOG": "Oras sa Tag-init ng Kanlurang Greenland", "HKST": "Oras sa Tag-init ng Hong Kong", "OEZ": "Standard na Oras sa Silangang Europe", "BOT": "Oras sa Bolivia", "WARST": "Oras sa Tag-init ng Kanlurang Argentina", "HADT": "Oras sa Tag-init ng Hawaii-Aleutian", "AWDT": "Daylight Time sa Kanlurang Australya", "LHDT": "Daylight Time sa Lorde Howe", "HAT": "Daylight Time sa Newfoundland", "WIT": "Oras sa Silangang Indonesia", "WITA": "Oras sa Gitnang Indonesia", "GMT": "Greenwich Mean Time", "WAST": "Oras sa Tag-init ng Kanlurang Africa", "NZST": "Standard na Oras sa New Zealand", "HNOG": "Standard na Oras sa Kanlurang Greenland", "IST": "Standard na Oras sa Bhutan"},
  71. }
  72. }
  73. // Locale returns the current translators string locale
  74. func (fil *fil_PH) Locale() string {
  75. return fil.locale
  76. }
  77. // PluralsCardinal returns the list of cardinal plural rules associated with 'fil_PH'
  78. func (fil *fil_PH) PluralsCardinal() []locales.PluralRule {
  79. return fil.pluralsCardinal
  80. }
  81. // PluralsOrdinal returns the list of ordinal plural rules associated with 'fil_PH'
  82. func (fil *fil_PH) PluralsOrdinal() []locales.PluralRule {
  83. return fil.pluralsOrdinal
  84. }
  85. // PluralsRange returns the list of range plural rules associated with 'fil_PH'
  86. func (fil *fil_PH) PluralsRange() []locales.PluralRule {
  87. return fil.pluralsRange
  88. }
  89. // CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'fil_PH'
  90. func (fil *fil_PH) CardinalPluralRule(num float64, v uint64) locales.PluralRule {
  91. n := math.Abs(num)
  92. i := int64(n)
  93. f := locales.F(n, v)
  94. iMod10 := i % 10
  95. fMod10 := f % 10
  96. if (v == 0 && (i == 1 || i == 2 || i == 3)) || (v == 0 && (iMod10 != 4 && iMod10 != 6 && iMod10 != 9)) || (v != 0 && (fMod10 != 4 && fMod10 != 6 && fMod10 != 9)) {
  97. return locales.PluralRuleOne
  98. }
  99. return locales.PluralRuleOther
  100. }
  101. // OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'fil_PH'
  102. func (fil *fil_PH) OrdinalPluralRule(num float64, v uint64) locales.PluralRule {
  103. n := math.Abs(num)
  104. if n == 1 {
  105. return locales.PluralRuleOne
  106. }
  107. return locales.PluralRuleOther
  108. }
  109. // RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'fil_PH'
  110. func (fil *fil_PH) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule {
  111. start := fil.CardinalPluralRule(num1, v1)
  112. end := fil.CardinalPluralRule(num2, v2)
  113. if start == locales.PluralRuleOne && end == locales.PluralRuleOne {
  114. return locales.PluralRuleOne
  115. } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther {
  116. return locales.PluralRuleOther
  117. } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne {
  118. return locales.PluralRuleOne
  119. }
  120. return locales.PluralRuleOther
  121. }
  122. // MonthAbbreviated returns the locales abbreviated month given the 'month' provided
  123. func (fil *fil_PH) MonthAbbreviated(month time.Month) string {
  124. return fil.monthsAbbreviated[month]
  125. }
  126. // MonthsAbbreviated returns the locales abbreviated months
  127. func (fil *fil_PH) MonthsAbbreviated() []string {
  128. return fil.monthsAbbreviated[1:]
  129. }
  130. // MonthNarrow returns the locales narrow month given the 'month' provided
  131. func (fil *fil_PH) MonthNarrow(month time.Month) string {
  132. return fil.monthsNarrow[month]
  133. }
  134. // MonthsNarrow returns the locales narrow months
  135. func (fil *fil_PH) MonthsNarrow() []string {
  136. return fil.monthsNarrow[1:]
  137. }
  138. // MonthWide returns the locales wide month given the 'month' provided
  139. func (fil *fil_PH) MonthWide(month time.Month) string {
  140. return fil.monthsWide[month]
  141. }
  142. // MonthsWide returns the locales wide months
  143. func (fil *fil_PH) MonthsWide() []string {
  144. return fil.monthsWide[1:]
  145. }
  146. // WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided
  147. func (fil *fil_PH) WeekdayAbbreviated(weekday time.Weekday) string {
  148. return fil.daysAbbreviated[weekday]
  149. }
  150. // WeekdaysAbbreviated returns the locales abbreviated weekdays
  151. func (fil *fil_PH) WeekdaysAbbreviated() []string {
  152. return fil.daysAbbreviated
  153. }
  154. // WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided
  155. func (fil *fil_PH) WeekdayNarrow(weekday time.Weekday) string {
  156. return fil.daysNarrow[weekday]
  157. }
  158. // WeekdaysNarrow returns the locales narrow weekdays
  159. func (fil *fil_PH) WeekdaysNarrow() []string {
  160. return fil.daysNarrow
  161. }
  162. // WeekdayShort returns the locales short weekday given the 'weekday' provided
  163. func (fil *fil_PH) WeekdayShort(weekday time.Weekday) string {
  164. return fil.daysShort[weekday]
  165. }
  166. // WeekdaysShort returns the locales short weekdays
  167. func (fil *fil_PH) WeekdaysShort() []string {
  168. return fil.daysShort
  169. }
  170. // WeekdayWide returns the locales wide weekday given the 'weekday' provided
  171. func (fil *fil_PH) WeekdayWide(weekday time.Weekday) string {
  172. return fil.daysWide[weekday]
  173. }
  174. // WeekdaysWide returns the locales wide weekdays
  175. func (fil *fil_PH) WeekdaysWide() []string {
  176. return fil.daysWide
  177. }
  178. // Decimal returns the decimal point of number
  179. func (fil *fil_PH) Decimal() string {
  180. return fil.decimal
  181. }
  182. // Group returns the group of number
  183. func (fil *fil_PH) Group() string {
  184. return fil.group
  185. }
  186. // Group returns the minus sign of number
  187. func (fil *fil_PH) Minus() string {
  188. return fil.minus
  189. }
  190. // FmtNumber returns 'num' with digits/precision of 'v' for 'fil_PH' and handles both Whole and Real numbers based on 'v'
  191. func (fil *fil_PH) FmtNumber(num float64, v uint64) string {
  192. s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
  193. l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3
  194. count := 0
  195. inWhole := v == 0
  196. b := make([]byte, 0, l)
  197. for i := len(s) - 1; i >= 0; i-- {
  198. if s[i] == '.' {
  199. b = append(b, fil.decimal[0])
  200. inWhole = true
  201. continue
  202. }
  203. if inWhole {
  204. if count == 3 {
  205. b = append(b, fil.group[0])
  206. count = 1
  207. } else {
  208. count++
  209. }
  210. }
  211. b = append(b, s[i])
  212. }
  213. if num < 0 {
  214. b = append(b, fil.minus[0])
  215. }
  216. // reverse
  217. for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
  218. b[i], b[j] = b[j], b[i]
  219. }
  220. return string(b)
  221. }
  222. // FmtPercent returns 'num' with digits/precision of 'v' for 'fil_PH' and handles both Whole and Real numbers based on 'v'
  223. // NOTE: 'num' passed into FmtPercent is assumed to be in percent already
  224. func (fil *fil_PH) FmtPercent(num float64, v uint64) string {
  225. s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
  226. l := len(s) + 3
  227. b := make([]byte, 0, l)
  228. for i := len(s) - 1; i >= 0; i-- {
  229. if s[i] == '.' {
  230. b = append(b, fil.decimal[0])
  231. continue
  232. }
  233. b = append(b, s[i])
  234. }
  235. if num < 0 {
  236. b = append(b, fil.minus[0])
  237. }
  238. // reverse
  239. for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
  240. b[i], b[j] = b[j], b[i]
  241. }
  242. b = append(b, fil.percent...)
  243. return string(b)
  244. }
  245. // FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'fil_PH'
  246. func (fil *fil_PH) FmtCurrency(num float64, v uint64, currency currency.Type) string {
  247. s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
  248. symbol := fil.currencies[currency]
  249. l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3
  250. count := 0
  251. inWhole := v == 0
  252. b := make([]byte, 0, l)
  253. for i := len(s) - 1; i >= 0; i-- {
  254. if s[i] == '.' {
  255. b = append(b, fil.decimal[0])
  256. inWhole = true
  257. continue
  258. }
  259. if inWhole {
  260. if count == 3 {
  261. b = append(b, fil.group[0])
  262. count = 1
  263. } else {
  264. count++
  265. }
  266. }
  267. b = append(b, s[i])
  268. }
  269. for j := len(symbol) - 1; j >= 0; j-- {
  270. b = append(b, symbol[j])
  271. }
  272. if num < 0 {
  273. b = append(b, fil.minus[0])
  274. }
  275. // reverse
  276. for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
  277. b[i], b[j] = b[j], b[i]
  278. }
  279. if int(v) < 2 {
  280. if v == 0 {
  281. b = append(b, fil.decimal...)
  282. }
  283. for i := 0; i < 2-int(v); i++ {
  284. b = append(b, '0')
  285. }
  286. }
  287. return string(b)
  288. }
  289. // FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'fil_PH'
  290. // in accounting notation.
  291. func (fil *fil_PH) FmtAccounting(num float64, v uint64, currency currency.Type) string {
  292. s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
  293. symbol := fil.currencies[currency]
  294. l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3
  295. count := 0
  296. inWhole := v == 0
  297. b := make([]byte, 0, l)
  298. for i := len(s) - 1; i >= 0; i-- {
  299. if s[i] == '.' {
  300. b = append(b, fil.decimal[0])
  301. inWhole = true
  302. continue
  303. }
  304. if inWhole {
  305. if count == 3 {
  306. b = append(b, fil.group[0])
  307. count = 1
  308. } else {
  309. count++
  310. }
  311. }
  312. b = append(b, s[i])
  313. }
  314. if num < 0 {
  315. for j := len(symbol) - 1; j >= 0; j-- {
  316. b = append(b, symbol[j])
  317. }
  318. b = append(b, fil.currencyNegativePrefix[0])
  319. } else {
  320. for j := len(symbol) - 1; j >= 0; j-- {
  321. b = append(b, symbol[j])
  322. }
  323. }
  324. // reverse
  325. for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
  326. b[i], b[j] = b[j], b[i]
  327. }
  328. if int(v) < 2 {
  329. if v == 0 {
  330. b = append(b, fil.decimal...)
  331. }
  332. for i := 0; i < 2-int(v); i++ {
  333. b = append(b, '0')
  334. }
  335. }
  336. if num < 0 {
  337. b = append(b, fil.currencyNegativeSuffix...)
  338. }
  339. return string(b)
  340. }
  341. // FmtDateShort returns the short date representation of 't' for 'fil_PH'
  342. func (fil *fil_PH) FmtDateShort(t time.Time) string {
  343. b := make([]byte, 0, 32)
  344. b = strconv.AppendInt(b, int64(t.Month()), 10)
  345. b = append(b, []byte{0x2f}...)
  346. b = strconv.AppendInt(b, int64(t.Day()), 10)
  347. b = append(b, []byte{0x2f}...)
  348. if t.Year() > 9 {
  349. b = append(b, strconv.Itoa(t.Year())[2:]...)
  350. } else {
  351. b = append(b, strconv.Itoa(t.Year())[1:]...)
  352. }
  353. return string(b)
  354. }
  355. // FmtDateMedium returns the medium date representation of 't' for 'fil_PH'
  356. func (fil *fil_PH) FmtDateMedium(t time.Time) string {
  357. b := make([]byte, 0, 32)
  358. b = append(b, fil.monthsAbbreviated[t.Month()]...)
  359. b = append(b, []byte{0x20}...)
  360. b = strconv.AppendInt(b, int64(t.Day()), 10)
  361. b = append(b, []byte{0x2c, 0x20}...)
  362. if t.Year() > 0 {
  363. b = strconv.AppendInt(b, int64(t.Year()), 10)
  364. } else {
  365. b = strconv.AppendInt(b, int64(-t.Year()), 10)
  366. }
  367. return string(b)
  368. }
  369. // FmtDateLong returns the long date representation of 't' for 'fil_PH'
  370. func (fil *fil_PH) FmtDateLong(t time.Time) string {
  371. b := make([]byte, 0, 32)
  372. b = append(b, fil.monthsWide[t.Month()]...)
  373. b = append(b, []byte{0x20}...)
  374. b = strconv.AppendInt(b, int64(t.Day()), 10)
  375. b = append(b, []byte{0x2c, 0x20}...)
  376. if t.Year() > 0 {
  377. b = strconv.AppendInt(b, int64(t.Year()), 10)
  378. } else {
  379. b = strconv.AppendInt(b, int64(-t.Year()), 10)
  380. }
  381. return string(b)
  382. }
  383. // FmtDateFull returns the full date representation of 't' for 'fil_PH'
  384. func (fil *fil_PH) FmtDateFull(t time.Time) string {
  385. b := make([]byte, 0, 32)
  386. b = append(b, fil.daysWide[t.Weekday()]...)
  387. b = append(b, []byte{0x2c, 0x20}...)
  388. b = append(b, fil.monthsWide[t.Month()]...)
  389. b = append(b, []byte{0x20}...)
  390. b = strconv.AppendInt(b, int64(t.Day()), 10)
  391. b = append(b, []byte{0x2c, 0x20}...)
  392. if t.Year() > 0 {
  393. b = strconv.AppendInt(b, int64(t.Year()), 10)
  394. } else {
  395. b = strconv.AppendInt(b, int64(-t.Year()), 10)
  396. }
  397. return string(b)
  398. }
  399. // FmtTimeShort returns the short time representation of 't' for 'fil_PH'
  400. func (fil *fil_PH) FmtTimeShort(t time.Time) string {
  401. b := make([]byte, 0, 32)
  402. h := t.Hour()
  403. if h > 12 {
  404. h -= 12
  405. }
  406. b = strconv.AppendInt(b, int64(h), 10)
  407. b = append(b, fil.timeSeparator...)
  408. if t.Minute() < 10 {
  409. b = append(b, '0')
  410. }
  411. b = strconv.AppendInt(b, int64(t.Minute()), 10)
  412. b = append(b, []byte{0x20}...)
  413. if t.Hour() < 12 {
  414. b = append(b, fil.periodsAbbreviated[0]...)
  415. } else {
  416. b = append(b, fil.periodsAbbreviated[1]...)
  417. }
  418. return string(b)
  419. }
  420. // FmtTimeMedium returns the medium time representation of 't' for 'fil_PH'
  421. func (fil *fil_PH) FmtTimeMedium(t time.Time) string {
  422. b := make([]byte, 0, 32)
  423. h := t.Hour()
  424. if h > 12 {
  425. h -= 12
  426. }
  427. b = strconv.AppendInt(b, int64(h), 10)
  428. b = append(b, fil.timeSeparator...)
  429. if t.Minute() < 10 {
  430. b = append(b, '0')
  431. }
  432. b = strconv.AppendInt(b, int64(t.Minute()), 10)
  433. b = append(b, fil.timeSeparator...)
  434. if t.Second() < 10 {
  435. b = append(b, '0')
  436. }
  437. b = strconv.AppendInt(b, int64(t.Second()), 10)
  438. b = append(b, []byte{0x20}...)
  439. if t.Hour() < 12 {
  440. b = append(b, fil.periodsAbbreviated[0]...)
  441. } else {
  442. b = append(b, fil.periodsAbbreviated[1]...)
  443. }
  444. return string(b)
  445. }
  446. // FmtTimeLong returns the long time representation of 't' for 'fil_PH'
  447. func (fil *fil_PH) FmtTimeLong(t time.Time) string {
  448. b := make([]byte, 0, 32)
  449. h := t.Hour()
  450. if h > 12 {
  451. h -= 12
  452. }
  453. b = strconv.AppendInt(b, int64(h), 10)
  454. b = append(b, fil.timeSeparator...)
  455. if t.Minute() < 10 {
  456. b = append(b, '0')
  457. }
  458. b = strconv.AppendInt(b, int64(t.Minute()), 10)
  459. b = append(b, fil.timeSeparator...)
  460. if t.Second() < 10 {
  461. b = append(b, '0')
  462. }
  463. b = strconv.AppendInt(b, int64(t.Second()), 10)
  464. b = append(b, []byte{0x20}...)
  465. if t.Hour() < 12 {
  466. b = append(b, fil.periodsAbbreviated[0]...)
  467. } else {
  468. b = append(b, fil.periodsAbbreviated[1]...)
  469. }
  470. b = append(b, []byte{0x20}...)
  471. tz, _ := t.Zone()
  472. b = append(b, tz...)
  473. return string(b)
  474. }
  475. // FmtTimeFull returns the full time representation of 't' for 'fil_PH'
  476. func (fil *fil_PH) FmtTimeFull(t time.Time) string {
  477. b := make([]byte, 0, 32)
  478. h := t.Hour()
  479. if h > 12 {
  480. h -= 12
  481. }
  482. b = strconv.AppendInt(b, int64(h), 10)
  483. b = append(b, fil.timeSeparator...)
  484. if t.Minute() < 10 {
  485. b = append(b, '0')
  486. }
  487. b = strconv.AppendInt(b, int64(t.Minute()), 10)
  488. b = append(b, fil.timeSeparator...)
  489. if t.Second() < 10 {
  490. b = append(b, '0')
  491. }
  492. b = strconv.AppendInt(b, int64(t.Second()), 10)
  493. b = append(b, []byte{0x20}...)
  494. if t.Hour() < 12 {
  495. b = append(b, fil.periodsAbbreviated[0]...)
  496. } else {
  497. b = append(b, fil.periodsAbbreviated[1]...)
  498. }
  499. b = append(b, []byte{0x20}...)
  500. tz, _ := t.Zone()
  501. if btz, ok := fil.timezones[tz]; ok {
  502. b = append(b, btz...)
  503. } else {
  504. b = append(b, tz...)
  505. }
  506. return string(b)
  507. }