timestamp_to_excel_date

Function timestamp_to_excel_date 

Source
pub fn timestamp_to_excel_date(timestamp_ms: i64) -> f64
Expand description

将时间戳(毫秒)转换为 Excel 日期序列号

Excel 使用从 1900年1月1日开始的序列号来表示日期。 由于 Excel 的历史 bug(将 1900 年视为闰年),需要特殊处理。

§参数

  • timestamp_ms - Unix 时间戳(毫秒),从 1970-01-01 00:00:00 UTC 开始

§返回

Excel 日期序列号(浮点数)

§示例

use xlsx_handlebars::timestamp_to_excel_date;
 
// 2024-01-01 00:00:00 UTC
let timestamp = 1704067200000i64;
let excel_date = timestamp_to_excel_date(timestamp);
println!("Excel date number: {}", excel_date);