Skip to content

[H5] addPhoneCalendar 按文档传入秒级时间戳,导出的 2027 年日程落在 1970 年 #19723

Backlog

Description

@yiwenmu1

请先确认

  • 我已搜索并确定这个提交不是重复的

Taro 版本

v4

相关领域

H5 API

使用框架

React

相关平台

  • 所有平台
  • Web 端(H5)
  • 移动端(React-Native)
  • 鸿蒙(Harmony)
  • 鸿蒙容器(Harmony Hybrid)
  • ASCF 元服务
  • 快应用(QuickApp)
  • 所有小程序
  • 微信小程序
  • 企业微信小程序
  • 京东小程序
  • 百度小程序
  • 支付宝小程序
  • 支付宝 IOT 小程序
  • 头条小程序
  • QQ 小程序
  • 钉钉小程序
  • 飞书小程序
  • 快手小程序

小程序基础库版本

No response

问题描述

在 H5 调用 addPhoneCalendar 导出单次日程时,传入 2027-01-15 09:00 UTC 的 Unix 秒级时间戳。接口返回 addPhoneCalendar:ok,下载的日历文件却把日程写到了 1970 年。startTime 参数文档

import { addPhoneCalendar } from '@tarojs/taro-h5';

await addPhoneCalendar({
  title: 'seconds',
  startTime: 1800003600,
  alarm: false
});

macos日历中的复现

两张截图显示同一目标时刻的两次导出,日历按本地时间(UTC+8)显示。

按文档传秒,事件 seconds 显示为 1970 年 1 月 22 日 04:00,与导出文件里的 19700121T200000Z 一致。

calendar-seconds

传入毫秒作对照,事件 milliseconds 显示为预期的 2027 年 1 月 15 日 17:00,对应 20270115T090000Z。

calendar-milliseconds

复现链接

https://github.com/yiwenmu1/taro-h5-calendar-timestamp-repro

复现步骤

  1. 下载或克隆复现仓库,在根目录运行 npm install 和 npm run build,用 Chrome 打开 index.html。
  2. 保持默认日期 2027-01-15T09:00:00Z,点击「按文档传秒」。页面显示 addPhoneCalendar:ok。
  3. 用文本编辑器打开下载的 seconds.ics。预期为 DTSTART:20270115T090000Z,实际为 DTSTART:19700121T200000Z。
  4. 保持日期不变,点击「毫秒对照」。传入 1800003600000 时,milliseconds.ics 中的开始时间为预期的 DTSTART:20270115T090000Z。

另测 2028-02-29 12:34 UTC 的闰日日程,导出值为 1970-01-22 05:50 UTC。跨年前后的两场日程(2026-12-31 23:59 和 2027-01-01 00:01 UTC)都被写成 1970-01-21 19:39 UTC。四个日期在三个时区的毫秒对照都返回正确日期。

环境信息

浏览器为 Chrome 158.0.8127.38。分别在 UTC、Asia/Shanghai 和 America/New_York 三个浏览器时区测试,导出的 UTC 开始时间一致。

👽 Taro v4.3.3

  Taro CLI 4.3.3 environment info:
    System:
      OS: macOS 27.2.1
      Shell: 5.9 - /bin/zsh
    Binaries:
      Node: 26.13.0 - /opt/homebrew/bin/node
      npm: 11.20.0 - /opt/homebrew/bin/npm
    npmPackages:
      @tarojs/cli: ^4.3.3 => 4.3.3
      @tarojs/taro-h5: ^4.3.3 => 4.3.3
      react: ^18.3.1 => 18.3.1

开源贡献

Activity

  1. added
    bug
    on Nov 30, 2026
  2. added
    A-api
    F-react
    T-h5
    V-4
    on Nov 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-apiF-reactT-h5V-4bug

    Type

    No type

    Projects

    • Status
      Padding

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions