excel_date_to_timestamp

Function excel_date_to_timestamp 

Source
pub fn excel_date_to_timestamp(excel_date: f64) -> Option<i64>
Expand description

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

Excel 使用从 1900年1月1日开始的序列号来表示日期。 此函数将 Excel 序列号转换回 Unix 时间戳。

§参数

  • excel_date - Excel 日期序列号

§返回

  • Some(timestamp_ms) - Unix 时间戳(毫秒),从 1970-01-01 00:00:00 UTC 开始
  • None - 如果输入的序列号无效(如负数或等于60)

§示例

use xlsx_handlebars::excel_date_to_timestamp;
 
// Excel 序列号 45294.0 表示 2024-01-01
let excel_date = 45294.0;
if let Some(timestamp) = excel_date_to_timestamp(excel_date) {
    println!("Unix timestamp: {}", timestamp);
}