当前位置:网站首页>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
边栏推荐
- SystemVerilog(六)-变量
- Logic regression principle and code implementation
- ES6
- Secure credit
- 关于gcc输出typeid完整名的方法
- Listen for click events other than an element
- Special effects case collection: mouse planet small tail
- MySQL_01_简单数据检索
- MySQL advanced index [classification, performance analysis, use, design principles]
- C# 的数据流加密与解密
猜你喜欢
Using files to save data (C language)
Auto.js 自定义对话框
k8s之实现redis一主多从动态扩缩容
Implementation of k8s redis one master multi slave dynamic capacity expansion
Logic regression principle and code implementation
2022年广东省安全员A证第三批(主要负责人)特种作业证考试题库及在线模拟考试
2022 judgment questions and answers for operation of refrigeration and air conditioning equipment
QTableWidget使用讲解
Process management command
高德地图搜索、拖拽 查询地址
随机推荐
2022制冷与空调设备运行操作判断题及答案
Applet learning notes (I)
proxy server
ES6 face test questions (reference documents)
[UDS unified diagnostic service] IV. typical diagnostic service (4) - online programming function unit (0x34-0x38)
Go file operation
MySQL_01_简单数据检索
ROS package NMEA_ navsat_ Driver reads GPS and Beidou Positioning Information Notes
In JS, t, = > Analysis of
.105Location
Implementation of image recognition code based on VGg convolutional neural network
[appium] write scripts by designing Keyword Driven files
列表的使用-增删改查
Leak detection and vacancy filling (6)
Encapsulate a timestamp to date method on string prototype
Auto. JS custom dialog box
Auto.js 自定义对话框
An example of linear regression based on tensorflow
Some questions some questions some questions some questions
Classes and objects