excelize/numfmt_test.go

201 lines
13 KiB
Go
Raw Normal View History

package excelize
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestNumFmt(t *testing.T) {
for _, item := range [][]string{
{"123", "general", "123"},
{"43528", "y", "19"},
{"43528", "Y", "19"},
{"43528", "yy", "19"},
{"43528", "YY", "19"},
{"43528", "yyy", "2019"},
{"43528", "YYY", "2019"},
{"43528", "yyyy", "2019"},
{"43528", "YYYY", "2019"},
{"43528", "yyyyy", "2019"},
{"43528", "YYYYY", "2019"},
{"43528", "m", "3"},
{"43528", "mm", "03"},
{"43528", "mmm", "Mar"},
{"43528", "mmmm", "March"},
{"43528", "mmmmm", "M"},
{"43528", "mmmmmm", "March"},
{"43528", "d", "4"},
{"43528", "dd", "04"},
{"43528", "ddd", "Mon"},
{"43528", "dddd", "Monday"},
{"43528", "h", "0"},
{"43528", "hh", "00"},
{"43528", "hhh", "00"},
{"43543.544872685183", "hhmm", "1304"},
{"43543.544872685183", "mmhhmmmm", "0313March"},
{"43543.544872685183", "mm hh mm mm", "03 13 04 03"},
{"43543.544872685183", "mm hh m m", "03 13 4 3"},
{"43543.544872685183", "m s", "4 37"},
{"43528", "[h]", "1044672"},
{"43528", "[m]", "62680320"},
{"43528", "s", "0"},
{"43528", "ss", "00"},
{"43528", "[s]", "3760819200"},
{"43543.544872685183", "h:mm:ss AM/PM", "1:04:37 PM"},
{"43543.544872685183", "AM/PM h:mm:ss", "PM 1:04:37"},
{"43543.086539351854", "hh:mm:ss AM/PM", "02:04:37 AM"},
{"43543.086539351854", "AM/PM hh:mm:ss", "AM 02:04:37"},
{"43543.086539351854", "AM/PM hh:mm:ss a/p", "AM 02:04:37 a"},
{"43528", "YYYY", "2019"},
{"43528", "", "43528"},
{"43528.2123", "YYYY-MM-DD hh:mm:ss", "2019-03-04 05:05:42"},
{"43528.2123", "YYYY-MM-DD hh:mm:ss;YYYY-MM-DD hh:mm:ss", "2019-03-04 05:05:42"},
{"43528.2123", "M/D/YYYY h:m:s", "3/4/2019 5:5:42"},
{"43528.003958333335", "m/d/yyyy h:m:s", "3/4/2019 0:5:42"},
{"43528.003958333335", "M/D/YYYY h:mm:s", "3/4/2019 0:05:42"},
{"0.64583333333333337", "h:mm:ss am/pm", "3:30:00 pm"},
{"43528.003958333335", "h:mm", "0:05"},
{"6.9444444444444444E-5", "h:m", "0:0"},
{"6.9444444444444444E-5", "h:mm", "0:00"},
{"6.9444444444444444E-5", "h:m", "0:0"},
{"0.50070601851851848", "h:m", "12:1"},
{"0.97952546296296295", "h:m", "23:30"},
{"43528", "mmmm", "March"},
{"43528", "dddd", "Monday"},
{"0", ";;;", "0"},
{"43528", "[$-409]MM/DD/YYYY", "03/04/2019"},
{"43528", "[$-409]MM/DD/YYYY am/pm", "03/04/2019 AM"},
{"43528", "[$-111]MM/DD/YYYY", "43528"},
{"43528", "[$US-409]MM/DD/YYYY", "43528"},
{"43543.586539351854", "AM/PM h h:mm", "PM 14 2:04"},
{"text", "AM/PM h h:mm", "text"},
{"44562.189571759256", "[$-36]mmm dd yyyy h:mm AM/PM", "Jan. 01 2022 4:32 vm."},
{"44562.189571759256", "[$-36]mmmm dd yyyy h:mm AM/PM", "Januarie 01 2022 4:32 vm."},
{"44562.189571759256", "[$-36]mmmmm dd yyyy h:mm AM/PM", "J 01 2022 4:32 vm."},
{"44682.18957170139", "[$-36]mmm dd yyyy h:mm AM/PM", "Mei 01 2022 4:32 vm."},
{"44682.18957170139", "[$-36]mmmm dd yyyy h:mm AM/PM", "Mei 01 2022 4:32 vm."},
{"44682.18957170139", "[$-36]mmmmm dd yyyy h:mm AM/PM", "M 01 2022 4:32 vm."},
{"43543.503206018519", "[$-445]mmm dd yyyy h:mm AM/PM", "\u09AE\u09BE\u09B0\u09CD\u099A 19 2019 12:04 AM"},
{"43543.503206018519", "[$-445]mmmm dd yyyy h:mm AM/PM", "\u09AE\u09BE\u09B0\u09CD\u099A 19 2019 12:04 AM"},
{"43543.503206018519", "[$-445]mmmmm dd yyyy h:mm AM/PM", "\u09AE 19 2019 12:04 AM"},
{"43543.503206018519", "[$-4]mmm dd yyyy h:mm AM/PM", "3月 19 2019 12:04 上午"},
{"43543.503206018519", "[$-4]mmmm dd yyyy h:mm AM/PM", "三月 19 2019 12:04 上午"},
{"43543.503206018519", "[$-4]mmmmm dd yyyy h:mm AM/PM", "三 19 2019 12:04 上午"},
{"43543.503206018519", "[$-7804]mmm dd yyyy h:mm AM/PM", "3月 19 2019 12:04 上午"},
{"43543.503206018519", "[$-7804]mmmm dd yyyy h:mm AM/PM", "三月 19 2019 12:04 上午"},
{"43543.503206018519", "[$-7804]mmmmm dd yyyy h:mm AM/PM", "三 19 2019 12:04 上午"},
{"43543.503206018519", "[$-804]mmm dd yyyy h:mm AM/PM", "3月 19 2019 12:04 上午"},
{"43543.503206018519", "[$-804]mmmm dd yyyy h:mm AM/PM", "三月 19 2019 12:04 上午"},
{"43543.503206018519", "[$-804]mmmmm dd yyyy h:mm AM/PM", "三 19 2019 12:04 上午"},
{"43543.503206018519", "[$-1004]mmm dd yyyy h:mm AM/PM", "三月 19 2019 12:04 上午"},
{"43543.503206018519", "[$-1004]mmmm dd yyyy h:mm AM/PM", "三月 19 2019 12:04 上午"},
{"43543.503206018519", "[$-1004]mmmmm dd yyyy h:mm AM/PM", "三 19 2019 12:04 上午"},
{"43543.503206018519", "[$-7C04]mmm dd yyyy h:mm AM/PM", "3月 19 2019 12:04 上午"},
{"43543.503206018519", "[$-7C04]mmmm dd yyyy h:mm AM/PM", "3月 19 2019 12:04 上午"},
{"43543.503206018519", "[$-7C04]mmmmm dd yyyy h:mm AM/PM", "3 19 2019 12:04 上午"},
{"43543.503206018519", "[$-C04]mmm dd yyyy h:mm AM/PM", "三月 19 2019 12:04 上午"},
{"43543.503206018519", "[$-C04]mmmm dd yyyy h:mm AM/PM", "三月 19 2019 12:04 上午"},
{"43543.503206018519", "[$-C04]mmmmm dd yyyy h:mm AM/PM", "三 19 2019 12:04 上午"},
{"43543.503206018519", "[$-1404]mmm dd yyyy h:mm AM/PM", "3月 19 2019 12:04 上午"},
{"43543.503206018519", "[$-1404]mmmm dd yyyy h:mm AM/PM", "3月 19 2019 12:04 上午"},
{"43543.503206018519", "[$-1404]mmmmm dd yyyy h:mm AM/PM", "3 19 2019 12:04 上午"},
{"43543.503206018519", "[$-404]mmm dd yyyy h:mm AM/PM", "3月 19 2019 12:04 上午"},
{"43543.503206018519", "[$-404]mmmm dd yyyy h:mm AM/PM", "3月 19 2019 12:04 上午"},
{"43543.503206018519", "[$-404]mmmmm dd yyyy h:mm AM/PM", "3 19 2019 12:04 上午"},
{"43543.503206018519", "[$-9]mmm dd yyyy h:mm AM/PM", "Mar 19 2019 12:04 AM"},
{"43543.503206018519", "[$-9]mmmm dd yyyy h:mm AM/PM", "March 19 2019 12:04 AM"},
{"43543.503206018519", "[$-9]mmmmm dd yyyy h:mm AM/PM", "M 19 2019 12:04 AM"},
{"43543.503206018519", "[$-1000]mmm dd yyyy h:mm AM/PM", "Mar 19 2019 12:04 AM"},
{"43543.503206018519", "[$-1000]mmmm dd yyyy h:mm AM/PM", "March 19 2019 12:04 AM"},
{"43543.503206018519", "[$-1000]mmmmm dd yyyy h:mm AM/PM", "M 19 2019 12:04 AM"},
{"43543.503206018519", "[$-C09]mmm dd yyyy h:mm AM/PM", "Mar 19 2019 12:04 am"},
{"43543.503206018519", "[$-C09]mmmm dd yyyy h:mm AM/PM", "March 19 2019 12:04 am"},
{"43543.503206018519", "[$-C09]mmmmm dd yyyy h:mm AM/PM", "M 19 2019 12:04 am"},
{"43543.503206018519", "[$-c09]mmm dd yyyy h:mm AM/PM", "Mar 19 2019 12:04 am"},
{"43543.503206018519", "[$-c09]mmmm dd yyyy h:mm AM/PM", "March 19 2019 12:04 am"},
{"43543.503206018519", "[$-c09]mmmmm dd yyyy h:mm AM/PM", "M 19 2019 12:04 am"},
{"43543.503206018519", "[$-2829]mmm dd yyyy h:mm AM/PM", "Mar 19 2019 12:04 AM"},
{"43543.503206018519", "[$-2829]mmmm dd yyyy h:mm AM/PM", "March 19 2019 12:04 AM"},
{"43543.503206018519", "[$-2829]mmmmm dd yyyy h:mm AM/PM", "M 19 2019 12:04 AM"},
{"43543.503206018519", "[$-1009]mmm dd yyyy h:mm AM/PM", "Mar 19 2019 12:04 AM"},
{"43543.503206018519", "[$-1009]mmmm dd yyyy h:mm AM/PM", "March 19 2019 12:04 AM"},
{"43543.503206018519", "[$-1009]mmmmm dd yyyy h:mm AM/PM", "M 19 2019 12:04 AM"},
{"43543.503206018519", "[$-2409]mmm dd yyyy h:mm AM/PM", "Mar 19 2019 12:04 AM"},
{"43543.503206018519", "[$-2409]mmmm dd yyyy h:mm AM/PM", "March 19 2019 12:04 AM"},
{"43543.503206018519", "[$-2409]mmmmm dd yyyy h:mm AM/PM", "M 19 2019 12:04 AM"},
{"43543.503206018519", "[$-3C09]mmm dd yyyy h:mm AM/PM", "Mar 19 2019 12:04 AM"},
{"43543.503206018519", "[$-3C09]mmmm dd yyyy h:mm AM/PM", "March 19 2019 12:04 AM"},
{"43543.503206018519", "[$-3C09]mmmmm dd yyyy h:mm AM/PM", "M 19 2019 12:04 AM"},
{"43543.503206018519", "[$-4009]mmm dd yyyy h:mm AM/PM", "Mar 19 2019 12:04 AM"},
{"43543.503206018519", "[$-4009]mmmm dd yyyy h:mm AM/PM", "March 19 2019 12:04 AM"},
{"43543.503206018519", "[$-4009]mmmmm dd yyyy h:mm AM/PM", "M 19 2019 12:04 AM"},
{"43543.503206018519", "[$-1809]mmm dd yyyy h:mm AM/PM", "Mar 19 2019 12:04 am"},
{"43543.503206018519", "[$-1809]mmmm dd yyyy h:mm AM/PM", "March 19 2019 12:04 am"},
{"43543.503206018519", "[$-1809]mmmmm dd yyyy h:mm AM/PM", "M 19 2019 12:04 am"},
{"43543.503206018519", "[$-2009]mmm dd yyyy h:mm AM/PM", "Mar 19 2019 12:04 AM"},
{"43543.503206018519", "[$-2009]mmmm dd yyyy h:mm AM/PM", "March 19 2019 12:04 AM"},
{"43543.503206018519", "[$-2009]mmmmm dd yyyy h:mm AM/PM", "M 19 2019 12:04 AM"},
{"43543.503206018519", "[$-4409]mmm dd yyyy h:mm AM/PM", "Mar 19 2019 12:04 AM"},
{"43543.503206018519", "[$-4409]mmmm dd yyyy h:mm AM/PM", "March 19 2019 12:04 AM"},
{"43543.503206018519", "[$-4409]mmmmm dd yyyy h:mm AM/PM", "M 19 2019 12:04 AM"},
{"43543.503206018519", "[$-1409]mmm dd yyyy h:mm AM/PM", "Mar 19 2019 12:04 AM"},
{"43543.503206018519", "[$-1409]mmmm dd yyyy h:mm AM/PM", "March 19 2019 12:04 AM"},
{"43543.503206018519", "[$-1409]mmmmm dd yyyy h:mm AM/PM", "M 19 2019 12:04 AM"},
{"43543.503206018519", "[$-3409]mmm dd yyyy h:mm AM/PM", "Mar 19 2019 12:04 AM"},
{"43543.503206018519", "[$-3409]mmmm dd yyyy h:mm AM/PM", "March 19 2019 12:04 AM"},
{"43543.503206018519", "[$-3409]mmmmm dd yyyy h:mm AM/PM", "M 19 2019 12:04 AM"},
{"43543.503206018519", "[$-4809]mmm dd yyyy h:mm AM/PM", "Mar 19 2019 12:04 AM"},
{"43543.503206018519", "[$-4809]mmmm dd yyyy h:mm AM/PM", "March 19 2019 12:04 AM"},
{"43543.503206018519", "[$-4809]mmmmm dd yyyy h:mm AM/PM", "M 19 2019 12:04 AM"},
{"43543.503206018519", "[$-1C09]mmm dd yyyy h:mm AM/PM", "Mar 19 2019 12:04 AM"},
{"43543.503206018519", "[$-1C09]mmmm dd yyyy h:mm AM/PM", "March 19 2019 12:04 AM"},
{"43543.503206018519", "[$-1C09]mmmmm dd yyyy h:mm AM/PM", "M 19 2019 12:04 AM"},
{"43543.503206018519", "[$-2C09]mmm dd yyyy h:mm AM/PM", "Mar 19 2019 12:04 AM"},
{"43543.503206018519", "[$-2C09]mmmm dd yyyy h:mm AM/PM", "March 19 2019 12:04 AM"},
{"43543.503206018519", "[$-2C09]mmmmm dd yyyy h:mm AM/PM", "M 19 2019 12:04 AM"},
{"43543.503206018519", "[$-4C09]mmm dd yyyy h:mm AM/PM", "Mar 19 2019 12:04 AM"},
{"43543.503206018519", "[$-4C09]mmmm dd yyyy h:mm AM/PM", "March 19 2019 12:04 AM"},
{"43543.503206018519", "[$-4C09]mmmmm dd yyyy h:mm AM/PM", "M 19 2019 12:04 AM"},
{"43543.503206018519", "[$-809]mmm dd yyyy h:mm AM/PM", "Mar 19 2019 12:04 am"},
{"43543.503206018519", "[$-809]mmmm dd yyyy h:mm AM/PM", "March 19 2019 12:04 am"},
{"43543.503206018519", "[$-809]mmmmm dd yyyy h:mm AM/PM", "M 19 2019 12:04 am"},
{"43543.503206018519", "[$-3009]mmm dd yyyy h:mm AM/PM", "Mar 19 2019 12:04 AM"},
{"43543.503206018519", "[$-3009]mmmm dd yyyy h:mm AM/PM", "March 19 2019 12:04 AM"},
{"43543.503206018519", "[$-3009]mmmmm dd yyyy h:mm AM/PM", "M 19 2019 12:04 AM"},
{"44562.189571759256", "[$-C]mmm dd yyyy h:mm AM/PM", "janv. 01 2022 4:32 AM"},
{"44562.189571759256", "[$-C]mmmm dd yyyy h:mm AM/PM", "janvier 01 2022 4:32 AM"},
{"44562.189571759256", "[$-C]mmmmm dd yyyy h:mm AM/PM", "j 01 2022 4:32 AM"},
{"43543.503206018519", "[$-C]mmm dd yyyy h:mm AM/PM", "mars 19 2019 12:04 AM"},
{"43543.503206018519", "[$-C]mmmm dd yyyy h:mm AM/PM", "mars 19 2019 12:04 AM"},
{"43543.503206018519", "[$-C]mmmmm dd yyyy h:mm AM/PM", "m 19 2019 12:04 AM"},
{"43543.503206018519", "[$-7]mmm dd yyyy h:mm AM/PM", "Mär 19 2019 12:04 AM"},
{"43543.503206018519", "[$-7]mmmm dd yyyy h:mm AM/PM", "März 19 2019 12:04 AM"},
{"43543.503206018519", "[$-7]mmmmm dd yyyy h:mm AM/PM", "M 19 2019 12:04 AM"},
{"44562.189571759256", "[$-C07]mmm dd yyyy h:mm AM/PM", "Jän 01 2022 4:32 AM"},
{"44562.189571759256", "[$-C07]mmmm dd yyyy h:mm AM/PM", "Jänner 01 2022 4:32 AM"},
{"44562.189571759256", "[$-C07]mmmmm dd yyyy h:mm AM/PM", "J 01 2022 4:32 AM"},
{"43543.503206018519", "[$-407]mmm dd yyyy h:mm AM/PM", "Mär 19 2019 12:04 AM"},
{"43543.503206018519", "[$-407]mmmm dd yyyy h:mm AM/PM", "März 19 2019 12:04 AM"},
{"43543.503206018519", "[$-407]mmmmm dd yyyy h:mm AM/PM", "M 19 2019 12:04 AM"},
{"43543.503206018519", "[$-10]mmm dd yyyy h:mm AM/PM", "mar 19 2019 12:04 AM"},
{"43543.503206018519", "[$-10]mmmm dd yyyy h:mm AM/PM", "marzo 19 2019 12:04 AM"},
{"43543.503206018519", "[$-10]mmmmm dd yyyy h:mm AM/PM", "m 19 2019 12:04 AM"},
{"43543.503206018519", "[$-11]mmm dd yyyy h:mm AM/PM", "3月 19 2019 12:04 午前"},
{"43543.503206018519", "[$-11]mmmm dd yyyy h:mm AM/PM", "3月 19 2019 12:04 午前"},
{"43543.503206018519", "[$-11]mmmmm dd yyyy h:mm AM/PM", "3 19 2019 12:04 午前"},
{"43543.503206018519", "[$-411]mmm dd yyyy h:mm AM/PM", "3月 19 2019 12:04 午前"},
{"43543.503206018519", "[$-411]mmmm dd yyyy h:mm AM/PM", "3月 19 2019 12:04 午前"},
{"43543.503206018519", "[$-411]mmmmm dd yyyy h:mm AM/PM", "3 19 2019 12:04 午前"},
{"43543.503206018519", "[$-12]mmm dd yyyy h:mm AM/PM", "3월 19 2019 12:04 오전"},
{"43543.503206018519", "[$-12]mmmm dd yyyy h:mm AM/PM", "3월 19 2019 12:04 오전"},
{"43543.503206018519", "[$-12]mmmmm dd yyyy h:mm AM/PM", "3 19 2019 12:04 오전"},
{"43543.503206018519", "[$-412]mmm dd yyyy h:mm AM/PM", "3월 19 2019 12:04 오전"},
{"43543.503206018519", "[$-412]mmmm dd yyyy h:mm AM/PM", "3월 19 2019 12:04 오전"},
{"43543.503206018519", "[$-412]mmmmm dd yyyy h:mm AM/PM", "3 19 2019 12:04 오전"},
} {
result := format(item[0], item[1])
assert.Equal(t, item[2], result, item)
}
}