...

Source file src/github.com/go-playground/locales/nds/nds.go

Documentation: github.com/go-playground/locales/nds

     1  package nds
     2  
     3  import (
     4  	"math"
     5  	"strconv"
     6  	"time"
     7  
     8  	"github.com/go-playground/locales"
     9  	"github.com/go-playground/locales/currency"
    10  )
    11  
    12  type nds struct {
    13  	locale                 string
    14  	pluralsCardinal        []locales.PluralRule
    15  	pluralsOrdinal         []locales.PluralRule
    16  	pluralsRange           []locales.PluralRule
    17  	decimal                string
    18  	group                  string
    19  	minus                  string
    20  	percent                string
    21  	percentSuffix          string
    22  	perMille               string
    23  	timeSeparator          string
    24  	inifinity              string
    25  	currencies             []string // idx = enum of currency code
    26  	currencyPositiveSuffix string
    27  	currencyNegativeSuffix string
    28  	monthsAbbreviated      []string
    29  	monthsNarrow           []string
    30  	monthsWide             []string
    31  	daysAbbreviated        []string
    32  	daysNarrow             []string
    33  	daysShort              []string
    34  	daysWide               []string
    35  	periodsAbbreviated     []string
    36  	periodsNarrow          []string
    37  	periodsShort           []string
    38  	periodsWide            []string
    39  	erasAbbreviated        []string
    40  	erasNarrow             []string
    41  	erasWide               []string
    42  	timezones              map[string]string
    43  }
    44  
    45  // New returns a new instance of translator for the 'nds' locale
    46  func New() locales.Translator {
    47  	return &nds{
    48  		locale:                 "nds",
    49  		pluralsCardinal:        nil,
    50  		pluralsOrdinal:         nil,
    51  		pluralsRange:           nil,
    52  		decimal:                ",",
    53  		group:                  ".",
    54  		minus:                  "-",
    55  		percent:                "%",
    56  		perMille:               "‰",
    57  		timeSeparator:          ":",
    58  		inifinity:              "∞",
    59  		currencies:             []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AU$", "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", "R$", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CA$", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNH", "CNX", "CN¥", "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", "€", "FIM", "FJD", "FKP", "FRF", "£", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HK$", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "₹", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JP¥", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "₩", "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", "MRU", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MX$", "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", "฿", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "NT$", "TZS", "UAH", "UAK", "UGS", "UGX", "$", "USN", "USS", "UYI", "UYP", "UYU", "UYW", "UZS", "VEB", "VEF", "VES", "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"},
    60  		percentSuffix:          " ",
    61  		currencyPositiveSuffix: " ",
    62  		currencyNegativeSuffix: " ",
    63  		monthsAbbreviated:      []string{"", "Jan.", "Feb.", "März", "Apr.", "Mai", "Juni", "Juli", "Aug.", "Sep.", "Okt.", "Nov.", "Dez."},
    64  		monthsNarrow:           []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"},
    65  		monthsWide:             []string{"", "Januaar", "Februaar", "März", "April", "Mai", "Juni", "Juli", "August", "September", "Oktover", "November", "Dezember"},
    66  		daysAbbreviated:        []string{"Sü.", "Ma.", "Di.", "Mi.", "Du.", "Fr.", "Sa."},
    67  		daysNarrow:             []string{"S", "M", "D", "M", "D", "F", "S"},
    68  		daysWide:               []string{"Sünndag", "Maandag", "Dingsdag", "Middeweken", "Dunnersdag", "Freedag", "Sünnavend"},
    69  		periodsAbbreviated:     []string{"vm", "nm"},
    70  		periodsWide:            []string{"vm", "nm"},
    71  		erasAbbreviated:        []string{"v.Chr.", "n.Chr."},
    72  		erasNarrow:             []string{"vC", "nC"},
    73  		erasWide:               []string{"vör Christus", "na Christus"},
    74  		timezones:              map[string]string{"ACDT": "Zentraalaustraalsch Summertiet", "ACST": "Zentraalaustraalsch Standardtiet", "ACWDT": "Westzentraalaustraalsch Summertiet", "ACWST": "Westzentraalaustraalsch Standardtiet", "ADT": "Noordamerikaansch Atlantik-Summertiet", "AEDT": "Oostaustraalsch Summertiet", "AEST": "Oostaustraalsch Standardtiet", "AKDT": "AKDT", "AKST": "AKST", "ARST": "ARST", "ART": "ART", "AST": "Noordamerikaansch Atlantik-Standardtiet", "AWDT": "Westaustraalsch Summertiet", "AWST": "Westaustraalsch Standardtiet", "BOT": "BOT", "BT": "BT", "CAT": "Zentraalafrikaansch Tiet", "CDT": "Noordamerikaansch zentraal Summertiet", "CHADT": "CHADT", "CHAST": "CHAST", "CLST": "CLST", "CLT": "CLT", "COST": "COST", "COT": "COT", "CST": "Noordamerikaansch zentraal Standardtiet", "ChST": "ChST", "EAT": "Oostafrikaansch Tiet", "ECT": "ECT", "EDT": "Noordamerikaansch oosten Summertiet", "EST": "Noordamerikaansch oosten Standardtiet", "GFT": "GFT", "GMT": "Gröönwisch-Welttiet", "GST": "GST", "GYT": "GYT", "HADT": "HADT", "HAST": "HAST", "HAT": "HAT", "HECU": "HECU", "HEEG": "HEEG", "HENOMX": "HENOMX", "HEOG": "HEOG", "HEPM": "HEPM", "HEPMX": "HEPMX", "HKST": "HKST", "HKT": "HKT", "HNCU": "HNCU", "HNEG": "HNEG", "HNNOMX": "HNNOMX", "HNOG": "HNOG", "HNPM": "HNPM", "HNPMX": "HNPMX", "HNT": "HNT", "IST": "Indien-Tiet", "JDT": "Japaansch Summertiet", "JST": "Japaansch Standardtiet", "LHDT": "LHDT", "LHST": "LHST", "MDT": "Noordamerikaansch Barg-Summertiet", "MESZ": "Zentraaleuropääsch Summertiet", "MEZ": "Zentraaleuropääsch Standardtiet", "MST": "Noordamerikaansch Barg-Standardtiet", "MYT": "MYT", "NZDT": "NZDT", "NZST": "NZST", "OESZ": "Oosteuropääsch Summertiet", "OEZ": "Oosteuropääsch Standardtiet", "PDT": "Noordamerikaansch Pazifik-Summertiet", "PST": "Noordamerikaansch Pazifik-Standardtiet", "SAST": "Söödafrikaansch Tiet", "SGT": "SGT", "SRT": "SRT", "TMST": "TMST", "TMT": "TMT", "UYST": "UYST", "UYT": "UYT", "VET": "VET", "WARST": "WARST", "WART": "WART", "WAST": "Westafrikaansch Summertiet", "WAT": "Westafrikaansch Standardtiet", "WESZ": "Westeuropääsch Summertiet", "WEZ": "Westeuropääsch Standardtiet", "WIB": "Westindoneesch Tiet", "WIT": "Oostindoneesch Tiet", "WITA": "Indoneesch Zentraaltiet", "∅∅∅": "∅∅∅"},
    75  	}
    76  }
    77  
    78  // Locale returns the current translators string locale
    79  func (nds *nds) Locale() string {
    80  	return nds.locale
    81  }
    82  
    83  // PluralsCardinal returns the list of cardinal plural rules associated with 'nds'
    84  func (nds *nds) PluralsCardinal() []locales.PluralRule {
    85  	return nds.pluralsCardinal
    86  }
    87  
    88  // PluralsOrdinal returns the list of ordinal plural rules associated with 'nds'
    89  func (nds *nds) PluralsOrdinal() []locales.PluralRule {
    90  	return nds.pluralsOrdinal
    91  }
    92  
    93  // PluralsRange returns the list of range plural rules associated with 'nds'
    94  func (nds *nds) PluralsRange() []locales.PluralRule {
    95  	return nds.pluralsRange
    96  }
    97  
    98  // CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'nds'
    99  func (nds *nds) CardinalPluralRule(num float64, v uint64) locales.PluralRule {
   100  	return locales.PluralRuleUnknown
   101  }
   102  
   103  // OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'nds'
   104  func (nds *nds) OrdinalPluralRule(num float64, v uint64) locales.PluralRule {
   105  	return locales.PluralRuleUnknown
   106  }
   107  
   108  // RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'nds'
   109  func (nds *nds) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule {
   110  	return locales.PluralRuleUnknown
   111  }
   112  
   113  // MonthAbbreviated returns the locales abbreviated month given the 'month' provided
   114  func (nds *nds) MonthAbbreviated(month time.Month) string {
   115  	return nds.monthsAbbreviated[month]
   116  }
   117  
   118  // MonthsAbbreviated returns the locales abbreviated months
   119  func (nds *nds) MonthsAbbreviated() []string {
   120  	return nds.monthsAbbreviated[1:]
   121  }
   122  
   123  // MonthNarrow returns the locales narrow month given the 'month' provided
   124  func (nds *nds) MonthNarrow(month time.Month) string {
   125  	return nds.monthsNarrow[month]
   126  }
   127  
   128  // MonthsNarrow returns the locales narrow months
   129  func (nds *nds) MonthsNarrow() []string {
   130  	return nds.monthsNarrow[1:]
   131  }
   132  
   133  // MonthWide returns the locales wide month given the 'month' provided
   134  func (nds *nds) MonthWide(month time.Month) string {
   135  	return nds.monthsWide[month]
   136  }
   137  
   138  // MonthsWide returns the locales wide months
   139  func (nds *nds) MonthsWide() []string {
   140  	return nds.monthsWide[1:]
   141  }
   142  
   143  // WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided
   144  func (nds *nds) WeekdayAbbreviated(weekday time.Weekday) string {
   145  	return nds.daysAbbreviated[weekday]
   146  }
   147  
   148  // WeekdaysAbbreviated returns the locales abbreviated weekdays
   149  func (nds *nds) WeekdaysAbbreviated() []string {
   150  	return nds.daysAbbreviated
   151  }
   152  
   153  // WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided
   154  func (nds *nds) WeekdayNarrow(weekday time.Weekday) string {
   155  	return nds.daysNarrow[weekday]
   156  }
   157  
   158  // WeekdaysNarrow returns the locales narrow weekdays
   159  func (nds *nds) WeekdaysNarrow() []string {
   160  	return nds.daysNarrow
   161  }
   162  
   163  // WeekdayShort returns the locales short weekday given the 'weekday' provided
   164  func (nds *nds) WeekdayShort(weekday time.Weekday) string {
   165  	return nds.daysShort[weekday]
   166  }
   167  
   168  // WeekdaysShort returns the locales short weekdays
   169  func (nds *nds) WeekdaysShort() []string {
   170  	return nds.daysShort
   171  }
   172  
   173  // WeekdayWide returns the locales wide weekday given the 'weekday' provided
   174  func (nds *nds) WeekdayWide(weekday time.Weekday) string {
   175  	return nds.daysWide[weekday]
   176  }
   177  
   178  // WeekdaysWide returns the locales wide weekdays
   179  func (nds *nds) WeekdaysWide() []string {
   180  	return nds.daysWide
   181  }
   182  
   183  // Decimal returns the decimal point of number
   184  func (nds *nds) Decimal() string {
   185  	return nds.decimal
   186  }
   187  
   188  // Group returns the group of number
   189  func (nds *nds) Group() string {
   190  	return nds.group
   191  }
   192  
   193  // Group returns the minus sign of number
   194  func (nds *nds) Minus() string {
   195  	return nds.minus
   196  }
   197  
   198  // FmtNumber returns 'num' with digits/precision of 'v' for 'nds' and handles both Whole and Real numbers based on 'v'
   199  func (nds *nds) FmtNumber(num float64, v uint64) string {
   200  
   201  	s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
   202  	l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3
   203  	count := 0
   204  	inWhole := v == 0
   205  	b := make([]byte, 0, l)
   206  
   207  	for i := len(s) - 1; i >= 0; i-- {
   208  
   209  		if s[i] == '.' {
   210  			b = append(b, nds.decimal[0])
   211  			inWhole = true
   212  			continue
   213  		}
   214  
   215  		if inWhole {
   216  			if count == 3 {
   217  				b = append(b, nds.group[0])
   218  				count = 1
   219  			} else {
   220  				count++
   221  			}
   222  		}
   223  
   224  		b = append(b, s[i])
   225  	}
   226  
   227  	if num < 0 {
   228  		b = append(b, nds.minus[0])
   229  	}
   230  
   231  	// reverse
   232  	for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
   233  		b[i], b[j] = b[j], b[i]
   234  	}
   235  
   236  	return string(b)
   237  }
   238  
   239  // FmtPercent returns 'num' with digits/precision of 'v' for 'nds' and handles both Whole and Real numbers based on 'v'
   240  // NOTE: 'num' passed into FmtPercent is assumed to be in percent already
   241  func (nds *nds) FmtPercent(num float64, v uint64) string {
   242  	s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
   243  	l := len(s) + 5
   244  	b := make([]byte, 0, l)
   245  
   246  	for i := len(s) - 1; i >= 0; i-- {
   247  
   248  		if s[i] == '.' {
   249  			b = append(b, nds.decimal[0])
   250  			continue
   251  		}
   252  
   253  		b = append(b, s[i])
   254  	}
   255  
   256  	if num < 0 {
   257  		b = append(b, nds.minus[0])
   258  	}
   259  
   260  	// reverse
   261  	for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
   262  		b[i], b[j] = b[j], b[i]
   263  	}
   264  
   265  	b = append(b, nds.percentSuffix...)
   266  
   267  	b = append(b, nds.percent...)
   268  
   269  	return string(b)
   270  }
   271  
   272  // FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'nds'
   273  func (nds *nds) FmtCurrency(num float64, v uint64, currency currency.Type) string {
   274  
   275  	s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
   276  	symbol := nds.currencies[currency]
   277  	l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3
   278  	count := 0
   279  	inWhole := v == 0
   280  	b := make([]byte, 0, l)
   281  
   282  	for i := len(s) - 1; i >= 0; i-- {
   283  
   284  		if s[i] == '.' {
   285  			b = append(b, nds.decimal[0])
   286  			inWhole = true
   287  			continue
   288  		}
   289  
   290  		if inWhole {
   291  			if count == 3 {
   292  				b = append(b, nds.group[0])
   293  				count = 1
   294  			} else {
   295  				count++
   296  			}
   297  		}
   298  
   299  		b = append(b, s[i])
   300  	}
   301  
   302  	if num < 0 {
   303  		b = append(b, nds.minus[0])
   304  	}
   305  
   306  	// reverse
   307  	for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
   308  		b[i], b[j] = b[j], b[i]
   309  	}
   310  
   311  	if int(v) < 2 {
   312  
   313  		if v == 0 {
   314  			b = append(b, nds.decimal...)
   315  		}
   316  
   317  		for i := 0; i < 2-int(v); i++ {
   318  			b = append(b, '0')
   319  		}
   320  	}
   321  
   322  	b = append(b, nds.currencyPositiveSuffix...)
   323  
   324  	b = append(b, symbol...)
   325  
   326  	return string(b)
   327  }
   328  
   329  // FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'nds'
   330  // in accounting notation.
   331  func (nds *nds) FmtAccounting(num float64, v uint64, currency currency.Type) string {
   332  
   333  	s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
   334  	symbol := nds.currencies[currency]
   335  	l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3
   336  	count := 0
   337  	inWhole := v == 0
   338  	b := make([]byte, 0, l)
   339  
   340  	for i := len(s) - 1; i >= 0; i-- {
   341  
   342  		if s[i] == '.' {
   343  			b = append(b, nds.decimal[0])
   344  			inWhole = true
   345  			continue
   346  		}
   347  
   348  		if inWhole {
   349  			if count == 3 {
   350  				b = append(b, nds.group[0])
   351  				count = 1
   352  			} else {
   353  				count++
   354  			}
   355  		}
   356  
   357  		b = append(b, s[i])
   358  	}
   359  
   360  	if num < 0 {
   361  
   362  		b = append(b, nds.minus[0])
   363  
   364  	}
   365  
   366  	// reverse
   367  	for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
   368  		b[i], b[j] = b[j], b[i]
   369  	}
   370  
   371  	if int(v) < 2 {
   372  
   373  		if v == 0 {
   374  			b = append(b, nds.decimal...)
   375  		}
   376  
   377  		for i := 0; i < 2-int(v); i++ {
   378  			b = append(b, '0')
   379  		}
   380  	}
   381  
   382  	if num < 0 {
   383  		b = append(b, nds.currencyNegativeSuffix...)
   384  		b = append(b, symbol...)
   385  	} else {
   386  
   387  		b = append(b, nds.currencyPositiveSuffix...)
   388  		b = append(b, symbol...)
   389  	}
   390  
   391  	return string(b)
   392  }
   393  
   394  // FmtDateShort returns the short date representation of 't' for 'nds'
   395  func (nds *nds) FmtDateShort(t time.Time) string {
   396  
   397  	b := make([]byte, 0, 32)
   398  
   399  	b = strconv.AppendInt(b, int64(t.Day()), 10)
   400  	b = append(b, []byte{0x2e}...)
   401  
   402  	if t.Month() < 10 {
   403  		b = append(b, '0')
   404  	}
   405  
   406  	b = strconv.AppendInt(b, int64(t.Month()), 10)
   407  
   408  	b = append(b, []byte{0x2e}...)
   409  
   410  	if t.Year() > 9 {
   411  		b = append(b, strconv.Itoa(t.Year())[2:]...)
   412  	} else {
   413  		b = append(b, strconv.Itoa(t.Year())[1:]...)
   414  	}
   415  
   416  	return string(b)
   417  }
   418  
   419  // FmtDateMedium returns the medium date representation of 't' for 'nds'
   420  func (nds *nds) FmtDateMedium(t time.Time) string {
   421  
   422  	b := make([]byte, 0, 32)
   423  
   424  	b = strconv.AppendInt(b, int64(t.Day()), 10)
   425  	b = append(b, []byte{0x2e, 0x20}...)
   426  	b = append(b, nds.monthsAbbreviated[t.Month()]...)
   427  	b = append(b, []byte{0x20}...)
   428  
   429  	if t.Year() > 0 {
   430  		b = strconv.AppendInt(b, int64(t.Year()), 10)
   431  	} else {
   432  		b = strconv.AppendInt(b, int64(-t.Year()), 10)
   433  	}
   434  
   435  	return string(b)
   436  }
   437  
   438  // FmtDateLong returns the long date representation of 't' for 'nds'
   439  func (nds *nds) FmtDateLong(t time.Time) string {
   440  
   441  	b := make([]byte, 0, 32)
   442  
   443  	b = strconv.AppendInt(b, int64(t.Day()), 10)
   444  	b = append(b, []byte{0x2e, 0x20}...)
   445  	b = append(b, nds.monthsWide[t.Month()]...)
   446  	b = append(b, []byte{0x20}...)
   447  
   448  	if t.Year() > 0 {
   449  		b = strconv.AppendInt(b, int64(t.Year()), 10)
   450  	} else {
   451  		b = strconv.AppendInt(b, int64(-t.Year()), 10)
   452  	}
   453  
   454  	return string(b)
   455  }
   456  
   457  // FmtDateFull returns the full date representation of 't' for 'nds'
   458  func (nds *nds) FmtDateFull(t time.Time) string {
   459  
   460  	b := make([]byte, 0, 32)
   461  
   462  	b = append(b, nds.daysWide[t.Weekday()]...)
   463  	b = append(b, []byte{0x2c, 0x20, 0x64, 0x65}...)
   464  	b = append(b, []byte{0x20}...)
   465  	b = strconv.AppendInt(b, int64(t.Day()), 10)
   466  	b = append(b, []byte{0x2e, 0x20}...)
   467  	b = append(b, nds.monthsWide[t.Month()]...)
   468  	b = append(b, []byte{0x20}...)
   469  
   470  	if t.Year() > 0 {
   471  		b = strconv.AppendInt(b, int64(t.Year()), 10)
   472  	} else {
   473  		b = strconv.AppendInt(b, int64(-t.Year()), 10)
   474  	}
   475  
   476  	return string(b)
   477  }
   478  
   479  // FmtTimeShort returns the short time representation of 't' for 'nds'
   480  func (nds *nds) FmtTimeShort(t time.Time) string {
   481  
   482  	b := make([]byte, 0, 32)
   483  
   484  	b = append(b, []byte{0x4b, 0x6c}...)
   485  	b = append(b, []byte{0x2e, 0x20}...)
   486  	b = strconv.AppendInt(b, int64(t.Hour()), 10)
   487  	b = append(b, []byte{0x2e}...)
   488  
   489  	if t.Minute() < 10 {
   490  		b = append(b, '0')
   491  	}
   492  
   493  	b = strconv.AppendInt(b, int64(t.Minute()), 10)
   494  
   495  	return string(b)
   496  }
   497  
   498  // FmtTimeMedium returns the medium time representation of 't' for 'nds'
   499  func (nds *nds) FmtTimeMedium(t time.Time) string {
   500  
   501  	b := make([]byte, 0, 32)
   502  
   503  	b = append(b, []byte{0x4b, 0x6c, 0x6f, 0x63, 0x6b}...)
   504  	b = append(b, []byte{0x20}...)
   505  	b = strconv.AppendInt(b, int64(t.Hour()), 10)
   506  	b = append(b, []byte{0x2e}...)
   507  
   508  	if t.Minute() < 10 {
   509  		b = append(b, '0')
   510  	}
   511  
   512  	b = strconv.AppendInt(b, int64(t.Minute()), 10)
   513  	b = append(b, nds.timeSeparator...)
   514  
   515  	if t.Second() < 10 {
   516  		b = append(b, '0')
   517  	}
   518  
   519  	b = strconv.AppendInt(b, int64(t.Second()), 10)
   520  
   521  	return string(b)
   522  }
   523  
   524  // FmtTimeLong returns the long time representation of 't' for 'nds'
   525  func (nds *nds) FmtTimeLong(t time.Time) string {
   526  
   527  	b := make([]byte, 0, 32)
   528  
   529  	b = append(b, []byte{0x4b, 0x6c, 0x6f, 0x63, 0x6b}...)
   530  	b = append(b, []byte{0x20}...)
   531  	b = strconv.AppendInt(b, int64(t.Hour()), 10)
   532  	b = append(b, []byte{0x2e}...)
   533  
   534  	if t.Minute() < 10 {
   535  		b = append(b, '0')
   536  	}
   537  
   538  	b = strconv.AppendInt(b, int64(t.Minute()), 10)
   539  	b = append(b, nds.timeSeparator...)
   540  
   541  	if t.Second() < 10 {
   542  		b = append(b, '0')
   543  	}
   544  
   545  	b = strconv.AppendInt(b, int64(t.Second()), 10)
   546  	b = append(b, []byte{0x20, 0x28}...)
   547  
   548  	tz, _ := t.Zone()
   549  	b = append(b, tz...)
   550  
   551  	b = append(b, []byte{0x29}...)
   552  
   553  	return string(b)
   554  }
   555  
   556  // FmtTimeFull returns the full time representation of 't' for 'nds'
   557  func (nds *nds) FmtTimeFull(t time.Time) string {
   558  
   559  	b := make([]byte, 0, 32)
   560  
   561  	b = append(b, []byte{0x4b, 0x6c, 0x6f, 0x63, 0x6b}...)
   562  	b = append(b, []byte{0x20}...)
   563  	b = strconv.AppendInt(b, int64(t.Hour()), 10)
   564  	b = append(b, []byte{0x2e}...)
   565  
   566  	if t.Minute() < 10 {
   567  		b = append(b, '0')
   568  	}
   569  
   570  	b = strconv.AppendInt(b, int64(t.Minute()), 10)
   571  	b = append(b, nds.timeSeparator...)
   572  
   573  	if t.Second() < 10 {
   574  		b = append(b, '0')
   575  	}
   576  
   577  	b = strconv.AppendInt(b, int64(t.Second()), 10)
   578  	b = append(b, []byte{0x20, 0x28}...)
   579  
   580  	tz, _ := t.Zone()
   581  
   582  	if btz, ok := nds.timezones[tz]; ok {
   583  		b = append(b, btz...)
   584  	} else {
   585  		b = append(b, tz...)
   586  	}
   587  
   588  	b = append(b, []byte{0x29}...)
   589  
   590  	return string(b)
   591  }
   592  

View as plain text