summaryrefslogtreecommitdiff
path: root/numfmt.go
diff options
context:
space:
mode:
authorxuri <xuri.me@gmail.com>2022-04-30 09:54:11 +0800
committerGitHub <noreply@github.com>2022-04-30 09:54:11 +0800
commit856ee57c4019b4478da0f6cb3010ae636914a6be (patch)
treea1a28fb6dec307695d4ec491929a00961c1c65ec /numfmt.go
parent0f93bd23c97ac0f04fe8012bd4a262c851e44a82 (diff)
This closes #1212, init support for 1900 or 1904 date system
Diffstat (limited to 'numfmt.go')
-rw-r--r--numfmt.go8
1 files changed, 4 insertions, 4 deletions
diff --git a/numfmt.go b/numfmt.go
index 6cb7fc7..5503027 100644
--- a/numfmt.go
+++ b/numfmt.go
@@ -34,7 +34,7 @@ type numberFormat struct {
section []nfp.Section
t time.Time
sectionIdx int
- isNumeric, hours, seconds bool
+ date1904, isNumeric, hours, seconds bool
number float64
ap, afterPoint, beforePoint, localCode, result, value, valueSectionType string
}
@@ -287,9 +287,9 @@ func (nf *numberFormat) prepareNumberic(value string) {
// format provides a function to return a string parse by number format
// expression. If the given number format is not supported, this will return
// the original cell value.
-func format(value, numFmt string) string {
+func format(value, numFmt string, date1904 bool) string {
p := nfp.NumberFormatParser()
- nf := numberFormat{section: p.Parse(numFmt), value: value}
+ nf := numberFormat{section: p.Parse(numFmt), value: value, date1904: date1904}
nf.number, nf.valueSectionType = nf.getValueSectionType(value)
nf.prepareNumberic(value)
for i, section := range nf.section {
@@ -315,7 +315,7 @@ func format(value, numFmt string) string {
// positiveHandler will be handling positive selection for a number format
// expression.
func (nf *numberFormat) positiveHandler() (result string) {
- nf.t, nf.hours, nf.seconds = timeFromExcelTime(nf.number, false), false, false
+ nf.t, nf.hours, nf.seconds = timeFromExcelTime(nf.number, nf.date1904), false, false
for i, token := range nf.section[nf.sectionIdx].Items {
if inStrSlice(supportedTokenTypes, token.TType, true) == -1 || token.TType == nfp.TokenTypeGeneral {
result = nf.value