mirror of
https://github.com/unidoc/unioffice.git
synced 2025-04-29 13:49:10 +08:00
59 lines
38 KiB
Go
59 lines
38 KiB
Go
//
|
|
// Copyright 2020 FoxyUtils ehf. All rights reserved.
|
|
//
|
|
// This is a commercial product and requires a license to operate.
|
|
// A trial license can be obtained at https://unidoc.io
|
|
//
|
|
// DO NOT EDIT: generated by unitwist Go source code obfuscator.
|
|
//
|
|
// Use of this source code is governed by the UniDoc End User License Agreement
|
|
// terms that can be accessed at https://unidoc.io/eula/
|
|
|
|
// Package format provides support for parsing and evaluating
|
|
// spreadsheetml/Excel number formats.
|
|
//
|
|
// Internally spreadsheets store numbers and dates values as a text
|
|
// representation of a floating point number (e.g. 1.2345). This number is then
|
|
// displayed in Excel or another spreadsheet viewer differently depending on the
|
|
// number fornat of the cell style applied to the cell.
|
|
//
|
|
// As an example, the same value of 1.2345 can be displayed as:
|
|
// - "1" with format "0"
|
|
// - "1.2" with format "0.0"
|
|
// - "1.23" with format "0.00"
|
|
// - "1.235" with format "0.000"
|
|
// - "123%" with format "0%"
|
|
// - "1 23/100" with fornat "0 0/100"
|
|
// - "1.23E+00" with format "0.00E+00"
|
|
// - "29:37:41s" with format `[h]:mm:ss"s"`
|
|
package format ;import (_c "bytes";_a "fmt";_dg "github.com/unidoc/unioffice";_d "io";_gb "math";_ae "strconv";_g "strings";_b "time";);func _cce (_cda _b .Time ,_age string )[]byte {_dcac :=[]byte {};_cgg :=0;for _fea :=0;_fea < len (_age );_fea ++{var _aea string ;if _age [_fea ]=='/'{_aea =string (_age [_cgg :_fea ]);_cgg =_fea +1;}else if _fea ==len (_age )-1{_aea =string (_age [_cgg :_fea +1]);}else {continue ;};switch _aea {case "\u0079\u0079":_dcac =_cda .AppendFormat (_dcac ,"\u0030\u0036");case "\u0079\u0079\u0079\u0079":_dcac =_cda .AppendFormat (_dcac ,"\u0032\u0030\u0030\u0036");case "\u006d":_dcac =_cda .AppendFormat (_dcac ,"\u0031");case "\u006d\u006d":_dcac =_cda .AppendFormat (_dcac ,"\u0030\u0031");case "\u006d\u006d\u006d":_dcac =_cda .AppendFormat (_dcac ,"\u004a\u0061\u006e");case "\u006d\u006d\u006d\u006d":_dcac =_cda .AppendFormat (_dcac ,"\u004aa\u006e\u0075\u0061\u0072\u0079");case "\u006d\u006d\u006dm\u006d":switch _cda .Month (){case _b .January ,_b .July ,_b .June :_dcac =append (_dcac ,'J');case _b .February :_dcac =append (_dcac ,'M');case _b .March ,_b .May :_dcac =append (_dcac ,'M');case _b .April ,_b .August :_dcac =append (_dcac ,'A');case _b .September :_dcac =append (_dcac ,'S');case _b .October :_dcac =append (_dcac ,'O');case _b .November :_dcac =append (_dcac ,'N');case _b .December :_dcac =append (_dcac ,'D');};case "\u0064":_dcac =_cda .AppendFormat (_dcac ,"\u0032");case "\u0064\u0064":_dcac =_cda .AppendFormat (_dcac ,"\u0030\u0032");case "\u0064\u0064\u0064":_dcac =_cda .AppendFormat (_dcac ,"\u004d\u006f\u006e");case "\u0064\u0064\u0064\u0064":_dcac =_cda .AppendFormat (_dcac ,"\u004d\u006f\u006e\u0064\u0061\u0079");default:_dg .Log ("\u0075\u006e\u0073\u0075\u0070\u0070\u006f\u0072\u0074\u0065\u0064 \u0064\u0061\u0074\u0065\u0020\u0066\u006f\u0072\u006d\u0061t\u0020\u0025\u0073",_aea );};if _age [_fea ]=='/'{_dcac =append (_dcac ,'/');};};return _dcac ;};func (_bde *Lexer )nextFmt (){_bde ._gebb =append (_bde ._gebb ,_bde ._ageef );_bde ._ageef =Format {}};func _gcf (_bea int64 )int64 {if _bea < 0{return -_bea ;};return _bea ;};const _gf int =0;func _bce (_cbf []byte )[]byte {for _fff :=len (_cbf )-1;_fff > 0;_fff --{if _cbf [_fff ]=='9'+1{_cbf [_fff ]='0';if _cbf [_fff -1]=='.'{_fff --;};_cbf [_fff -1]++;};};if _cbf [0]=='9'+1{_cbf [0]='0';copy (_cbf [1:],_cbf [0:]);_cbf [0]='1';};return _cbf ;};
|
|
|
|
// Value formats a value as a number or string depending on if it appears to be
|
|
// a number or string.
|
|
func Value (v string ,f string )string {if IsNumber (v ){_ed ,_ :=_ae .ParseFloat (v ,64);return Number (_ed ,f );};return String (v ,f );};func _aca (_bf float64 ,_eb Format ,_ebb bool )string {if _eb ._e {return NumberGeneric (_bf );};_eg :=make ([]byte ,0,20);_acd :=_gb .Signbit (_bf );_cb :=_gb .Abs (_bf );_fec :=int64 (0);_cbd :=int64 (0);if _eb .IsExponential {for _cb >=10{_cbd ++;_cb /=10;};for _cb < 1{_cbd --;_cb *=10;};}else if _eb ._ga {_cb *=100;}else if _eb ._de {if _eb ._ff ==0{_ee :=_gb .Pow (10,float64 (_eb ._db ));_cde ,_eeg :=1.0,1.0;_ =_cde ;for _eed :=1.0;_eed < _ee ;_eed ++{_ ,_fge :=_gb .Modf (_cb *float64 (_eed ));if _fge < _eeg {_eeg =_fge ;_cde =_eed ;if _fge ==0{break ;};};};_eb ._ff =int64 (_cde );};_fec =int64 (_cb *float64 (_eb ._ff )+0.5);if len (_eb .Whole )> 0&&_fec > _eb ._ff {_fec =int64 (_cb *float64 (_eb ._ff ))%_eb ._ff ;_cb -=float64 (_fec )/float64 (_eb ._ff );}else {_cb -=float64 (_fec )/float64 (_eb ._ff );if _gb .Abs (_cb )< 1{_dd :=true ;for _ ,_cc :=range _eb .Whole {if _cc .Type ==FmtTypeDigitOpt {continue ;};if _cc .Type ==FmtTypeLiteral &&_cc .Literal ==' '{continue ;};_dd =false ;};if _dd {_eb .Whole =nil ;};};};};_ba :=1;for _ ,_bbdf :=range _eb .Fractional {if _bbdf .Type ==FmtTypeDigit ||_bbdf .Type ==FmtTypeDigitOpt {_ba ++;};};_cb +=5*_gb .Pow10 (-_ba );_caa ,_ddc :=_gb .Modf (_cb );_eg =append (_eg ,_bbf (_caa ,_bf ,_eb )...);_eg =append (_eg ,_cec (_ddc ,_bf ,_eb )...);_eg =append (_eg ,_fdd (_cbd ,_eb )...);if _eb ._de {_eg =_ae .AppendInt (_eg ,_fec ,10);_eg =append (_eg ,'/');_eg =_ae .AppendInt (_eg ,_eb ._ff ,10);};if !_ebb &&_acd {return "\u002d"+string (_eg );};return string (_eg );};func _fdd (_eae int64 ,_abg Format )[]byte {if !_abg .IsExponential ||len (_abg .Exponent )==0{return nil ;};_babf :=_ae .AppendInt (nil ,_gcf (_eae ),10);_ccg :=make ([]byte ,0,len (_babf )+2);_ccg =append (_ccg ,'E');if _eae >=0{_ccg =append (_ccg ,'+');}else {_ccg =append (_ccg ,'-');_eae *=-1;};_cf :=0;_cdd :for _acf :=len (_abg .Exponent )-1;_acf >=0;_acf --{_deb :=len (_babf )-1-_cf ;_bbe :=_abg .Exponent [_acf ];switch _bbe .Type {case FmtTypeDigit :if _deb >=0{_ccg =append (_ccg ,_babf [_deb ]);_cf ++;}else {_ccg =append (_ccg ,'0');};case FmtTypeDigitOpt :if _deb >=0{_ccg =append (_ccg ,_babf [_deb ]);_cf ++;}else {for _ebbc :=_acf ;_ebbc >=0;_ebbc --{_bbfb :=_abg .Exponent [_ebbc ];if _bbfb .Type ==FmtTypeLiteral {_ccg =append (_ccg ,_bbfb .Literal );};};break _cdd ;};case FmtTypeLiteral :_ccg =append (_ccg ,_bbe .Literal );default:_dg .Log ("\u0075\u006e\u0073\u0075\u0070\u0070\u006f\u0072\u0074\u0065\u0064 \u0074\u0079\u0070\u0065\u0020\u0069\u006e\u0020\u0065\u0078p\u0020\u0025\u0076",_bbe );};};if _cf < len (_babf ){_ccg =append (_ccg ,_babf [len (_babf )-_cf -1:_cf -1]...);};_cab (_ccg [2:]);return _ccg ;};func (_dbg *Lexer )Lex (r _d .Reader ){_gbe ,_gdf ,_ffca :=0,0,0;_bbea :=-1;_gdc ,_aga ,_fgac :=0,0,0;_ =_aga ;_ =_fgac ;_fag :=1;_ =_fag ;_fdb :=make ([]byte ,4096);_egc :=false ;for !_egc {_fgd :=0;if _gdc > 0{_fgd =_gdf -_gdc ;};_gdf =0;_ebd ,_gbb :=r .Read (_fdb [_fgd :]);if _ebd ==0||_gbb !=nil {_egc =true ;};_ffca =_ebd +_fgd ;if _ffca < len (_fdb ){_bbea =_ffca ;};{_gbe =_aee ;_gdc =0;_aga =0;_fgac =0;};{if _gdf ==_ffca {goto _ceb ;};switch _gbe {case 34:goto _ege ;case 35:goto _gdcb ;case 0:goto _fgea ;case 36:goto _gce ;case 37:goto _baaf ;case 1:goto _abab ;case 2:goto _egd ;case 38:goto _edee ;case 3:goto _ecaf ;case 4:goto _bddb ;case 39:goto _dac ;case 5:goto _bbg ;case 6:goto _cbc ;case 7:goto _fddg ;case 8:goto _aag ;case 40:goto _adg ;case 9:goto _gda ;case 41:goto _cgdg ;case 10:goto _fcbf ;case 42:goto _cga ;case 11:goto _caaa ;case 43:goto _gg ;case 44:goto _eec ;case 45:goto _fbc ;case 12:goto _gaff ;case 46:goto _cdb ;case 13:goto _egef ;case 14:goto _dece ;case 15:goto _dag ;case 16:goto _fde ;case 47:goto _egb ;case 17:goto _eea ;case 48:goto _fgdb ;case 18:goto _baea ;case 19:goto _gbff ;case 20:goto _ebc ;case 49:goto _bfac ;case 50:goto _abgf ;case 21:goto _ddgg ;case 22:goto _adga ;case 23:goto _bbgc ;case 24:goto _eeaa ;case 25:goto _ddd ;case 51:goto _abbc ;case 26:goto _gbdd ;case 52:goto _bdac ;case 53:goto _gbdeb ;case 54:goto _gde ;case 55:goto _ecc ;case 56:goto _bbfc ;case 57:goto _dab ;case 27:goto _ccf ;case 28:goto _gca ;case 29:goto _dgbd ;case 30:goto _efcb ;case 31:goto _fad ;case 58:goto _cgaa ;case 32:goto _cdbg ;case 59:goto _bcd ;case 33:goto _ddb ;case 60:goto _ccfg ;case 61:goto _bdaf ;case 62:goto _cecg ;};goto _gagg ;_fgg :switch _fgac {case 2:{_gdf =(_aga )-1;_dbg ._ageef .AddToken (FmtTypeDigit ,nil );};case 3:{_gdf =(_aga )-1;_dbg ._ageef .AddToken (FmtTypeDigitOpt ,nil );};case 5:{_gdf =(_aga )-1;};case 8:{_gdf =(_aga )-1;_dbg ._ageef .AddToken (FmtTypePercent ,nil );};case 13:{_gdf =(_aga )-1;_dbg ._ageef .AddToken (FmtTypeFraction ,_fdb [_gdc :_aga ]);};case 14:{_gdf =(_aga )-1;_dbg ._ageef .AddToken (FmtTypeDate ,_fdb [_gdc :_aga ]);};case 15:{_gdf =(_aga )-1;_dbg ._ageef .AddToken (FmtTypeTime ,_fdb [_gdc :_aga ]);};case 16:{_gdf =(_aga )-1;_dbg ._ageef .AddToken (FmtTypeTime ,_fdb [_gdc :_aga ]);};case 18:{_gdf =(_aga )-1;};case 20:{_gdf =(_aga )-1;_dbg ._ageef .AddToken (FmtTypeLiteral ,_fdb [_gdc :_aga ]);};case 21:{_gdf =(_aga )-1;_dbg ._ageef .AddToken (FmtTypeLiteral ,_fdb [_gdc +1:_aga -1]);};};goto _dbc ;_ecdf :_gdf =(_aga )-1;{_dbg ._ageef .AddToken (FmtTypeFraction ,_fdb [_gdc :_aga ]);};goto _dbc ;_gaa :_gdf =(_aga )-1;{_dbg ._ageef .AddToken (FmtTypeDigitOpt ,nil );};goto _dbc ;_bdd :_aga =_gdf +1;{_dbg ._ageef .AddToken (FmtTypeDigitOptThousands ,nil );};goto _dbc ;_ddcf :_gdf =(_aga )-1;{_dbg ._ageef .AddToken (FmtTypePercent ,nil );};goto _dbc ;_aggb :_gdf =(_aga )-1;{_dbg ._ageef .AddToken (FmtTypeDate ,_fdb [_gdc :_aga ]);};goto _dbc ;_edc :_gdf =(_aga )-1;{_dbg ._ageef .AddToken (FmtTypeDigit ,nil );};goto _dbc ;_abgc :_gdf =(_aga )-1;{_dbg ._ageef .AddToken (FmtTypeTime ,_fdb [_gdc :_aga ]);};goto _dbc ;_eba :_gdf =(_aga )-1;{_dbg ._ageef .AddToken (FmtTypeLiteral ,_fdb [_gdc :_aga ]);};goto _dbc ;_bgg :_aga =_gdf +1;{_dbg ._ageef ._e =true ;};goto _dbc ;_cfb :_aga =_gdf +1;{_dbg ._ageef .AddToken (FmtTypeLiteral ,_fdb [_gdc :_aga ]);};goto _dbc ;_bfe :_aga =_gdf +1;{_dbg ._ageef .AddToken (FmtTypeDollar ,nil );};goto _dbc ;_aae :_aga =_gdf +1;{_dbg ._ageef .AddToken (FmtTypeComma ,nil );};goto _dbc ;_agca :_aga =_gdf +1;{_dbg ._ageef .AddToken (FmtTypeDecimal ,nil );};goto _dbc ;_gdcc :_aga =_gdf +1;{_dbg .nextFmt ();};goto _dbc ;_fda :_aga =_gdf +1;{_dbg ._ageef .AddToken (FmtTypeText ,nil );};goto _dbc ;_gfg :_aga =_gdf +1;{_dbg ._ageef .AddToken (FmtTypeUnderscore ,nil );};goto _dbc ;_gbc :_aga =_gdf ;_gdf --;{_dbg ._ageef .AddToken (FmtTypeLiteral ,_fdb [_gdc :_aga ]);};goto _dbc ;_efcg :_aga =_gdf ;_gdf --;{_dbg ._ageef .AddToken (FmtTypeLiteral ,_fdb [_gdc +1:_aga -1]);};goto _dbc ;_efg :_aga =_gdf ;_gdf --;{_dbg ._ageef .AddToken (FmtTypeDigitOpt ,nil );};goto _dbc ;_dgcfe :_aga =_gdf ;_gdf --;{_dbg ._ageef .AddToken (FmtTypeFraction ,_fdb [_gdc :_aga ]);};goto _dbc ;_efbf :_aga =_gdf ;_gdf --;{_dbg ._ageef .AddToken (FmtTypePercent ,nil );};goto _dbc ;_fgf :_aga =_gdf ;_gdf --;{_dbg ._ageef .AddToken (FmtTypeDate ,_fdb [_gdc :_aga ]);};goto _dbc ;_def :_aga =_gdf ;_gdf --;{_dbg ._ageef .AddToken (FmtTypeDigit ,nil );};goto _dbc ;_agfd :_aga =_gdf ;_gdf --;{_dbg ._ageef .AddToken (FmtTypeTime ,_fdb [_gdc :_aga ]);};goto _dbc ;_gag :_aga =_gdf ;_gdf --;{};goto _dbc ;_aged :_aga =_gdf +1;{_dbg ._ageef .IsExponential =true ;};goto _dbc ;_fafe :_aga =_gdf +1;{_dbg ._ageef .AddToken (FmtTypeLiteral ,_fdb [_gdc +1:_aga ]);};goto _dbc ;_dbc :_gdc =0;if _gdf ++;_gdf ==_ffca {goto _gceb ;};_ege :_gdc =_gdf ;switch _fdb [_gdf ]{case 34:goto _bcg ;case 35:goto _efcf ;case 36:goto _bfe ;case 37:goto _beff ;case 44:goto _aae ;case 46:goto _agca ;case 47:goto _dde ;case 48:goto _aagg ;case 58:goto _gebc ;case 59:goto _gdcc ;case 63:goto _fdg ;case 64:goto _fda ;case 65:goto _dffc ;case 69:goto _ffe ;case 71:goto _gdd ;case 91:goto _dcagc ;case 92:goto _dfbb ;case 95:goto _gfg ;case 100:goto _dde ;case 104:goto _gebc ;case 109:goto _fgaa ;case 115:goto _bec ;case 121:goto _egca ;};if 49<=_fdb [_gdf ]&&_fdb [_gdf ]<=57{goto _aab ;};goto _cfb ;_bcg :_aga =_gdf +1;_fgac =20;goto _ebg ;_ebg :if _gdf ++;_gdf ==_ffca {goto _cgcf ;};_gdcb :if _fdb [_gdf ]==34{goto _fdc ;};goto _gae ;_gae :if _gdf ++;_gdf ==_ffca {goto _ccee ;};_fgea :if _fdb [_gdf ]==34{goto _fdc ;};goto _gae ;_fdc :_aga =_gdf +1;_fgac =21;goto _bcb ;_bcb :if _gdf ++;_gdf ==_ffca {goto _adc ;};_gce :if _fdb [_gdf ]==34{goto _gae ;};goto _efcg ;_efcf :_aga =_gdf +1;_fgac =3;goto _ecdfc ;_ecdfc :if _gdf ++;_gdf ==_ffca {goto _cddc ;};_baaf :switch _fdb [_gdf ]{case 35:goto _ecac ;case 37:goto _ecac ;case 44:goto _dfc ;case 47:goto _bdb ;case 48:goto _ecac ;case 63:goto _ecac ;};goto _efg ;_ecac :if _gdf ++;_gdf ==_ffca {goto _debd ;};_abab :switch _fdb [_gdf ]{case 35:goto _ecac ;case 37:goto _ecac ;case 47:goto _bdb ;case 48:goto _ecac ;case 63:goto _ecac ;};goto _fgg ;_bdb :if _gdf ++;_gdf ==_ffca {goto _fedg ;};_egd :switch _fdb [_gdf ]{case 35:goto _fegaf ;case 37:goto _beac ;case 48:goto _badd ;case 63:goto _fegaf ;};if 49<=_fdb [_gdf ]&&_fdb [_gdf ]<=57{goto _ccc ;};goto _fgg ;_fegaf :_aga =_gdf +1;goto _defd ;_defd :if _gdf ++;_gdf ==_ffca {goto _ddfg ;};_edee :switch _fdb [_gdf ]{case 35:goto _fegaf ;case 37:goto _fegaf ;case 44:goto _fegaf ;case 46:goto _fegaf ;case 48:goto _fegaf ;case 63:goto _fegaf ;case 65:goto _dfb ;};goto _dgcfe ;_dfb :if _gdf ++;_gdf ==_ffca {goto _aeca ;};_ecaf :switch _fdb [_gdf ]{case 47:goto _fbb ;case 77:goto _gfb ;};goto _ecdf ;_fbb :if _gdf ++;_gdf ==_ffca {goto _fffcd ;};_bddb :if _fdb [_gdf ]==80{goto _dgf ;};goto _ecdf ;_dgf :_aga =_gdf +1;goto _ecdd ;_ecdd :if _gdf ++;_gdf ==_ffca {goto _dabc ;};_dac :if _fdb [_gdf ]==65{goto _dfb ;};goto _dgcfe ;_gfb :if _gdf ++;_gdf ==_ffca {goto _bddf ;};_bbg :if _fdb [_gdf ]==47{goto _ecda ;};goto _ecdf ;_ecda :if _gdf ++;_gdf ==_ffca {goto _gbfc ;};_cbc :if _fdb [_gdf ]==80{goto _egdb ;};goto _ecdf ;_egdb :if _gdf ++;_gdf ==_ffca {goto _acae ;};_fddg :if _fdb [_gdf ]==77{goto _dgf ;};goto _ecdf ;_beac :if _gdf ++;_gdf ==_ffca {goto _ggg ;};_aag :switch _fdb [_gdf ]{case 35:goto _geg ;case 37:goto _bfg ;case 63:goto _geg ;};if 48<=_fdb [_gdf ]&&_fdb [_gdf ]<=57{goto _dffe ;};goto _fgg ;_geg :_aga =_gdf +1;goto _ceg ;_ceg :if _gdf ++;_gdf ==_ffca {goto _dada ;};_adg :switch _fdb [_gdf ]{case 35:goto _fegaf ;case 37:goto _febe ;case 44:goto _fegaf ;case 46:goto _fegaf ;case 48:goto _fegaf ;case 63:goto _fegaf ;case 65:goto _dfb ;};goto _dgcfe ;_febe :if _gdf ++;_gdf ==_ffca {goto _abe ;};_gda :switch _fdb [_gdf ]{case 35:goto _afc ;case 44:goto _afc ;case 46:goto _afc ;case 48:goto _afc ;case 63:goto _afc ;};goto _ecdf ;_afc :_aga =_gdf +1;goto _eabf ;_eabf :if _gdf ++;_gdf ==_ffca {goto _gcfd ;};_cgdg :switch _fdb [_gdf ]{case 35:goto _afc ;case 44:goto _afc ;case 46:goto _afc ;case 48:goto _afc ;case 63:goto _afc ;case 65:goto _dfb ;};goto _dgcfe ;_bfg :if _gdf ++;_gdf ==_ffca {goto _bbc ;};_fcbf :if _fdb [_gdf ]==37{goto _bfg ;};if 48<=_fdb [_gdf ]&&_fdb [_gdf ]<=57{goto _dffe ;};goto _fgg ;_dffe :_aga =_gdf +1;_fgac =13;goto _fffc ;_fffc :if _gdf ++;_gdf ==_ffca {goto _feag ;};_cga :switch _fdb [_gdf ]{case 35:goto _fegaf ;case 37:goto _fbd ;case 44:goto _fegaf ;case 46:goto _fegaf ;case 48:goto _bad ;case 63:goto _fegaf ;case 65:goto _dfb ;};if 49<=_fdb [_gdf ]&&_fdb [_gdf ]<=57{goto _dffe ;};goto _dgcfe ;_fbd :if _gdf ++;_gdf ==_ffca {goto _fca ;};_caaa :switch _fdb [_gdf ]{case 35:goto _afc ;case 37:goto _bfg ;case 44:goto _afc ;case 46:goto _afc ;case 63:goto _afc ;};if 48<=_fdb [_gdf ]&&_fdb [_gdf ]<=57{goto _dffe ;};goto _ecdf ;_bad :_aga =_gdf +1;goto _fdbd ;_fdbd :if _gdf ++;_gdf ==_ffca {goto _cecga ;};_gg :switch _fdb [_gdf ]{case 35:goto _fegaf ;case 37:goto _bad ;case 44:goto _fegaf ;case 46:goto _fegaf ;case 48:goto _bad ;case 63:goto _fegaf ;case 65:goto _dfb ;};if 49<=_fdb [_gdf ]&&_fdb [_gdf ]<=57{goto _dffe ;};goto _dgcfe ;_badd :_aga =_gdf +1;goto _daf ;_daf :if _gdf ++;_gdf ==_ffca {goto _bcc ;};_eec :switch _fdb [_gdf ]{case 35:goto _fegaf ;case 37:goto _bad ;case 44:goto _fegaf ;case 46:goto _fegaf ;case 48:goto _badd ;case 63:goto _fegaf ;case 65:goto _dfb ;};if 49<=_fdb [_gdf ]&&_fdb [_gdf ]<=57{goto _ccc ;};goto _dgcfe ;_ccc :_aga =_gdf +1;goto _fbbf ;_fbbf :if _gdf ++;_gdf ==_ffca {goto _fefd ;};_fbc :switch _fdb [_gdf ]{case 35:goto _fegaf ;case 37:goto _dffe ;case 44:goto _fegaf ;case 46:goto _fegaf ;case 48:goto _badd ;case 63:goto _fegaf ;case 65:goto _dfb ;};if 49<=_fdb [_gdf ]&&_fdb [_gdf ]<=57{goto _ccc ;};goto _dgcfe ;_dfc :if _gdf ++;_gdf ==_ffca {goto _bcfe ;};_gaff :if _fdb [_gdf ]==35{goto _bdd ;};goto _gaa ;_beff :_aga =_gdf +1;_fgac =8;goto _ddg ;_ddg :if _gdf ++;_gdf ==_ffca {goto _aebc ;};_cdb :switch _fdb [_gdf ]{case 35:goto _ecgc ;case 37:goto _eeb ;case 48:goto _dcag ;case 63:goto _ecgc ;};if 49<=_fdb [_gdf ]&&_fdb [_gdf ]<=57{goto _fcd ;};goto _efbf ;_ecgc :if _gdf ++;_gdf ==_ffca {goto _dadc ;};_egef :switch _fdb [_gdf ]{case 35:goto _ecgc ;case 47:goto _bdb ;case 48:goto _ecgc ;case 63:goto _ecgc ;};goto _ddcf ;_eeb :if _gdf ++;_gdf ==_ffca {goto _febg ;};_dece :if _fdb [_gdf ]==37{goto _eeb ;};if 48<=_fdb [_gdf ]&&_fdb [_gdf ]<=57{goto _fcd ;};goto _fgg ;_fcd :if _gdf ++;_gdf ==_ffca {goto _eabc ;};_dag :switch _fdb [_gdf ]{case 37:goto _eeb ;case 47:goto _bdb ;};if 48<=_fdb [_gdf ]&&_fdb [_gdf ]<=57{goto _fcd ;};goto _fgg ;_dcag :if _gdf ++;_gdf ==_ffca {goto _gggd ;};_fde :switch _fdb [_gdf ]{case 35:goto _ecgc ;case 37:goto _eeb ;case 47:goto _bdb ;case 48:goto _dcag ;case 63:goto _ecgc ;};if 49<=_fdb [_gdf ]&&_fdb [_gdf ]<=57{goto _fcd ;};goto _ddcf ;_dde :_aga =_gdf +1;goto _ace ;_ace :if _gdf ++;_gdf ==_ffca {goto _gfc ;};_egb :switch _fdb [_gdf ]{case 47:goto _dde ;case 100:goto _dde ;case 109:goto _dde ;case 121:goto _cdeg ;};goto _fgf ;_cdeg :if _gdf ++;_gdf ==_ffca {goto _cgaf ;};_eea :if _fdb [_gdf ]==121{goto _dde ;};goto _aggb ;_aagg :_aga =_gdf +1;_fgac =2;goto _bee ;_bee :if _gdf ++;_gdf ==_ffca {goto _dbgc ;};_fgdb :switch _fdb [_gdf ]{case 35:goto _ecac ;case 37:goto _eaa ;case 47:goto _bdb ;case 48:goto _efbc ;case 63:goto _ecac ;};if 49<=_fdb [_gdf ]&&_fdb [_gdf ]<=57{goto _edg ;};goto _def ;_eaa :if _gdf ++;_gdf ==_ffca {goto _cgbc ;};_baea :switch _fdb [_gdf ]{case 35:goto _ecac ;case 37:goto _eaa ;case 47:goto _bdb ;case 48:goto _eaa ;case 63:goto _ecac ;};if 49<=_fdb [_gdf ]&&_fdb [_gdf ]<=57{goto _fcd ;};goto _edc ;_efbc :if _gdf ++;_gdf ==_ffca {goto _ceea ;};_gbff :switch _fdb [_gdf ]{case 35:goto _ecac ;case 37:goto _eaa ;case 47:goto _bdb ;case 48:goto _efbc ;case 63:goto _ecac ;};if 49<=_fdb [_gdf ]&&_fdb [_gdf ]<=57{goto _edg ;};goto _edc ;_edg :if _gdf ++;_gdf ==_ffca {goto _eeaf ;};_ebc :switch _fdb [_gdf ]{case 37:goto _fcd ;case 47:goto _bdb ;};if 48<=_fdb [_gdf ]&&_fdb [_gdf ]<=57{goto _edg ;};goto _fgg ;_aab :_aga =_gdf +1;_fgac =20;goto _bbfg ;_bbfg :if _gdf ++;_gdf ==_ffca {goto _gbcd ;};_bfac :switch _fdb [_gdf ]{case 37:goto _fcd ;case 47:goto _bdb ;};if 48<=_fdb [_gdf ]&&_fdb [_gdf ]<=57{goto _edg ;};goto _gbc ;_gebc :_aga =_gdf +1;_fgac =15;goto _efd ;_efd :if _gdf ++;_gdf ==_ffca {goto _eggb ;};_abgf :switch _fdb [_gdf ]{case 58:goto _gebc ;case 65:goto _cgab ;case 104:goto _gebc ;case 109:goto _gebc ;case 115:goto _bec ;};goto _agfd ;_cgab :if _gdf ++;_gdf ==_ffca {goto _bcgd ;};_ddgg :switch _fdb [_gdf ]{case 47:goto _ddga ;case 77:goto _cbe ;};goto _fgg ;_ddga :if _gdf ++;_gdf ==_ffca {goto _egcd ;};_adga :if _fdb [_gdf ]==80{goto _gebc ;};goto _fgg ;_cbe :if _gdf ++;_gdf ==_ffca {goto _ceeg ;};_bbgc :if _fdb [_gdf ]==47{goto _fdad ;};goto _fgg ;_fdad :if _gdf ++;_gdf ==_ffca {goto _dgcg ;};_eeaa :if _fdb [_gdf ]==80{goto _eaeb ;};goto _fgg ;_eaeb :if _gdf ++;_gdf ==_ffca {goto _ffd ;};_ddd :if _fdb [_gdf ]==77{goto _gebc ;};goto _fgg ;_bec :_aga =_gdf +1;_fgac =15;goto _fedb ;_fedb :if _gdf ++;_gdf ==_ffca {goto _ddec ;};_abbc :switch _fdb [_gdf ]{case 46:goto _fecd ;case 58:goto _gebc ;case 65:goto _cgab ;case 104:goto _gebc ;case 109:goto _gebc ;case 115:goto _bec ;};goto _agfd ;_fecd :if _gdf ++;_gdf ==_ffca {goto _efbdc ;};_gbdd :if _fdb [_gdf ]==48{goto _ccbg ;};goto _abgc ;_ccbg :_aga =_gdf +1;_fgac =15;goto _acfa ;_acfa :if _gdf ++;_gdf ==_ffca {goto _gcg ;};_bdac :switch _fdb [_gdf ]{case 48:goto _cgcd ;case 58:goto _gebc ;case 65:goto _cgab ;case 104:goto _gebc ;case 109:goto _gebc ;case 115:goto _bec ;};goto _agfd ;_cgcd :_aga =_gdf +1;_fgac =15;goto _cbeb ;_cbeb :if _gdf ++;_gdf ==_ffca {goto _eebc ;};_gbdeb :switch _fdb [_gdf ]{case 48:goto _gebc ;case 58:goto _gebc ;case 65:goto _cgab ;case 104:goto _gebc ;case 109:goto _gebc ;case 115:goto _bec ;};goto _agfd ;_fdg :_aga =_gdf +1;_fgac =5;goto _daa ;_daa :if _gdf ++;_gdf ==_ffca {goto _eggd ;};_gde :switch _fdb [_gdf ]{case 35:goto _ecac ;case 37:goto _ecac ;case 47:goto _bdb ;case 48:goto _ecac ;case 63:goto _ecac ;};goto _gag ;_dffc :_aga =_gdf +1;_fgac =20;goto _aef ;_aef :if _gdf ++;_gdf ==_ffca {goto _cfc ;};_ecc :switch _fdb [_gdf ]{case 47:goto _ddga ;case 77:goto _cbe ;};goto _gbc ;_ffe :if _gdf ++;_gdf ==_ffca {goto _eafa ;};_bbfc :switch _fdb [_gdf ]{case 43:goto _aged ;case 45:goto _aged ;};goto _gbc ;_gdd :_aga =_gdf +1;goto _bcf ;_bcf :if _gdf ++;_gdf ==_ffca {goto _fgbe ;};_dab :if _fdb [_gdf ]==101{goto _dae ;};goto _gbc ;_dae :if _gdf ++;_gdf ==_ffca {goto _fdf ;};_ccf :if _fdb [_gdf ]==110{goto _gfbg ;};goto _eba ;_gfbg :if _gdf ++;_gdf ==_ffca {goto _adf ;};_gca :if _fdb [_gdf ]==101{goto _faa ;};goto _eba ;_faa :if _gdf ++;_gdf ==_ffca {goto _acbe ;};_dgbd :if _fdb [_gdf ]==114{goto _ffa ;};goto _eba ;_ffa :if _gdf ++;_gdf ==_ffca {goto _cdfba ;};_efcb :if _fdb [_gdf ]==97{goto _edb ;};goto _eba ;_edb :if _gdf ++;_gdf ==_ffca {goto _ccba ;};_fad :if _fdb [_gdf ]==108{goto _bgg ;};goto _eba ;_dcagc :_aga =_gdf +1;_fgac =20;goto _fgbd ;_fgbd :if _gdf ++;_gdf ==_ffca {goto _dgcfd ;};_cgaa :switch _fdb [_gdf ]{case 104:goto _ecb ;case 109:goto _ecb ;case 115:goto _ecb ;};goto _aeb ;_aeb :if _gdf ++;_gdf ==_ffca {goto _ffff ;};_cdbg :if _fdb [_gdf ]==93{goto _egbg ;};goto _aeb ;_egbg :_aga =_gdf +1;_fgac =18;goto _feadc ;_bbgf :_aga =_gdf +1;_fgac =16;goto _feadc ;_feadc :if _gdf ++;_gdf ==_ffca {goto _ddee ;};_bcd :if _fdb [_gdf ]==93{goto _egbg ;};goto _aeb ;_ecb :if _gdf ++;_gdf ==_ffca {goto _cbde ;};_ddb :if _fdb [_gdf ]==93{goto _bbgf ;};goto _aeb ;_dfbb :if _gdf ++;_gdf ==_ffca {goto _bead ;};_ccfg :goto _fafe ;_fgaa :_aga =_gdf +1;_fgac =14;goto _aggd ;_aggd :if _gdf ++;_gdf ==_ffca {goto _ced ;};_bdaf :switch _fdb [_gdf ]{case 47:goto _dde ;case 58:goto _gebc ;case 65:goto _cgab ;case 100:goto _dde ;case 104:goto _gebc ;case 109:goto _fgaa ;case 115:goto _bec ;case 121:goto _cdeg ;};goto _fgf ;_egca :if _gdf ++;_gdf ==_ffca {goto _aeee ;};_cecg :if _fdb [_gdf ]==121{goto _dde ;};goto _gbc ;_gagg :_gceb :_gbe =34;goto _ceb ;_cgcf :_gbe =35;goto _ceb ;_ccee :_gbe =0;goto _ceb ;_adc :_gbe =36;goto _ceb ;_cddc :_gbe =37;goto _ceb ;_debd :_gbe =1;goto _ceb ;_fedg :_gbe =2;goto _ceb ;_ddfg :_gbe =38;goto _ceb ;_aeca :_gbe =3;goto _ceb ;_fffcd :_gbe =4;goto _ceb ;_dabc :_gbe =39;goto _ceb ;_bddf :_gbe =5;goto _ceb ;_gbfc :_gbe =6;goto _ceb ;_acae :_gbe =7;goto _ceb ;_ggg :_gbe =8;goto _ceb ;_dada :_gbe =40;goto _ceb ;_abe :_gbe =9;goto _ceb ;_gcfd :_gbe =41;goto _ceb ;_bbc :_gbe =10;goto _ceb ;_feag :_gbe =42;goto _ceb ;_fca :_gbe =11;goto _ceb ;_cecga :_gbe =43;goto _ceb ;_bcc :_gbe =44;goto _ceb ;_fefd :_gbe =45;goto _ceb ;_bcfe :_gbe =12;goto _ceb ;_aebc :_gbe =46;goto _ceb ;_dadc :_gbe =13;goto _ceb ;_febg :_gbe =14;goto _ceb ;_eabc :_gbe =15;goto _ceb ;_gggd :_gbe =16;goto _ceb ;_gfc :_gbe =47;goto _ceb ;_cgaf :_gbe =17;goto _ceb ;_dbgc :_gbe =48;goto _ceb ;_cgbc :_gbe =18;goto _ceb ;_ceea :_gbe =19;goto _ceb ;_eeaf :_gbe =20;goto _ceb ;_gbcd :_gbe =49;goto _ceb ;_eggb :_gbe =50;goto _ceb ;_bcgd :_gbe =21;goto _ceb ;_egcd :_gbe =22;goto _ceb ;_ceeg :_gbe =23;goto _ceb ;_dgcg :_gbe =24;goto _ceb ;_ffd :_gbe =25;goto _ceb ;_ddec :_gbe =51;goto _ceb ;_efbdc :_gbe =26;goto _ceb ;_gcg :_gbe =52;goto _ceb ;_eebc :_gbe =53;goto _ceb ;_eggd :_gbe =54;goto _ceb ;_cfc :_gbe =55;goto _ceb ;_eafa :_gbe =56;goto _ceb ;_fgbe :_gbe =57;goto _ceb ;_fdf :_gbe =27;goto _ceb ;_adf :_gbe =28;goto _ceb ;_acbe :_gbe =29;goto _ceb ;_cdfba :_gbe =30;goto _ceb ;_ccba :_gbe =31;goto _ceb ;_dgcfd :_gbe =58;goto _ceb ;_ffff :_gbe =32;goto _ceb ;_ddee :_gbe =59;goto _ceb ;_cbde :_gbe =33;goto _ceb ;_bead :_gbe =60;goto _ceb ;_ced :_gbe =61;goto _ceb ;_aeee :_gbe =62;goto _ceb ;_ceb :{};if _gdf ==_bbea {switch _gbe {case 35:goto _gbc ;case 0:goto _fgg ;case 36:goto _efcg ;case 37:goto _efg ;case 1:goto _fgg ;case 2:goto _fgg ;case 38:goto _dgcfe ;case 3:goto _ecdf ;case 4:goto _ecdf ;case 39:goto _dgcfe ;case 5:goto _ecdf ;case 6:goto _ecdf ;case 7:goto _ecdf ;case 8:goto _fgg ;case 40:goto _dgcfe ;case 9:goto _ecdf ;case 41:goto _dgcfe ;case 10:goto _fgg ;case 42:goto _dgcfe ;case 11:goto _ecdf ;case 43:goto _dgcfe ;case 44:goto _dgcfe ;case 45:goto _dgcfe ;case 12:goto _gaa ;case 46:goto _efbf ;case 13:goto _ddcf ;case 14:goto _fgg ;case 15:goto _fgg ;case 16:goto _ddcf ;case 47:goto _fgf ;case 17:goto _aggb ;case 48:goto _def ;case 18:goto _edc ;case 19:goto _edc ;case 20:goto _fgg ;case 49:goto _gbc ;case 50:goto _agfd ;case 21:goto _fgg ;case 22:goto _fgg ;case 23:goto _fgg ;case 24:goto _fgg ;case 25:goto _fgg ;case 51:goto _agfd ;case 26:goto _abgc ;case 52:goto _agfd ;case 53:goto _agfd ;case 54:goto _gag ;case 55:goto _gbc ;case 56:goto _gbc ;case 57:goto _gbc ;case 27:goto _eba ;case 28:goto _eba ;case 29:goto _eba ;case 30:goto _eba ;case 31:goto _eba ;case 58:goto _gbc ;case 32:goto _fgg ;case 59:goto _fgg ;case 33:goto _eba ;case 60:goto _gbc ;case 61:goto _fgf ;case 62:goto _gbc ;};};};if _gdc > 0{copy (_fdb [0:],_fdb [_gdc :]);};};_ =_bbea ;if _gbe ==_faf {_dg .Log ("\u0066o\u0072m\u0061\u0074\u0020\u0070\u0061r\u0073\u0065 \u0065\u0072\u0072\u006f\u0072");};};func _cec (_fa ,_feg float64 ,_cae Format )[]byte {if len (_cae .Fractional )==0{return nil ;};_efb :=_ae .AppendFloat (nil ,_fa ,'f',-1,64);if len (_efb )> 2{_efb =_efb [2:];}else {_efb =nil ;};_bfb :=make ([]byte ,0,len (_efb ));_bfb =append (_bfb ,'.');_efbd :=0;_cdg :for _cee :=0;_cee < len (_cae .Fractional );_cee ++{_fae :=_cee ;_dgce :=_cae .Fractional [_cee ];switch _dgce .Type {case FmtTypeDigit :if _fae < len (_efb ){_bfb =append (_bfb ,_efb [_fae ]);_efbd ++;}else {_bfb =append (_bfb ,'0');};case FmtTypeDigitOpt :if _fae >=0{_bfb =append (_bfb ,_efb [_fae ]);_efbd ++;}else {break _cdg ;};case FmtTypeLiteral :_bfb =append (_bfb ,_dgce .Literal );default:_dg .Log ("\u0075\u006e\u0073\u0075\u0070\u0070o\u0072\u0074\u0065\u0064\u0020\u0074\u0079\u0070\u0065\u0020\u0069\u006e\u0020f\u0072\u0061\u0063\u0074\u0069\u006f\u006ea\u006c\u0020\u0025\u0076",_dgce );};};return _bfb ;};func _cab (_bc []byte )[]byte {for _ffc :=0;_ffc < len (_bc )/2;_ffc ++{_ge :=len (_bc )-1-_ffc ;_bc [_ffc ],_bc [_ge ]=_bc [_ge ],_bc [_ffc ];};return _bc ;};func _gd (_abgb float64 )string {_df :=_ae .FormatFloat (_abgb ,'E',-1,64);_bef :=_ae .FormatFloat (_abgb ,'E',5,64);if len (_df )< len (_bef ){return _ae .FormatFloat (_abgb ,'E',2,64);};return _bef ;};const _fffb int =34;func _dcb (_aeaa _b .Time ,_bg float64 ,_abb string )[]byte {_cdfb :=[]byte {};_gef :=0;for _aad :=0;_aad < len (_abb );_aad ++{var _ddcg string ;if _abb [_aad ]==':'{_ddcg =string (_abb [_gef :_aad ]);_gef =_aad +1;}else if _aad ==len (_abb )-1{_ddcg =string (_abb [_gef :_aad +1]);}else {continue ;};switch _ddcg {case "\u0064":_cdfb =_aeaa .AppendFormat (_cdfb ,"\u0032");case "\u0068":_cdfb =_aeaa .AppendFormat (_cdfb ,"\u0033");case "\u0068\u0068":_cdfb =_aeaa .AppendFormat (_cdfb ,"\u0031\u0035");case "\u006d":_cdfb =_aeaa .AppendFormat (_cdfb ,"\u0034");case "\u006d\u006d":_cdfb =_aeaa .AppendFormat (_cdfb ,"\u0030\u0034");case "\u0073":_cdfb =_aeaa .Round (_b .Second ).AppendFormat (_cdfb ,"\u0035");case "\u0073\u002e\u0030":_cdfb =_aeaa .Round (_b .Second /10).AppendFormat (_cdfb ,"\u0035\u002e\u0030");case "\u0073\u002e\u0030\u0030":_cdfb =_aeaa .Round (_b .Second /100).AppendFormat (_cdfb ,"\u0035\u002e\u0030\u0030");case "\u0073\u002e\u00300\u0030":_cdfb =_aeaa .Round (_b .Second /1000).AppendFormat (_cdfb ,"\u0035\u002e\u00300\u0030");case "\u0073\u0073":_cdfb =_aeaa .Round (_b .Second ).AppendFormat (_cdfb ,"\u0030\u0035");case "\u0073\u0073\u002e\u0030":_cdfb =_aeaa .Round (_b .Second /10).AppendFormat (_cdfb ,"\u0030\u0035\u002e\u0030");case "\u0073\u0073\u002e0\u0030":_cdfb =_aeaa .Round (_b .Second /100).AppendFormat (_cdfb ,"\u0030\u0035\u002e0\u0030");case "\u0073\u0073\u002e\u0030\u0030\u0030":_cdfb =_aeaa .Round (_b .Second /1000).AppendFormat (_cdfb ,"\u0030\u0035\u002e\u0030\u0030\u0030");case "\u0041\u004d\u002fP\u004d":_cdfb =_aeaa .AppendFormat (_cdfb ,"\u0050\u004d");case "\u005b\u0068\u005d":_cdfb =_ae .AppendInt (_cdfb ,int64 (_bg *24),10);case "\u005b\u006d\u005d":_cdfb =_ae .AppendInt (_cdfb ,int64 (_bg *24*60),10);case "\u005b\u0073\u005d":_cdfb =_ae .AppendInt (_cdfb ,int64 (_bg *24*60*60),10);case "":default:_dg .Log ("\u0075\u006e\u0073\u0075\u0070\u0070\u006f\u0072\u0074\u0065\u0064 \u0074\u0069\u006d\u0065\u0020\u0066\u006f\u0072\u006d\u0061t\u0020\u0025\u0073",_ddcg );};if _abb [_aad ]==':'{_cdfb =append (_cdfb ,':');};};return _cdfb ;};func (_ac FmtType )String ()string {if _ac >=FmtType (len (_dga )-1){return _a .Sprintf ("F\u006d\u0074\u0054\u0079\u0070\u0065\u0028\u0025\u0064\u0029",_ac );};return _cg [_dga [_ac ]:_dga [_ac +1]];};const _fga int =-1;func _dca (_dgb []byte )[]byte {_egg :=len (_dgb );_fefa :=false ;_cacc :=false ;for _cca :=len (_dgb )-1;_cca >=0;_cca --{if _dgb [_cca ]=='0'&&!_cacc &&!_fefa {_egg =_cca ;}else if _dgb [_cca ]=='.'{_fefa =true ;}else {_cacc =true ;};};if _fefa &&_cacc {if _dgb [_egg -1]=='.'{_egg --;};return _dgb [0:_egg ];};return _dgb ;};var _dga =[...]uint8 {0,14,26,41,53,67,81,94,118,135,146,157,172,183};const _cg ="\u0046\u006d\u0074\u0054\u0079\u0070\u0065\u004c\u0069\u0074\u0065\u0072a\u006c\u0046\u006d\u0074\u0054\u0079\u0070\u0065\u0044\u0069\u0067\u0069\u0074\u0046\u006d\u0074\u0054y\u0070\u0065\u0044i\u0067\u0069\u0074\u004f\u0070\u0074\u0046\u006d\u0074\u0054\u0079\u0070\u0065\u0043o\u006d\u006d\u0061\u0046\u006d\u0074\u0054\u0079\u0070\u0065\u0044\u0065\u0063\u0069\u006da\u006c\u0046\u006d\u0074\u0054\u0079\u0070\u0065Pe\u0072\u0063e\u006e\u0074\u0046\u006d\u0074\u0054\u0079\u0070e\u0044\u006f\u006c\u006c\u0061\u0072\u0046\u006d\u0074Ty\u0070\u0065\u0044i\u0067\u0069\u0074\u004f\u0070\u0074\u0054\u0068\u006f\u0075\u0073\u0061n\u0064\u0073\u0046\u006d\u0074\u0054\u0079\u0070\u0065\u0055n\u0064\u0065\u0072\u0073c\u006f\u0072\u0065\u0046\u006d\u0074T\u0079\u0070\u0065\u0044\u0061\u0074\u0065\u0046\u006d\u0074\u0054y\u0070e\u0054\u0069\u006d\u0065\u0046\u006d\u0074\u0054\u0079\u0070\u0065\u0046\u0072\u0061\u0063t\u0069\u006f\u006e\u0046\u006dt\u0054\u0079\u0070\u0065\u0054e\u0078\u0074";const (FmtTypeLiteral FmtType =iota ;FmtTypeDigit ;FmtTypeDigitOpt ;FmtTypeComma ;FmtTypeDecimal ;FmtTypePercent ;FmtTypeDollar ;FmtTypeDigitOptThousands ;FmtTypeUnderscore ;FmtTypeDate ;FmtTypeTime ;FmtTypeFraction ;FmtTypeText ;);func Parse (s string )[]Format {_eded :=Lexer {};_eded .Lex (_g .NewReader (s ));_eded ._gebb =append (_eded ._gebb ,_eded ._ageef );return _eded ._gebb ;};const _ca =1e11;const _bba int =0;func _ebf (_cdbe _b .Time )_b .Time {_cdbe =_cdbe .UTC ();return _b .Date (_cdbe .Year (),_cdbe .Month (),_cdbe .Day (),_cdbe .Hour (),_cdbe .Minute (),_cdbe .Second (),_cdbe .Nanosecond (),_b .Local );};func _bbf (_cag ,_fcg float64 ,_cbb Format )[]byte {if len (_cbb .Whole )==0{return nil ;};_ccb :=_b .Date (1899,12,30,0,0,0,0,_b .UTC );_ab :=_ccb .Add (_b .Duration (_fcg *float64 (24*_b .Hour )));_ab =_ebf (_ab );_fef :=_ae .AppendFloat (nil ,_cag ,'f',-1,64);_bdg :=make ([]byte ,0,len (_fef ));_cac :=0;_cef :=1;_baa :for _dgcf :=len (_cbb .Whole )-1;_dgcf >=0;_dgcf --{_aec :=len (_fef )-1-_cac ;_dgaa :=_cbb .Whole [_dgcf ];switch _dgaa .Type {case FmtTypeDigit :if _aec >=0{_bdg =append (_bdg ,_fef [_aec ]);_cac ++;_cef =_dgcf ;}else {_bdg =append (_bdg ,'0');};case FmtTypeDigitOpt :if _aec >=0{_bdg =append (_bdg ,_fef [_aec ]);_cac ++;_cef =_dgcf ;}else {for _bab :=_dgcf ;_bab >=0;_bab --{_cdf :=_cbb .Whole [_bab ];if _cdf .Type ==FmtTypeLiteral {_bdg =append (_bdg ,_cdf .Literal );};};break _baa ;};case FmtTypeDollar :for _ea :=_cac ;_ea < len (_fef );_ea ++{_bdg =append (_bdg ,_fef [len (_fef )-1-_ea ]);_cac ++;};_bdg =append (_bdg ,'$');case FmtTypeComma :if !_cbb ._bb {_bdg =append (_bdg ,',');};case FmtTypeLiteral :_bdg =append (_bdg ,_dgaa .Literal );case FmtTypeDate :_bdg =append (_bdg ,_cab (_cce (_ab ,_dgaa .DateTime ))...);case FmtTypeTime :_bdg =append (_bdg ,_cab (_dcb (_ab ,_fcg ,_dgaa .DateTime ))...);default:_dg .Log ("\u0075\u006e\u0073\u0075p\u0070\u006f\u0072\u0074\u0065\u0064\u0020\u0074\u0079\u0070e\u0020i\u006e\u0020\u0077\u0068\u006f\u006c\u0065 \u0025\u0076",_dgaa );};};_gcd :=_cab (_bdg );if _cac < len (_fef )&&(_cac !=0||_cbb ._gbf ){_ddf :=len (_fef )-_cac ;_be :=make ([]byte ,len (_gcd )+_ddf );copy (_be ,_gcd [0:_cef ]);copy (_be [_cef :],_fef [0:]);copy (_be [_cef +_ddf :],_gcd [_cef :]);_gcd =_be ;};if _cbb ._bb {_dad :=_c .Buffer {};_gee :=0;for _dec :=len (_gcd )-1;_dec >=0;_dec --{if !(_gcd [_dec ]>='0'&&_gcd [_dec ]<='9'){_gee ++;}else {break ;};};for _aa :=0;_aa < len (_gcd );_aa ++{_feb :=(len (_gcd )-_aa -_gee );if _feb %3==0&&_feb !=0&&_aa !=0{_dad .WriteByte (',');};_dad .WriteByte (_gcd [_aa ]);};_gcd =_dad .Bytes ();};return _gcd ;};const _da =1e-10;const _aee int =34;
|
|
|
|
// Format is a parsed number format.
|
|
type Format struct{Whole []Token ;Fractional []Token ;Exponent []Token ;IsExponential bool ;_de bool ;_ga bool ;_e bool ;_bb bool ;_fb bool ;_gbf bool ;_ff int64 ;_db int ;};
|
|
|
|
// FmtType is the type of a format token.
|
|
//go:generate stringer -type=FmtType
|
|
type FmtType byte ;type Lexer struct{_ageef Format ;_gebb []Format ;};const _bbfa int =34;
|
|
|
|
// Number is used to format a number with a format string. If the format
|
|
// string is empty, then General number formatting is used which attempts to mimic
|
|
// Excel's general formatting.
|
|
func Number (v float64 ,f string )string {if f ==""||f =="\u0047e\u006e\u0065\u0072\u0061\u006c"||f =="\u0040"{return NumberGeneric (v );};_dc :=Parse (f );if len (_dc )==1{return _aca (v ,_dc [0],false );}else if len (_dc )> 1&&v < 0{return _aca (v ,_dc [1],true );}else if len (_dc )> 2&&v ==0{return _aca (v ,_dc [2],false );};return _aca (v ,_dc [0],false );};const _faf int =-1;
|
|
|
|
// AddToken adds a format token to the format.
|
|
func (_dgc *Format )AddToken (t FmtType ,l []byte ){if _dgc ._fb {_dgc ._fb =false ;return ;};switch t {case FmtTypeDecimal :_dgc ._gbf =true ;case FmtTypeUnderscore :_dgc ._fb =true ;case FmtTypeText :_dgc .Whole =append (_dgc .Whole ,Token {Type :t });case FmtTypeDate ,FmtTypeTime :_dgc .Whole =append (_dgc .Whole ,Token {Type :t ,DateTime :string (l )});case FmtTypePercent :_dgc ._ga =true ;t =FmtTypeLiteral ;l =[]byte {'%'};fallthrough;case FmtTypeDigitOpt :fallthrough;case FmtTypeLiteral ,FmtTypeDigit ,FmtTypeDollar ,FmtTypeComma :if l ==nil {l =[]byte {0};};for _ ,_fd :=range l {if _dgc .IsExponential {_dgc .Exponent =append (_dgc .Exponent ,Token {Type :t ,Literal :_fd });}else if !_dgc ._gbf {_dgc .Whole =append (_dgc .Whole ,Token {Type :t ,Literal :_fd });}else {_dgc .Fractional =append (_dgc .Fractional ,Token {Type :t ,Literal :_fd });};};case FmtTypeDigitOptThousands :_dgc ._bb =true ;case FmtTypeFraction :_ec :=_g .Split (string (l ),"\u002f");if len (_ec )==2{_dgc ._de =true ;_dgc ._ff ,_ =_ae .ParseInt (_ec [1],10,64);for _ ,_agf :=range _ec [1]{if _agf =='?'||_agf =='0'{_dgc ._db ++;};};};default:_dg .Log ("\u0075\u006e\u0073u\u0070\u0070\u006f\u0072t\u0065\u0064\u0020\u0070\u0068\u0020\u0074y\u0070\u0065\u0020\u0069\u006e\u0020\u0070\u0061\u0072\u0073\u0065\u0020\u0025\u0076",t );};};const _aeac int =0;
|
|
|
|
// Token is a format token in the Excel format string.
|
|
type Token struct{Type FmtType ;Literal byte ;DateTime string ;};func IsNumber (data string )(_aba bool ){_beb ,_ecg ,_gbde :=0,0,len (data );_bebb :=len (data );_ade ,_cfg ,_fgee :=0,0,0;_ =_cfg ;_ =_fgee ;_ =_ade ;{_beb =_bba ;_ade =0;_cfg =0;_fgee =0;};{if _ecg ==_gbde {goto _eaf ;};switch _beb {case 0:goto _ccgb ;case 1:goto _fed ;case 2:goto _cfe ;case 3:goto _agg ;case 4:goto _aaf ;case 5:goto _bae ;case 6:goto _cgc ;case 7:goto _dff ;};goto _eca ;_fgb :_cfg =_ecg ;_ecg --;{_aba =false ;};goto _bfa ;_fead :_cfg =_ecg ;_ecg --;{_aba =_cfg ==len (data );};goto _bfa ;_cacf :_cfg =_ecg ;_ecg --;{_aba =_cfg ==len (data );};goto _bfa ;_efa :switch _fgee {case 2:{_ecg =(_cfg )-1;_aba =_cfg ==len (data );};case 3:{_ecg =(_cfg )-1;_aba =false ;};};goto _bfa ;_bfa :_ade =0;if _ecg ++;_ecg ==_gbde {goto _fcgg ;};_ccgb :_ade =_ecg ;switch data [_ecg ]{case 43:goto _af ;case 45:goto _af ;};if 48<=data [_ecg ]&&data [_ecg ]<=57{goto _eab ;};goto _acb ;_acb :if _ecg ++;_ecg ==_gbde {goto _ecd ;};_fed :goto _acb ;_af :if _ecg ++;_ecg ==_gbde {goto _gcdf ;};_cfe :if 48<=data [_ecg ]&&data [_ecg ]<=57{goto _eab ;};goto _acb ;_eab :if _ecg ++;_ecg ==_gbde {goto _bda ;};_agg :if data [_ecg ]==46{goto _bfaa ;};if 48<=data [_ecg ]&&data [_ecg ]<=57{goto _eab ;};goto _acb ;_bfaa :if _ecg ++;_ecg ==_gbde {goto _fega ;};_aaf :if 48<=data [_ecg ]&&data [_ecg ]<=57{goto _abbg ;};goto _acb ;_abbg :if _ecg ++;_ecg ==_gbde {goto _eff ;};_bae :if data [_ecg ]==69{goto _fcb ;};if 48<=data [_ecg ]&&data [_ecg ]<=57{goto _abbg ;};goto _acb ;_fcb :if _ecg ++;_ecg ==_gbde {goto _agee ;};_cgc :switch data [_ecg ]{case 43:goto _gff ;case 45:goto _gff ;};goto _acb ;_gff :_cfg =_ecg +1;_fgee =3;goto _gfff ;_gaf :_cfg =_ecg +1;_fgee =2;goto _gfff ;_gfff :if _ecg ++;_ecg ==_gbde {goto _cgb ;};_dff :if 48<=data [_ecg ]&&data [_ecg ]<=57{goto _gaf ;};goto _acb ;_eca :_fcgg :_beb =0;goto _eaf ;_ecd :_beb =1;goto _eaf ;_gcdf :_beb =2;goto _eaf ;_bda :_beb =3;goto _eaf ;_fega :_beb =4;goto _eaf ;_eff :_beb =5;goto _eaf ;_agee :_beb =6;goto _eaf ;_cgb :_beb =7;goto _eaf ;_eaf :{};if _ecg ==_bebb {switch _beb {case 1:goto _fgb ;case 2:goto _fgb ;case 3:goto _fead ;case 4:goto _fgb ;case 5:goto _cacf ;case 6:goto _fgb ;case 7:goto _efa ;};};};if _beb ==_faf {return false ;};return ;};
|
|
|
|
// String returns the string formatted according to the type. In format strings
|
|
// this is the fourth item, where '@' is used as a placeholder for text.
|
|
func String (v string ,f string )string {_gc :=Parse (f );var _fe Format ;if len (_gc )==1{_fe =_gc [0];}else if len (_gc )==4{_fe =_gc [3];};_fg :=false ;for _ ,_ce :=range _fe .Whole {if _ce .Type ==FmtTypeText {_fg =true ;};};if !_fg {return v ;};_bd :=_c .Buffer {};for _ ,_bbd :=range _fe .Whole {switch _bbd .Type {case FmtTypeLiteral :_bd .WriteByte (_bbd .Literal );case FmtTypeText :_bd .WriteString (v );};};return _bd .String ();};
|
|
|
|
// NumberGeneric formats the number with the generic format which attemps to
|
|
// mimic Excel's general formatting.
|
|
func NumberGeneric (v float64 )string {if _gb .Abs (v )>=_ca ||_gb .Abs (v )<=_da &&v !=0{return _gd (v );};_gbd :=make ([]byte ,0,15);_gbd =_ae .AppendFloat (_gbd ,v ,'f',-1,64);if len (_gbd )> 11{_geb :=_gbd [11]-'0';if _geb >=5&&_geb <=9{_gbd [10]++;_gbd =_gbd [0:11];_gbd =_bce (_gbd );};_gbd =_gbd [0:11];}else if len (_gbd )==11{if _gbd [len (_gbd )-1]=='9'{_gbd [len (_gbd )-1]++;_gbd =_bce (_gbd );};};_gbd =_dca (_gbd );return string (_gbd );}; |