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", "[$-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"}, } { result := format(item[0], item[1]) assert.Equal(t, item[2], result, item) } }