当前位置:网站首页>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
边栏推荐
- re正则表达式
- Operators in C language
- Open source key component multi_ Button use, including test engineering
- How to read literature
- 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
- Basic usage of crawler requests
- Chrome浏览器的跨域设置----包含新老版本两种设置
- Write a regular
- ROS package NMEA_ navsat_ Driver reads GPS and Beidou Positioning Information Notes
- 2022年广东省安全员A证第三批(主要负责人)特种作业证考试题库及在线模拟考试
猜你喜欢
2022江西光伏展,中国分布式光伏展会,南昌太阳能利用展
Open source key component multi_ Button use, including test engineering
Qtablewidget usage explanation
Error in created hook: "referenceerror:" promise "undefined“
Operation of 2022 mobile crane driver national question bank simulation examination platform
2022制冷与空调设备运行操作判断题及答案
SystemVerilog (VI) - variable
Go对文件操作
An example of linear regression based on tensorflow
Yolov4 pruning [with code]
随机推荐
Operators in C language
Eigen learning summary
Write a regular
Tensorflow tensor introduction
Where is the configuration file of tidb server?
Go file operation
Gets the time range of the current week
cartographer_ There is no problem compiling node, but running the bug that hangs directly
Classes and objects
JS high frequency interview questions
JS interview question: FN call. call. call. Call (FN2) parsing
2022 Jiangxi Photovoltaic Exhibition, China distributed Photovoltaic Exhibition, Nanchang solar energy utilization Exhibition
Submit local warehouse and synchronize code cloud warehouse
JS forms the items with the same name in the array object into the same array according to the name
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
Open source key component multi_ Button use, including test engineering
[UDS unified diagnostic service] IV. typical diagnostic service (6) - input / output control unit (0x2F)
Tell the truth of TS
[UDS unified diagnostic service] IV. typical diagnostic service (4) - online programming function unit (0x34-0x38)
Generate verification code