当前位置:网站首页>Read excel, int digital time to time
Read excel, int digital time to time
2022-04-23 17:59:00 【User nickname cannot be empty】
golang analysis excel When , You will find that the date and time have become Numbers , But in excel The display in is normal .
reason
excel The dates in are stored according to his own era . With 1899 year 12 month 30 Japan 0 when 0 branch 0 second UTC For the era .
terms of settlement
transformation
func ExcelIntDate(dateStr string) (dt time.Time, err error) {
var dateValue float64
matched, err := regexp.MatchString(`^\d+$`, dateStr)
if err != nil {
return
}
if !matched {
err = errors.New("not excel time")
return
}
dateValue, err = strconv.ParseFloat(dateStr, 64)
if err != nil {
return
}
epoch := time.Date(1899, 12, 30, 0, 0, 0, 0, time.UTC) // UTC 1899/12/30 00:00:00
dt = epoch.Add(time.Duration(dateValue) * 24 * time.Hour)
return
}
test
var dateStr string
dateStr = "44666" // 2022-04-15 00:00:00 +0000 UTC
dateStr = "44621" // 2022-03-01 00:00:00 +0000 UTC
fmt.Println(ExcelIntDate(dateStr))
版权声明
本文为[User nickname cannot be empty]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204231757283909.html
边栏推荐
- Go语言JSON包使用
- Anchor location - how to set the distance between the anchor and the top of the page. The anchor is located and offset from the top
- Comparison between xtask and kotlin coroutine
- Amount input box, used for recharge and withdrawal
- _ FindText error
- Build openstack platform
- Operators in C language
- This point in JS
- Add animation to the picture under V-for timing
- Some questions some questions some questions some questions
猜你喜欢
Land cover / use data product download
C1 notes [task training part 2]
开源按键组件Multi_Button的使用,含测试工程
positioner
re正则表达式
Go语言JSON包使用
Examination question bank and online simulation examination of the third batch (main person in charge) of special operation certificate of safety officer a certificate in Guangdong Province in 2022
2022 Shanghai safety officer C certificate operation certificate examination question bank and simulation examination
MySQL_ 01_ Simple data retrieval
Go file operation
随机推荐
Type judgment in [untitled] JS
proxy server
Eigen learning summary
JS interview question: FN call. call. call. Call (FN2) parsing
列表的使用-增删改查
Vite configure proxy proxy to solve cross domain
20222 return to the workplace
【Appium】通过设计关键字驱动文件来编写脚本
587. Install fence / Sword finger offer II 014 Anagrams in strings
Oil monkey website address
Some questions some questions some questions some questions
2022江西光伏展,中国分布式光伏展会,南昌太阳能利用展
2022 judgment questions and answers for operation of refrigeration and air conditioning equipment
C language implements memcpy, memset, strcpy, strncpy, StrCmp, strncmp and strlen
Click Cancel to return to the previous page and modify the parameter value of the previous page, let pages = getcurrentpages() let prevpage = pages [pages. Length - 2] / / the data of the previous pag
Yolov4 pruning [with code]
Add animation to the picture under V-for timing
Go's gin framework learning
读取excel,int 数字时间转时间
Qtablewidget usage explanation