c++ - 如何将儒略天数转换为儒略日期?44332 到 2021 年 5 月 17 日?
问题描述
我能够将常规日期(例如 05/19/2021)转换为儒略日期编号 44334(自 1990 年以来经过的天数)。
但是,我现在需要做相反的事情,我只是不知道该怎么做。
你能帮我解释一下这里的逻辑吗?
解决方案
You can use date.h
or its C++20 implementation in case you already use it.
using namespace date;
using namespace date::literals;
This will do the trick.
year_month_day ymd(1990_y/01/01); // Create a date object. '_y' is a literal like 'f' for float which comes with `date::literals` or `chorno::literals`.
sys_days total_days = (sys_days)ymd; // Convert it to a time_point.
total_days += days(44334); // Add the days.
year_month_day later = total_days; // Convert it back to an object.
I found help here: std::chrono add days to current date
推荐阅读
- c# - Xamarin Forms/ReactiveUI Router - 关闭子视图后显示子视图并执行父视图模型代码
- css - 悬停时不显示 CSS 子菜单
- android - 如何在android中同时设置两个不同时间的通知警报
- html - 我无法查看此登录页面?
- ios - Swift 中的 UITabBarItem Image Inset 问题
- r - 如何使用基础 R 创建堆叠直方图?
- php - PHP 是否具有相当于 ASP.NET 占位符的功能?
- excel - 使用不同的值填充 ActiveX 组合框
- javascript - 在 mouseenter/mouseleave 上隐藏/显示 HTML 元素
- apache - apache + nginx ubuntu php 系统变量值并不总是相同