Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect parse time caused by round precision #764

Closed
vlyonline opened this issue Jan 19, 2021 · 3 comments
Closed

Incorrect parse time caused by round precision #764

vlyonline opened this issue Jan 19, 2021 · 3 comments
Projects

Comments

@vlyonline
Copy link

vlyonline commented Jan 19, 2021

excel文件里面的日期是 2020/1/4 23:00:00

func readContent(f *excelize.File) ([]map[string]string, error) {
	var rs = make([]map[string]string, 0)
	var column_name = make([]string, 0)
	rows, err := f.GetRows("Sheet1")
	if err != nil {
		return rs, err
	}
	for i, row := range rows { //遍历行
		if i == 0 {
			for _, v := range row {
				column_name = append(column_name, v)
			}
		} else {
			maxindex := len(column_name)
			var newmap = make(map[string]string)
			for ii, vv := range row { // 遍历列
				if ii < maxindex {
					log.Info("vv:%v", vv)  ----这里打印了单元表格值
					newmap[column_name[ii]] = vv
				}
			}
			rs = append(rs, newmap)
		}
	}
	return rs, nil
}

日志(截取部分):
2021/01/19 10:58:07.854566 excel.go:50: [INFO] vv:2020/1/4 10:59:59
解析出来的时间不对

Output of go version:go version go1.14.3 linux/amd64

库版本:github.com/360EntSecGroup-Skylar/excelize/v2 v2.3.2
**Environment details (OS, Microsoft Excel™ version, physical, etc.):开发环境 ubuntu 20 ,生产是centos 7 **

@xuri xuri closed this as completed in 1bc5302 Jan 19, 2021
@xuri xuri changed the title 解析出来的时间不对,24小时制变成12小时制,时间也不对,少了1分钟,可以自己试一下 Incorrect parse time caused by round precision Jan 19, 2021
@xuri
Copy link
Member

xuri commented Jan 19, 2021

Hi @vlyonline, thanks for your issue. I have fixed the incorrect parse time caused by round precision, please upgrade to the master branch code, and this fix will be released in the next version. This library doesn't support localization built-in number format and custom number format currently, so the time format will be in 12-hours as default under the English region. I'll consider adding localization support and create a lexer and parser for the custom number format expression to resolve this problem, also reference the issue #73 and #655.

@xuri xuri added this to Bugfix in v2.4.0 Feb 2, 2021
@ZengYueWei
Copy link

Hi Xuri,这问题好像没有完全没有解决
在excel中写入的时间为:2021/11/27 2:20
在日志中打印出来的时间为:2021/11/27 2:19

Go:1.16
excelize:V2.4.1

@xuri
Copy link
Member

xuri commented Nov 22, 2021

Hi @ZengYueWei, please give a try the master branch code, this issue has been re-fixed by commit 58fd279, and will be released in the next version.

@xuri xuri mentioned this issue Dec 11, 2021
xuri added a commit that referenced this issue Feb 12, 2022
- Introduced NFP (number format parser) dependencies module
- Initialize custom dates and times number format support
- Dependencies module upgraded
xuri added a commit to carbin-gun/excelize that referenced this issue Oct 9, 2022
…is improve number format support

- Introduced NFP (number format parser) dependencies module
- Initialize custom dates and times number format support
- Dependencies module upgraded
jenbonzhang pushed a commit to jenbonzhang/excelize that referenced this issue Oct 22, 2023
jenbonzhang pushed a commit to jenbonzhang/excelize that referenced this issue Oct 22, 2023
…is improve number format support

- Introduced NFP (number format parser) dependencies module
- Initialize custom dates and times number format support
- Dependencies module upgraded
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
v2.4.0
Bugfix
Development

No branches or pull requests

3 participants