Skip to content

Commit

Permalink
This fixes #1599, and improve date and time number format
Browse files Browse the repository at this point in the history
- Fix basic arithmetic operator priority issues
- Support apply date and time number format with 52 languages: Estonian, Faroese, Filipino, Finnish, Frisian, Fulah, Galician, Georgian, Greek, Greenlandic, Guarani, Gujarati, Hausa, Hawaiian, Hebrew, Hindi, Hungarian, Icelandic, Igbo, Indonesian, Inuktitut, Kannada, Kashmiri, Kazakh, Khmer, Kiche, Kinyarwanda, Kiswahili, Konkani, Kyrgyz, Lao, Latin, Latvian, Lithuanian, Luxembourgish, Macedonian, Malay, Malayalam, Maltese, Maori, Mapudungun, Marathi, Mohawk, Morocco, Nepali, Nigeria, Norwegian, Occitan, Odia, Oromo, Pashto and Syllabics
- Support apply the Chinese weekdays' number formats
- Update the unit test and dependencies modules
  • Loading branch information
xuri committed Aug 5, 2023
1 parent aa3c79a commit eb17590
Show file tree
Hide file tree
Showing 6 changed files with 2,656 additions and 162 deletions.
14 changes: 7 additions & 7 deletions calc.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,13 @@ var (
"/": 4,
"+": 3,
"-": 3,
"=": 2,
"<>": 2,
"<": 2,
"<=": 2,
">": 2,
">=": 2,
"&": 1,
"&": 2,
"=": 1,
"<>": 1,
"<": 1,
"<=": 1,
">": 1,
">=": 1,
}
month2num = map[string]int{
"january": 1,
Expand Down
67 changes: 36 additions & 31 deletions calc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,37 +35,42 @@ func TestCalcCellValue(t *testing.T) {
{nil, nil, nil, "Feb", "South 2", 45500},
}
mathCalc := map[string]string{
"=2^3": "8",
"=1=1": "TRUE",
"=1=2": "FALSE",
"=1<2": "TRUE",
"=3<2": "FALSE",
"=1<\"-1\"": "TRUE",
"=\"-1\"<1": "FALSE",
"=\"-1\"<\"-2\"": "TRUE",
"=2<=3": "TRUE",
"=2<=1": "FALSE",
"=1<=\"-1\"": "TRUE",
"=\"-1\"<=1": "FALSE",
"=\"-1\"<=\"-2\"": "TRUE",
"=2>1": "TRUE",
"=2>3": "FALSE",
"=1>\"-1\"": "FALSE",
"=\"-1\">-1": "TRUE",
"=\"-1\">\"-2\"": "FALSE",
"=2>=1": "TRUE",
"=2>=3": "FALSE",
"=1>=\"-1\"": "FALSE",
"=\"-1\">=-1": "TRUE",
"=\"-1\">=\"-2\"": "FALSE",
"=1&2": "12",
"=15%": "0.15",
"=1+20%": "1.2",
"={1}+2": "3",
"=1+{2}": "3",
"={1}+{2}": "3",
"=\"A\"=\"A\"": "TRUE",
"=\"A\"<>\"A\"": "FALSE",
"=2^3": "8",
"=1=1": "TRUE",
"=1=2": "FALSE",
"=1<2": "TRUE",
"=3<2": "FALSE",
"=1<\"-1\"": "TRUE",
"=\"-1\"<1": "FALSE",
"=\"-1\"<\"-2\"": "TRUE",
"=2<=3": "TRUE",
"=2<=1": "FALSE",
"=1<=\"-1\"": "TRUE",
"=\"-1\"<=1": "FALSE",
"=\"-1\"<=\"-2\"": "TRUE",
"=2>1": "TRUE",
"=2>3": "FALSE",
"=1>\"-1\"": "FALSE",
"=\"-1\">-1": "TRUE",
"=\"-1\">\"-2\"": "FALSE",
"=2>=1": "TRUE",
"=2>=3": "FALSE",
"=1>=\"-1\"": "FALSE",
"=\"-1\">=-1": "TRUE",
"=\"-1\">=\"-2\"": "FALSE",
"=1&2": "12",
"=15%": "0.15",
"=1+20%": "1.2",
"={1}+2": "3",
"=1+{2}": "3",
"={1}+{2}": "3",
"=\"A\"=\"A\"": "TRUE",
"=\"A\"<>\"A\"": "FALSE",
"=TRUE()&FALSE()": "TRUEFALSE",
"=TRUE()&FALSE()<>FALSE": "TRUE",
"=TRUE()&\"1\"": "TRUE1",
"=TRUE<>FALSE()": "TRUE",
"=TRUE<>1&\"x\"": "TRUE",
// Engineering Functions
// BESSELI
"=BESSELI(4.5,1)": "15.3892227537359",
Expand Down
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ require (
github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826
github.com/richardlehane/mscfb v1.0.4
github.com/stretchr/testify v1.8.0
github.com/xuri/efp v0.0.0-20230422071738-01f4e37c47e9
github.com/xuri/nfp v0.0.0-20230730012209-aee513b45ff4
github.com/xuri/efp v0.0.0-20230802181842-ad255f2331ca
github.com/xuri/nfp v0.0.0-20230802015359-2d5eeba905e9
golang.org/x/crypto v0.11.0
golang.org/x/image v0.5.0
golang.org/x/net v0.12.0
golang.org/x/net v0.13.0
golang.org/x/text v0.11.0
)

Expand Down
12 changes: 6 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSS
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk=
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/xuri/efp v0.0.0-20230422071738-01f4e37c47e9 h1:ge5g8vsTQclA5lXDi+PuiAFw5GMIlMHOB/5e1hsf96E=
github.com/xuri/efp v0.0.0-20230422071738-01f4e37c47e9/go.mod h1:ybY/Jr0T0GTCnYjKqmdwxyxn2BQf2RcQIIvex5QldPI=
github.com/xuri/nfp v0.0.0-20230730012209-aee513b45ff4 h1:7TXNzvlvE0E/oLDazWm2Xip72G9Su+jRzvziSxwO6Ww=
github.com/xuri/nfp v0.0.0-20230730012209-aee513b45ff4/go.mod h1:WwHg+CVyzlv/TX9xqBFXEZAuxOPxn2k1GNHwG41IIUQ=
github.com/xuri/efp v0.0.0-20230802181842-ad255f2331ca h1:uvPMDVyP7PXMMioYdyPH+0O+Ta/UO1WFfNYMO3Wz0eg=
github.com/xuri/efp v0.0.0-20230802181842-ad255f2331ca/go.mod h1:ybY/Jr0T0GTCnYjKqmdwxyxn2BQf2RcQIIvex5QldPI=
github.com/xuri/nfp v0.0.0-20230802015359-2d5eeba905e9 h1:jmhvNv5by7bXDzzjzBXaIWmEI4lMYfv5iJtI5Pw5/aM=
github.com/xuri/nfp v0.0.0-20230802015359-2d5eeba905e9/go.mod h1:WwHg+CVyzlv/TX9xqBFXEZAuxOPxn2k1GNHwG41IIUQ=
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
Expand All @@ -33,8 +33,8 @@ golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg=
golang.org/x/net v0.12.0 h1:cfawfvKITfUsFCeJIHJrbSxpeu/E81khclypR0GVT50=
golang.org/x/net v0.12.0/go.mod h1:zEVYFnQC7m/vmpQFELhcD1EWkZlX69l4oqgmer6hfKA=
golang.org/x/net v0.13.0 h1:Nvo8UFsZ8X3BhAC9699Z1j7XQ3rsZnUUm7jfBEk1ueY=
golang.org/x/net v0.13.0/go.mod h1:zEVYFnQC7m/vmpQFELhcD1EWkZlX69l4oqgmer6hfKA=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
Expand Down
Loading

0 comments on commit eb17590

Please sign in to comment.