mirror of
https://github.com/HowardHinnant/date.git
synced 2024-12-27 00:14:07 +08:00
8eeae97520
This patch updates the html documentation to add the color-scheme meta element, signaling ligth and dark color scheme support, and updating the inline CSS styles to override some colors when dark mode is active, to make sure that the document is always readable. I've also cleaned up a bit the CSS styles, but without functional changes.
157 lines
2.9 KiB
HTML
157 lines
2.9 KiB
HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
|
"http://www.w3.org/TR/html4/loose.dtd">
|
|
<html>
|
|
<head>
|
|
<title>julian</title>
|
|
|
|
<meta name="color-scheme" content="light dark" />
|
|
<style>
|
|
li, p {text-align:justify}
|
|
ins {color:#00A000}
|
|
del {color:#A00000}
|
|
code {white-space:pre;}
|
|
@media (prefers-color-scheme: dark)
|
|
{
|
|
ins {color:#88FF88}
|
|
del {color:#FF5555}
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
|
|
<address align=right>
|
|
<br/>
|
|
<br/>
|
|
<a href="mailto:howard.hinnant@gmail.com">Howard E. Hinnant</a><br/>
|
|
2016-06-26<br/>
|
|
</address>
|
|
<hr/>
|
|
<h1 align=center><code>julian</code></h1>
|
|
|
|
<h2>Contents</h2>
|
|
|
|
<ul>
|
|
<li><a href="https://github.com/HowardHinnant/date">github link</a></li>
|
|
<li><a href="#Introduction">Introduction</a></li>
|
|
</ul>
|
|
|
|
<a name="Introduction"></a><h2>Introduction</h2>
|
|
|
|
<p>
|
|
This is a Julian calendar in the style of
|
|
<a href="date.html">date.h</a>.
|
|
Everything is the same here as for
|
|
<a href="date.html">date.h</a>,
|
|
except that the calendrical arithmetic implements a proleptic Julian calendar.
|
|
</p>
|
|
|
|
<p>
|
|
The <code>julian</code> calendar can interoperate with
|
|
<a href="date.html">date.h</a> and <a href="tz.html">tz.h</a> just by
|
|
paying attention to the namespace. For example to convert the <i>civil</i>
|
|
date <code>2016_y/jun/26</code> to a julian date, just do:
|
|
</p>
|
|
|
|
<blockquote><pre>
|
|
#include "julian.h"
|
|
#include <iostream>
|
|
|
|
int
|
|
main()
|
|
{
|
|
using namespace date::literals;
|
|
std::cout << julian::year_month_day{2016_y/jun/26} << '\n';
|
|
}
|
|
</pre></blockquote>
|
|
|
|
<p>
|
|
This outputs:
|
|
</p>
|
|
|
|
<blockquote><pre>
|
|
2016-06-13
|
|
</pre></blockquote>
|
|
|
|
<p>
|
|
And here is the reverse conversion:
|
|
</p>
|
|
|
|
<blockquote><pre>
|
|
#include "julian.h"
|
|
#include <iostream>
|
|
|
|
int
|
|
main()
|
|
{
|
|
using namespace julian::literals;
|
|
std::cout << date::year_month_day{2016_y/jun/13} << '\n';
|
|
}
|
|
</pre></blockquote>
|
|
|
|
<p>
|
|
Which outputs:
|
|
</p>
|
|
|
|
<blockquote><pre>
|
|
2016-06-26
|
|
</pre></blockquote>
|
|
|
|
<p>
|
|
You can even convert directly to the ISO-week-based calendar:
|
|
</p>
|
|
|
|
<blockquote><pre>
|
|
#include "iso_week.h"
|
|
#include "julian.h"
|
|
#include <iostream>
|
|
|
|
int
|
|
main()
|
|
{
|
|
using namespace julian::literals;
|
|
std::cout << iso_week::year_weeknum_weekday{2016_y/jun/13} << '\n';
|
|
}
|
|
</pre></blockquote>
|
|
|
|
<p>
|
|
Which outputs:
|
|
</p>
|
|
|
|
<blockquote><pre>
|
|
2016-W25-Sun
|
|
</pre></blockquote>
|
|
|
|
<p>
|
|
|
|
<p>
|
|
You can find the current local julian date and time with:
|
|
</p>
|
|
|
|
<blockquote><pre>
|
|
#include "julian.h"
|
|
#include "tz.h"
|
|
#include <iostream>
|
|
|
|
int
|
|
main()
|
|
{
|
|
auto zt = date::make_zoned(date::current_zone(), std::chrono::system_clock::now());
|
|
auto ld = date::floor<date::days>(zt.get_local_time());
|
|
julian::year_month_day ymd{ld};
|
|
auto time = date::make_time(zt.get_local_time() - ld);
|
|
std::cout << ymd << ' ' << time << '\n';
|
|
}
|
|
</pre></blockquote>
|
|
|
|
<p>
|
|
Example output:
|
|
</p>
|
|
|
|
<blockquote><pre>
|
|
2016-06-13 18:38:30.049598
|
|
</pre></blockquote>
|
|
|
|
|
|
</body>
|
|
</html>
|