当前位置:网站首页>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
边栏推荐
- Utilisation de la liste - Ajouter, supprimer et modifier la requête
- positioner
- Array rotation
- Implementation of k8s redis one master multi slave dynamic capacity expansion
- Commonly used functions -- spineros:: and spineros::)
- C1小笔记【任务训练篇二】
- Cloud native Virtualization: building edge computing instances based on kubevirt
- undefined reference to `Nabo::NearestNeighbourSearch
- Amount input box, used for recharge and withdrawal
- 2022 judgment questions and answers for operation of refrigeration and air conditioning equipment
猜你喜欢

2022 Jiangxi Photovoltaic Exhibition, China Distributed Photovoltaic Exhibition, Nanchang Solar Energy Utilization Exhibition

JS forms the items with the same name in the array object into the same array according to the name

re正则表达式

On the problem of V-IF display and hiding
![[UDS unified diagnostic service] (Supplement) v. detailed explanation of ECU bootloader development points (2)](/img/91/3272d5ad04cd1d8476c739546f4356.png)
[UDS unified diagnostic service] (Supplement) v. detailed explanation of ECU bootloader development points (2)

Laser slam theory and practice of dark blue College Chapter 3 laser radar distortion removal exercise

MySQL_ 01_ Simple data retrieval
![C1 notes [task training part 2]](/img/10/48f7490a6c097f2b178ae948cb2c91.png)
C1 notes [task training part 2]

MySQL 中的字符串函数

Detailed deployment of flask project
随机推荐
C# 的数据流加密与解密
Realsense selection comparison d455 d435i d415 t265 3D hardware comparison
.105Location
Go file operation
Kubernetes service discovery monitoring endpoints
2021 Great Wall Cup WP
Submit local warehouse and synchronize code cloud warehouse
2022 Jiangxi Photovoltaic Exhibition, China distributed Photovoltaic Exhibition, Nanchang solar energy utilization Exhibition
.104History
Leak detection and vacancy filling (VIII)
2022江西光伏展,中國分布式光伏展會,南昌太陽能利用展
k8s之实现redis一主多从动态扩缩容
MySQL 中的字符串函数
How to read literature
Notes on common basic usage of eigen Library
Listen for click events other than an element
On the problem of V-IF display and hiding
Cloud native Virtualization: building edge computing instances based on kubevirt
Uniapp custom search box adaptation applet alignment capsule
MySQL_01_简单数据检索