Travel Days Counter

Travel Days Counter

📐 工作原理与说明
行程天数 =(返回日期 − 出发日期)÷ 86400000 + 1(含首尾两天);住宿晚数 = 天数 − 1;距出发倒计时 =(出发日期 − 当前日期)向上取整;跨月跨年按时间戳自动累计,闰年 2 月多计 1 天;已过天数 = 当前日期 − 出发日期。

📚 深度解析:旅行天数/倒计时

💡 常见使用场景

9/1–9/7
days=ceil((9/7−9/1)/86400000)+1=7 天、nights=6、hours=168、weeks=1;含首尾算 7 天。
未来出发倒计时
start 设 9/10、now 9/1,untilStart=ceil((start−now)/86400000)=9 天;用于_plan 行前准备。

❓ 常见问题(FAQ)

天数含首尾吗?
含,end−start 毫秒加 1 天;nights=days−1 为过夜数。
倒计时负了?
start 已过则 sinceEnd 为正,表示行程已结束多少天。

Formula & Standard References

Item Formula Source-Standard
Day counting Travel days are counted as calendar days including both endpoints ISO 8601-1:2019 Date and time - Representations for information interchange - Part 1: Basic rules
Interval notation Intervals are written as start date slash end date ISO 8601-1:2019 Date and time - Representations for information interchange - Part 1: Basic rules
Month crossing Intervals crossing months sum the actual days of each month ISO 8601-1:2019 Date and time - Representations for information interchange - Part 1: Basic rules
⚠️ 使用说明与注意事项