blob: d901416cff37357b71611d353ef4ff925d0e2c75 [file] [log] [blame]
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="The time zone."><meta name="keywords" content="rust, rustlang, rust-lang, TimeZone"><title>TimeZone in chrono::offset - Rust</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceSerif4-Regular.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../FiraSans-Regular.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../FiraSans-Medium.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceCodePro-Regular.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceSerif4-Bold.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceCodePro-Semibold.ttf.woff2"><link rel="stylesheet" href="../../normalize.css"><link rel="stylesheet" href="../../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" href="../../ayu.css" disabled><link rel="stylesheet" href="../../dark.css" disabled><link rel="stylesheet" href="../../light.css" id="themeStyle"><script id="default-settings" ></script><script src="../../storage.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../main.js"></script><noscript><link rel="stylesheet" href="../../noscript.css"></noscript><link rel="alternate icon" type="image/png" href="../../favicon-16x16.png"><link rel="alternate icon" type="image/png" href="../../favicon-32x32.png"><link rel="icon" type="image/svg+xml" href="../../favicon.svg"></head><body class="rustdoc trait"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle">&#9776;</button><a class="sidebar-logo" href="../../chrono/index.html"><div class="logo-container"><img class="rust-logo" src="../../rust-logo.svg" alt="logo"></div></a><h2></h2></nav><nav class="sidebar"><a class="sidebar-logo" href="../../chrono/index.html"><div class="logo-container"><img class="rust-logo" src="../../rust-logo.svg" alt="logo"></div></a><h2 class="location"><a href="#">TimeZone</a></h2><div class="sidebar-elems"><section><h3><a href="#required-associated-types">Required Associated Types</a></h3><ul class="block"><li><a href="#associatedtype.Offset">Offset</a></li></ul><h3><a href="#required-methods">Required Methods</a></h3><ul class="block"><li><a href="#tymethod.from_offset">from_offset</a></li><li><a href="#tymethod.offset_from_local_date">offset_from_local_date</a></li><li><a href="#tymethod.offset_from_local_datetime">offset_from_local_datetime</a></li><li><a href="#tymethod.offset_from_utc_date">offset_from_utc_date</a></li><li><a href="#tymethod.offset_from_utc_datetime">offset_from_utc_datetime</a></li></ul><h3><a href="#provided-methods">Provided Methods</a></h3><ul class="block"><li><a href="#method.datetime_from_str">datetime_from_str</a></li><li><a href="#method.from_local_date">from_local_date</a></li><li><a href="#method.from_local_datetime">from_local_datetime</a></li><li><a href="#method.from_utc_date">from_utc_date</a></li><li><a href="#method.from_utc_datetime">from_utc_datetime</a></li><li><a href="#method.isoywd">isoywd</a></li><li><a href="#method.isoywd_opt">isoywd_opt</a></li><li><a href="#method.timestamp">timestamp</a></li><li><a href="#method.timestamp_millis">timestamp_millis</a></li><li><a href="#method.timestamp_millis_opt">timestamp_millis_opt</a></li><li><a href="#method.timestamp_nanos">timestamp_nanos</a></li><li><a href="#method.timestamp_opt">timestamp_opt</a></li><li><a href="#method.with_ymd_and_hms">with_ymd_and_hms</a></li><li><a href="#method.ymd">ymd</a></li><li><a href="#method.ymd_opt">ymd_opt</a></li><li><a href="#method.yo">yo</a></li><li><a href="#method.yo_opt">yo_opt</a></li></ul><h3><a href="#implementors">Implementors</a></h3></section><h2><a href="index.html">In chrono::offset</a></h2></div></nav><main><div class="width-limiter"><nav class="sub"><form class="search-form"><div class="search-container"><span></span><input class="search-input" name="search" autocomplete="off" spellcheck="false" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../wheel.svg"></a></div></div></form></nav><section id="main-content" class="content"><div class="main-heading"><h1 class="fqn">Trait <a href="../index.html">chrono</a>::<wbr><a href="index.html">offset</a>::<wbr><a class="trait" href="#">TimeZone</a><button id="copy-path" onclick="copy_path(this)" title="Copy item path to clipboard"><img src="../../clipboard.svg" width="19" height="18" alt="Copy item path"></button></h1><span class="out-of-band"><a class="srclink" href="../../src/chrono/offset/mod.rs.html#216-501">source</a> · <a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class="inner">&#x2212;</span>]</a></span></div><div class="item-decl"><pre class="rust trait"><code>pub trait TimeZone: Sized + Clone {
type <a href="#associatedtype.Offset" class="associatedtype">Offset</a>: <a class="trait" href="trait.Offset.html" title="trait chrono::offset::Offset">Offset</a>;
<details class="rustdoc-toggle type-contents-toggle"><summary class="hideme"><span>Show 22 methods</span></summary> fn <a href="#tymethod.from_offset" class="fnname">from_offset</a>(offset: &amp;Self::<a class="associatedtype" href="trait.TimeZone.html#associatedtype.Offset" title="type chrono::offset::TimeZone::Offset">Offset</a>) -&gt; Self;
<span class="item-spacer"></span> fn <a href="#tymethod.offset_from_local_date" class="fnname">offset_from_local_date</a>(<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&amp;self,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;local: &amp;<a class="struct" href="../naive/struct.NaiveDate.html" title="struct chrono::naive::NaiveDate">NaiveDate</a><br>&nbsp;&nbsp;&nbsp;&nbsp;) -&gt; <a class="enum" href="enum.LocalResult.html" title="enum chrono::offset::LocalResult">LocalResult</a>&lt;Self::<a class="associatedtype" href="trait.TimeZone.html#associatedtype.Offset" title="type chrono::offset::TimeZone::Offset">Offset</a>&gt;;
<span class="item-spacer"></span> fn <a href="#tymethod.offset_from_local_datetime" class="fnname">offset_from_local_datetime</a>(<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&amp;self,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;local: &amp;<a class="struct" href="../naive/struct.NaiveDateTime.html" title="struct chrono::naive::NaiveDateTime">NaiveDateTime</a><br>&nbsp;&nbsp;&nbsp;&nbsp;) -&gt; <a class="enum" href="enum.LocalResult.html" title="enum chrono::offset::LocalResult">LocalResult</a>&lt;Self::<a class="associatedtype" href="trait.TimeZone.html#associatedtype.Offset" title="type chrono::offset::TimeZone::Offset">Offset</a>&gt;;
<span class="item-spacer"></span> fn <a href="#tymethod.offset_from_utc_date" class="fnname">offset_from_utc_date</a>(&amp;self, utc: &amp;<a class="struct" href="../naive/struct.NaiveDate.html" title="struct chrono::naive::NaiveDate">NaiveDate</a>) -&gt; Self::<a class="associatedtype" href="trait.TimeZone.html#associatedtype.Offset" title="type chrono::offset::TimeZone::Offset">Offset</a>;
<span class="item-spacer"></span> fn <a href="#tymethod.offset_from_utc_datetime" class="fnname">offset_from_utc_datetime</a>(&amp;self, utc: &amp;<a class="struct" href="../naive/struct.NaiveDateTime.html" title="struct chrono::naive::NaiveDateTime">NaiveDateTime</a>) -&gt; Self::<a class="associatedtype" href="trait.TimeZone.html#associatedtype.Offset" title="type chrono::offset::TimeZone::Offset">Offset</a>;
fn <a href="#method.with_ymd_and_hms" class="fnname">with_ymd_and_hms</a>(<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&amp;self,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;year: i32,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;month: u32,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;day: u32,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;hour: u32,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;min: u32,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sec: u32<br>&nbsp;&nbsp;&nbsp;&nbsp;) -&gt; <a class="enum" href="enum.LocalResult.html" title="enum chrono::offset::LocalResult">LocalResult</a>&lt;<a class="struct" href="../struct.DateTime.html" title="struct chrono::DateTime">DateTime</a>&lt;Self&gt;&gt; { ... }
<span class="item-spacer"></span> fn <a href="#method.ymd" class="fnname">ymd</a>(&amp;self, year: i32, month: u32, day: u32) -&gt; <a class="struct" href="../struct.Date.html" title="struct chrono::Date">Date</a>&lt;Self&gt; { ... }
<span class="item-spacer"></span> fn <a href="#method.ymd_opt" class="fnname">ymd_opt</a>(&amp;self, year: i32, month: u32, day: u32) -&gt; <a class="enum" href="enum.LocalResult.html" title="enum chrono::offset::LocalResult">LocalResult</a>&lt;<a class="struct" href="../struct.Date.html" title="struct chrono::Date">Date</a>&lt;Self&gt;&gt; { ... }
<span class="item-spacer"></span> fn <a href="#method.yo" class="fnname">yo</a>(&amp;self, year: i32, ordinal: u32) -&gt; <a class="struct" href="../struct.Date.html" title="struct chrono::Date">Date</a>&lt;Self&gt; { ... }
<span class="item-spacer"></span> fn <a href="#method.yo_opt" class="fnname">yo_opt</a>(&amp;self, year: i32, ordinal: u32) -&gt; <a class="enum" href="enum.LocalResult.html" title="enum chrono::offset::LocalResult">LocalResult</a>&lt;<a class="struct" href="../struct.Date.html" title="struct chrono::Date">Date</a>&lt;Self&gt;&gt; { ... }
<span class="item-spacer"></span> fn <a href="#method.isoywd" class="fnname">isoywd</a>(&amp;self, year: i32, week: u32, weekday: <a class="enum" href="../enum.Weekday.html" title="enum chrono::Weekday">Weekday</a>) -&gt; <a class="struct" href="../struct.Date.html" title="struct chrono::Date">Date</a>&lt;Self&gt; { ... }
<span class="item-spacer"></span> fn <a href="#method.isoywd_opt" class="fnname">isoywd_opt</a>(<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&amp;self,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;year: i32,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;week: u32,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;weekday: <a class="enum" href="../enum.Weekday.html" title="enum chrono::Weekday">Weekday</a><br>&nbsp;&nbsp;&nbsp;&nbsp;) -&gt; <a class="enum" href="enum.LocalResult.html" title="enum chrono::offset::LocalResult">LocalResult</a>&lt;<a class="struct" href="../struct.Date.html" title="struct chrono::Date">Date</a>&lt;Self&gt;&gt; { ... }
<span class="item-spacer"></span> fn <a href="#method.timestamp" class="fnname">timestamp</a>(&amp;self, secs: i64, nsecs: u32) -&gt; <a class="struct" href="../struct.DateTime.html" title="struct chrono::DateTime">DateTime</a>&lt;Self&gt; { ... }
<span class="item-spacer"></span> fn <a href="#method.timestamp_opt" class="fnname">timestamp_opt</a>(&amp;self, secs: i64, nsecs: u32) -&gt; <a class="enum" href="enum.LocalResult.html" title="enum chrono::offset::LocalResult">LocalResult</a>&lt;<a class="struct" href="../struct.DateTime.html" title="struct chrono::DateTime">DateTime</a>&lt;Self&gt;&gt; { ... }
<span class="item-spacer"></span> fn <a href="#method.timestamp_millis" class="fnname">timestamp_millis</a>(&amp;self, millis: i64) -&gt; <a class="struct" href="../struct.DateTime.html" title="struct chrono::DateTime">DateTime</a>&lt;Self&gt; { ... }
<span class="item-spacer"></span> fn <a href="#method.timestamp_millis_opt" class="fnname">timestamp_millis_opt</a>(&amp;self, millis: i64) -&gt; <a class="enum" href="enum.LocalResult.html" title="enum chrono::offset::LocalResult">LocalResult</a>&lt;<a class="struct" href="../struct.DateTime.html" title="struct chrono::DateTime">DateTime</a>&lt;Self&gt;&gt; { ... }
<span class="item-spacer"></span> fn <a href="#method.timestamp_nanos" class="fnname">timestamp_nanos</a>(&amp;self, nanos: i64) -&gt; <a class="struct" href="../struct.DateTime.html" title="struct chrono::DateTime">DateTime</a>&lt;Self&gt; { ... }
<span class="item-spacer"></span> fn <a href="#method.datetime_from_str" class="fnname">datetime_from_str</a>(&amp;self, s: &amp;str, fmt: &amp;str) -&gt; <a class="type" href="../format/type.ParseResult.html" title="type chrono::format::ParseResult">ParseResult</a>&lt;<a class="struct" href="../struct.DateTime.html" title="struct chrono::DateTime">DateTime</a>&lt;Self&gt;&gt; { ... }
<span class="item-spacer"></span> fn <a href="#method.from_local_date" class="fnname">from_local_date</a>(&amp;self, local: &amp;<a class="struct" href="../naive/struct.NaiveDate.html" title="struct chrono::naive::NaiveDate">NaiveDate</a>) -&gt; <a class="enum" href="enum.LocalResult.html" title="enum chrono::offset::LocalResult">LocalResult</a>&lt;<a class="struct" href="../struct.Date.html" title="struct chrono::Date">Date</a>&lt;Self&gt;&gt; { ... }
<span class="item-spacer"></span> fn <a href="#method.from_local_datetime" class="fnname">from_local_datetime</a>(<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&amp;self,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;local: &amp;<a class="struct" href="../naive/struct.NaiveDateTime.html" title="struct chrono::naive::NaiveDateTime">NaiveDateTime</a><br>&nbsp;&nbsp;&nbsp;&nbsp;) -&gt; <a class="enum" href="enum.LocalResult.html" title="enum chrono::offset::LocalResult">LocalResult</a>&lt;<a class="struct" href="../struct.DateTime.html" title="struct chrono::DateTime">DateTime</a>&lt;Self&gt;&gt; { ... }
<span class="item-spacer"></span> fn <a href="#method.from_utc_date" class="fnname">from_utc_date</a>(&amp;self, utc: &amp;<a class="struct" href="../naive/struct.NaiveDate.html" title="struct chrono::naive::NaiveDate">NaiveDate</a>) -&gt; <a class="struct" href="../struct.Date.html" title="struct chrono::Date">Date</a>&lt;Self&gt; { ... }
<span class="item-spacer"></span> fn <a href="#method.from_utc_datetime" class="fnname">from_utc_datetime</a>(&amp;self, utc: &amp;<a class="struct" href="../naive/struct.NaiveDateTime.html" title="struct chrono::naive::NaiveDateTime">NaiveDateTime</a>) -&gt; <a class="struct" href="../struct.DateTime.html" title="struct chrono::DateTime">DateTime</a>&lt;Self&gt; { ... }
</details>}</code></pre></div><details class="rustdoc-toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>The time zone.</p>
<p>The methods here are the primarily constructors for <a href="../struct.Date.html"><code>Date</code></a> and
<a href="../struct.DateTime.html"><code>DateTime</code></a> types.</p>
</div></details><h2 id="required-associated-types" class="small-section-header">Required Associated Types<a href="#required-associated-types" class="anchor"></a></h2><div class="methods"><details class="rustdoc-toggle method-toggle" open><summary><section id="associatedtype.Offset" class="method has-srclink"><a class="srclink rightside" href="../../src/chrono/offset/mod.rs.html#220">source</a><h4 class="code-header">type <a href="#associatedtype.Offset" class="associatedtype">Offset</a>: <a class="trait" href="trait.Offset.html" title="trait chrono::offset::Offset">Offset</a></h4></section></summary><div class="docblock"><p>An associated offset type.
This type is used to store the actual offset in date and time types.
The original <code>TimeZone</code> value can be recovered via <code>TimeZone::from_offset</code>.</p>
</div></details></div><h2 id="required-methods" class="small-section-header">Required Methods<a href="#required-methods" class="anchor"></a></h2><div class="methods"><details class="rustdoc-toggle method-toggle" open><summary><section id="tymethod.from_offset" class="method has-srclink"><a class="srclink rightside" href="../../src/chrono/offset/mod.rs.html#454">source</a><h4 class="code-header">fn <a href="#tymethod.from_offset" class="fnname">from_offset</a>(offset: &amp;Self::<a class="associatedtype" href="trait.TimeZone.html#associatedtype.Offset" title="type chrono::offset::TimeZone::Offset">Offset</a>) -&gt; Self</h4></section></summary><div class="docblock"><p>Reconstructs the time zone from the offset.</p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="tymethod.offset_from_local_date" class="method has-srclink"><a class="srclink rightside" href="../../src/chrono/offset/mod.rs.html#457">source</a><h4 class="code-header">fn <a href="#tymethod.offset_from_local_date" class="fnname">offset_from_local_date</a>(&amp;self, local: &amp;<a class="struct" href="../naive/struct.NaiveDate.html" title="struct chrono::naive::NaiveDate">NaiveDate</a>) -&gt; <a class="enum" href="enum.LocalResult.html" title="enum chrono::offset::LocalResult">LocalResult</a>&lt;Self::<a class="associatedtype" href="trait.TimeZone.html#associatedtype.Offset" title="type chrono::offset::TimeZone::Offset">Offset</a>&gt;</h4></section></summary><div class="docblock"><p>Creates the offset(s) for given local <code>NaiveDate</code> if possible.</p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="tymethod.offset_from_local_datetime" class="method has-srclink"><a class="srclink rightside" href="../../src/chrono/offset/mod.rs.html#460">source</a><h4 class="code-header">fn <a href="#tymethod.offset_from_local_datetime" class="fnname">offset_from_local_datetime</a>(<br>&nbsp;&nbsp;&nbsp;&nbsp;&amp;self,<br>&nbsp;&nbsp;&nbsp;&nbsp;local: &amp;<a class="struct" href="../naive/struct.NaiveDateTime.html" title="struct chrono::naive::NaiveDateTime">NaiveDateTime</a><br>) -&gt; <a class="enum" href="enum.LocalResult.html" title="enum chrono::offset::LocalResult">LocalResult</a>&lt;Self::<a class="associatedtype" href="trait.TimeZone.html#associatedtype.Offset" title="type chrono::offset::TimeZone::Offset">Offset</a>&gt;</h4></section></summary><div class="docblock"><p>Creates the offset(s) for given local <code>NaiveDateTime</code> if possible.</p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="tymethod.offset_from_utc_date" class="method has-srclink"><a class="srclink rightside" href="../../src/chrono/offset/mod.rs.html#481">source</a><h4 class="code-header">fn <a href="#tymethod.offset_from_utc_date" class="fnname">offset_from_utc_date</a>(&amp;self, utc: &amp;<a class="struct" href="../naive/struct.NaiveDate.html" title="struct chrono::naive::NaiveDate">NaiveDate</a>) -&gt; Self::<a class="associatedtype" href="trait.TimeZone.html#associatedtype.Offset" title="type chrono::offset::TimeZone::Offset">Offset</a></h4></section></summary><div class="docblock"><p>Creates the offset for given UTC <code>NaiveDate</code>. This cannot fail.</p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="tymethod.offset_from_utc_datetime" class="method has-srclink"><a class="srclink rightside" href="../../src/chrono/offset/mod.rs.html#484">source</a><h4 class="code-header">fn <a href="#tymethod.offset_from_utc_datetime" class="fnname">offset_from_utc_datetime</a>(&amp;self, utc: &amp;<a class="struct" href="../naive/struct.NaiveDateTime.html" title="struct chrono::naive::NaiveDateTime">NaiveDateTime</a>) -&gt; Self::<a class="associatedtype" href="trait.TimeZone.html#associatedtype.Offset" title="type chrono::offset::TimeZone::Offset">Offset</a></h4></section></summary><div class="docblock"><p>Creates the offset for given UTC <code>NaiveDateTime</code>. This cannot fail.</p>
</div></details></div><h2 id="provided-methods" class="small-section-header">Provided Methods<a href="#provided-methods" class="anchor"></a></h2><div class="methods"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.with_ymd_and_hms" class="method has-srclink"><a class="srclink rightside" href="../../src/chrono/offset/mod.rs.html#227-241">source</a><h4 class="code-header">fn <a href="#method.with_ymd_and_hms" class="fnname">with_ymd_and_hms</a>(<br>&nbsp;&nbsp;&nbsp;&nbsp;&amp;self,<br>&nbsp;&nbsp;&nbsp;&nbsp;year: i32,<br>&nbsp;&nbsp;&nbsp;&nbsp;month: u32,<br>&nbsp;&nbsp;&nbsp;&nbsp;day: u32,<br>&nbsp;&nbsp;&nbsp;&nbsp;hour: u32,<br>&nbsp;&nbsp;&nbsp;&nbsp;min: u32,<br>&nbsp;&nbsp;&nbsp;&nbsp;sec: u32<br>) -&gt; <a class="enum" href="enum.LocalResult.html" title="enum chrono::offset::LocalResult">LocalResult</a>&lt;<a class="struct" href="../struct.DateTime.html" title="struct chrono::DateTime">DateTime</a>&lt;Self&gt;&gt;</h4></section></summary><div class="docblock"><p>Make a new <code>DateTime</code> from year, month, day, time components and current time zone.</p>
<p>This assumes the proleptic Gregorian calendar, with the year 0 being 1 BCE.</p>
<p>Returns <code>LocalResult::None</code> on invalid input data.</p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.ymd" class="method has-srclink"><a class="srclink rightside" href="../../src/chrono/offset/mod.rs.html#252-254">source</a><h4 class="code-header">fn <a href="#method.ymd" class="fnname">ymd</a>(&amp;self, year: i32, month: u32, day: u32) -&gt; <a class="struct" href="../struct.Date.html" title="struct chrono::Date">Date</a>&lt;Self&gt;</h4></section></summary><span class="item-info"><div class="stab deprecated"><span class="emoji">👎</span><span>Deprecated since 0.4.23: use <code>with_ymd_and_hms()</code> instead</span></div></span><div class="docblock"><p>Makes a new <code>Date</code> from year, month, day and the current time zone.
This assumes the proleptic Gregorian calendar, with the year 0 being 1 BCE.</p>
<p>The time zone normally does not affect the date (unless it is between UTC-24 and UTC+24),
but it will propagate to the <code>DateTime</code> values constructed via this date.</p>
<p>Panics on the out-of-range date, invalid month and/or day.</p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.ymd_opt" class="method has-srclink"><a class="srclink rightside" href="../../src/chrono/offset/mod.rs.html#265-270">source</a><h4 class="code-header">fn <a href="#method.ymd_opt" class="fnname">ymd_opt</a>(&amp;self, year: i32, month: u32, day: u32) -&gt; <a class="enum" href="enum.LocalResult.html" title="enum chrono::offset::LocalResult">LocalResult</a>&lt;<a class="struct" href="../struct.Date.html" title="struct chrono::Date">Date</a>&lt;Self&gt;&gt;</h4></section></summary><span class="item-info"><div class="stab deprecated"><span class="emoji">👎</span><span>Deprecated since 0.4.23: use <code>with_ymd_and_hms()</code> instead</span></div></span><div class="docblock"><p>Makes a new <code>Date</code> from year, month, day and the current time zone.
This assumes the proleptic Gregorian calendar, with the year 0 being 1 BCE.</p>
<p>The time zone normally does not affect the date (unless it is between UTC-24 and UTC+24),
but it will propagate to the <code>DateTime</code> values constructed via this date.</p>
<p>Returns <code>None</code> on the out-of-range date, invalid month and/or day.</p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.yo" class="method has-srclink"><a class="srclink rightside" href="../../src/chrono/offset/mod.rs.html#284-286">source</a><h4 class="code-header">fn <a href="#method.yo" class="fnname">yo</a>(&amp;self, year: i32, ordinal: u32) -&gt; <a class="struct" href="../struct.Date.html" title="struct chrono::Date">Date</a>&lt;Self&gt;</h4></section></summary><span class="item-info"><div class="stab deprecated"><span class="emoji">👎</span><span>Deprecated since 0.4.23: use <code>from_local_datetime()</code> with a <code>NaiveDateTime</code> instead</span></div></span><div class="docblock"><p>Makes a new <code>Date</code> from year, day of year (DOY or “ordinal”) and the current time zone.
This assumes the proleptic Gregorian calendar, with the year 0 being 1 BCE.</p>
<p>The time zone normally does not affect the date (unless it is between UTC-24 and UTC+24),
but it will propagate to the <code>DateTime</code> values constructed via this date.</p>
<p>Panics on the out-of-range date and/or invalid DOY.</p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.yo_opt" class="method has-srclink"><a class="srclink rightside" href="../../src/chrono/offset/mod.rs.html#300-305">source</a><h4 class="code-header">fn <a href="#method.yo_opt" class="fnname">yo_opt</a>(&amp;self, year: i32, ordinal: u32) -&gt; <a class="enum" href="enum.LocalResult.html" title="enum chrono::offset::LocalResult">LocalResult</a>&lt;<a class="struct" href="../struct.Date.html" title="struct chrono::Date">Date</a>&lt;Self&gt;&gt;</h4></section></summary><span class="item-info"><div class="stab deprecated"><span class="emoji">👎</span><span>Deprecated since 0.4.23: use <code>from_local_datetime()</code> with a <code>NaiveDateTime</code> instead</span></div></span><div class="docblock"><p>Makes a new <code>Date</code> from year, day of year (DOY or “ordinal”) and the current time zone.
This assumes the proleptic Gregorian calendar, with the year 0 being 1 BCE.</p>
<p>The time zone normally does not affect the date (unless it is between UTC-24 and UTC+24),
but it will propagate to the <code>DateTime</code> values constructed via this date.</p>
<p>Returns <code>None</code> on the out-of-range date and/or invalid DOY.</p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.isoywd" class="method has-srclink"><a class="srclink rightside" href="../../src/chrono/offset/mod.rs.html#321-323">source</a><h4 class="code-header">fn <a href="#method.isoywd" class="fnname">isoywd</a>(&amp;self, year: i32, week: u32, weekday: <a class="enum" href="../enum.Weekday.html" title="enum chrono::Weekday">Weekday</a>) -&gt; <a class="struct" href="../struct.Date.html" title="struct chrono::Date">Date</a>&lt;Self&gt;</h4></section></summary><span class="item-info"><div class="stab deprecated"><span class="emoji">👎</span><span>Deprecated since 0.4.23: use <code>from_local_datetime()</code> with a <code>NaiveDateTime</code> instead</span></div></span><div class="docblock"><p>Makes a new <code>Date</code> from ISO week date (year and week number), day of the week (DOW) and
the current time zone.
This assumes the proleptic Gregorian calendar, with the year 0 being 1 BCE.
The resulting <code>Date</code> may have a different year from the input year.</p>
<p>The time zone normally does not affect the date (unless it is between UTC-24 and UTC+24),
but it will propagate to the <code>DateTime</code> values constructed via this date.</p>
<p>Panics on the out-of-range date and/or invalid week number.</p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.isoywd_opt" class="method has-srclink"><a class="srclink rightside" href="../../src/chrono/offset/mod.rs.html#339-344">source</a><h4 class="code-header">fn <a href="#method.isoywd_opt" class="fnname">isoywd_opt</a>(<br>&nbsp;&nbsp;&nbsp;&nbsp;&amp;self,<br>&nbsp;&nbsp;&nbsp;&nbsp;year: i32,<br>&nbsp;&nbsp;&nbsp;&nbsp;week: u32,<br>&nbsp;&nbsp;&nbsp;&nbsp;weekday: <a class="enum" href="../enum.Weekday.html" title="enum chrono::Weekday">Weekday</a><br>) -&gt; <a class="enum" href="enum.LocalResult.html" title="enum chrono::offset::LocalResult">LocalResult</a>&lt;<a class="struct" href="../struct.Date.html" title="struct chrono::Date">Date</a>&lt;Self&gt;&gt;</h4></section></summary><span class="item-info"><div class="stab deprecated"><span class="emoji">👎</span><span>Deprecated since 0.4.23: use <code>from_local_datetime()</code> with a <code>NaiveDateTime</code> instead</span></div></span><div class="docblock"><p>Makes a new <code>Date</code> from ISO week date (year and week number), day of the week (DOW) and
the current time zone.
This assumes the proleptic Gregorian calendar, with the year 0 being 1 BCE.
The resulting <code>Date</code> may have a different year from the input year.</p>
<p>The time zone normally does not affect the date (unless it is between UTC-24 and UTC+24),
but it will propagate to the <code>DateTime</code> values constructed via this date.</p>
<p>Returns <code>None</code> on the out-of-range date and/or invalid week number.</p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.timestamp" class="method has-srclink"><a class="srclink rightside" href="../../src/chrono/offset/mod.rs.html#353-355">source</a><h4 class="code-header">fn <a href="#method.timestamp" class="fnname">timestamp</a>(&amp;self, secs: i64, nsecs: u32) -&gt; <a class="struct" href="../struct.DateTime.html" title="struct chrono::DateTime">DateTime</a>&lt;Self&gt;</h4></section></summary><span class="item-info"><div class="stab deprecated"><span class="emoji">👎</span><span>Deprecated since 0.4.23: use <code>timestamp_opt()</code> instead</span></div></span><div class="docblock"><p>Makes a new <code>DateTime</code> from the number of non-leap seconds
since January 1, 1970 0:00:00 UTC (aka “UNIX timestamp”)
and the number of nanoseconds since the last whole non-leap second.</p>
<p>Panics on the out-of-range number of seconds and/or invalid nanosecond,
for a non-panicking version see <a href="#method.timestamp_opt"><code>timestamp_opt</code></a>.</p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.timestamp_opt" class="method has-srclink"><a class="srclink rightside" href="../../src/chrono/offset/mod.rs.html#371-376">source</a><h4 class="code-header">fn <a href="#method.timestamp_opt" class="fnname">timestamp_opt</a>(&amp;self, secs: i64, nsecs: u32) -&gt; <a class="enum" href="enum.LocalResult.html" title="enum chrono::offset::LocalResult">LocalResult</a>&lt;<a class="struct" href="../struct.DateTime.html" title="struct chrono::DateTime">DateTime</a>&lt;Self&gt;&gt;</h4></section></summary><div class="docblock"><p>Makes a new <code>DateTime</code> from the number of non-leap seconds
since January 1, 1970 0:00:00 UTC (aka “UNIX timestamp”)
and the number of nanoseconds since the last whole non-leap second.</p>
<p>Returns <code>LocalResult::None</code> on out-of-range number of seconds and/or
invalid nanosecond, otherwise always returns <code>LocalResult::Single</code>.</p>
<h5 id="example"><a href="#example">Example</a></h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>chrono::{Utc, TimeZone};
<span class="macro">assert_eq!</span>(Utc.timestamp_opt(<span class="number">1431648000</span>, <span class="number">0</span>).unwrap().to_string(), <span class="string">&quot;2015-05-15 00:00:00 UTC&quot;</span>);</code></pre></div>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.timestamp_millis" class="method has-srclink"><a class="srclink rightside" href="../../src/chrono/offset/mod.rs.html#384-386">source</a><h4 class="code-header">fn <a href="#method.timestamp_millis" class="fnname">timestamp_millis</a>(&amp;self, millis: i64) -&gt; <a class="struct" href="../struct.DateTime.html" title="struct chrono::DateTime">DateTime</a>&lt;Self&gt;</h4></section></summary><span class="item-info"><div class="stab deprecated"><span class="emoji">👎</span><span>Deprecated since 0.4.23: use <code>timestamp_millis_opt()</code> instead</span></div></span><div class="docblock"><p>Makes a new <code>DateTime</code> from the number of non-leap milliseconds
since January 1, 1970 0:00:00 UTC (aka “UNIX timestamp”).</p>
<p>Panics on out-of-range number of milliseconds for a non-panicking
version see <a href="#method.timestamp_millis_opt"><code>timestamp_millis_opt</code></a>.</p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.timestamp_millis_opt" class="method has-srclink"><a class="srclink rightside" href="../../src/chrono/offset/mod.rs.html#405-412">source</a><h4 class="code-header">fn <a href="#method.timestamp_millis_opt" class="fnname">timestamp_millis_opt</a>(&amp;self, millis: i64) -&gt; <a class="enum" href="enum.LocalResult.html" title="enum chrono::offset::LocalResult">LocalResult</a>&lt;<a class="struct" href="../struct.DateTime.html" title="struct chrono::DateTime">DateTime</a>&lt;Self&gt;&gt;</h4></section></summary><div class="docblock"><p>Makes a new <code>DateTime</code> from the number of non-leap milliseconds
since January 1, 1970 0:00:00 UTC (aka “UNIX timestamp”).</p>
<p>Returns <code>LocalResult::None</code> on out-of-range number of milliseconds
and/or invalid nanosecond, otherwise always returns
<code>LocalResult::Single</code>.</p>
<h5 id="example-1"><a href="#example-1">Example</a></h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>chrono::{Utc, TimeZone, LocalResult};
<span class="kw">match </span>Utc.timestamp_millis_opt(<span class="number">1431648000</span>) {
LocalResult::Single(dt) =&gt; <span class="macro">assert_eq!</span>(dt.timestamp(), <span class="number">1431648</span>),
<span class="kw">_ </span>=&gt; <span class="macro">panic!</span>(<span class="string">&quot;Incorrect timestamp_millis&quot;</span>),
};</code></pre></div>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.timestamp_nanos" class="method has-srclink"><a class="srclink rightside" href="../../src/chrono/offset/mod.rs.html#427-434">source</a><h4 class="code-header">fn <a href="#method.timestamp_nanos" class="fnname">timestamp_nanos</a>(&amp;self, nanos: i64) -&gt; <a class="struct" href="../struct.DateTime.html" title="struct chrono::DateTime">DateTime</a>&lt;Self&gt;</h4></section></summary><div class="docblock"><p>Makes a new <code>DateTime</code> from the number of non-leap nanoseconds
since January 1, 1970 0:00:00 UTC (aka “UNIX timestamp”).</p>
<p>Unlike <a href="#method.timestamp_millis"><code>timestamp_millis</code></a>, this never
panics.</p>
<h5 id="example-2"><a href="#example-2">Example</a></h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>chrono::{Utc, TimeZone};
<span class="macro">assert_eq!</span>(Utc.timestamp_nanos(<span class="number">1431648000000000</span>).timestamp(), <span class="number">1431648</span>);</code></pre></div>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.datetime_from_str" class="method has-srclink"><a class="srclink rightside" href="../../src/chrono/offset/mod.rs.html#447-451">source</a><h4 class="code-header">fn <a href="#method.datetime_from_str" class="fnname">datetime_from_str</a>(&amp;self, s: &amp;str, fmt: &amp;str) -&gt; <a class="type" href="../format/type.ParseResult.html" title="type chrono::format::ParseResult">ParseResult</a>&lt;<a class="struct" href="../struct.DateTime.html" title="struct chrono::DateTime">DateTime</a>&lt;Self&gt;&gt;</h4></section></summary><div class="docblock"><p>Parses a string with the specified format string and returns a
<code>DateTime</code> with the current offset.</p>
<p>See the <a href="../format/strftime/index.html" title="crate::format::strftime"><code>crate::format::strftime</code></a> module on the
supported escape sequences.</p>
<p>If the to-be-parsed string includes an offset, it <em>must</em> match the
offset of the TimeZone, otherwise an error will be returned.</p>
<p>See also <a href="../struct.DateTime.html#method.parse_from_str" title="DateTime::parse_from_str"><code>DateTime::parse_from_str</code></a> which gives a <a href="../struct.DateTime.html" title="DateTime"><code>DateTime</code></a> with
parsed <a href="struct.FixedOffset.html" title="FixedOffset"><code>FixedOffset</code></a>.</p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.from_local_date" class="method has-srclink"><a class="srclink rightside" href="../../src/chrono/offset/mod.rs.html#466-471">source</a><h4 class="code-header">fn <a href="#method.from_local_date" class="fnname">from_local_date</a>(&amp;self, local: &amp;<a class="struct" href="../naive/struct.NaiveDate.html" title="struct chrono::naive::NaiveDate">NaiveDate</a>) -&gt; <a class="enum" href="enum.LocalResult.html" title="enum chrono::offset::LocalResult">LocalResult</a>&lt;<a class="struct" href="../struct.Date.html" title="struct chrono::Date">Date</a>&lt;Self&gt;&gt;</h4></section></summary><span class="item-info"><div class="stab deprecated"><span class="emoji">👎</span><span>Deprecated since 0.4.23: use <code>from_local_datetime()</code> instead</span></div></span><div class="docblock"><p>Converts the local <code>NaiveDate</code> to the timezone-aware <code>Date</code> if possible.</p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.from_local_datetime" class="method has-srclink"><a class="srclink rightside" href="../../src/chrono/offset/mod.rs.html#475-478">source</a><h4 class="code-header">fn <a href="#method.from_local_datetime" class="fnname">from_local_datetime</a>(<br>&nbsp;&nbsp;&nbsp;&nbsp;&amp;self,<br>&nbsp;&nbsp;&nbsp;&nbsp;local: &amp;<a class="struct" href="../naive/struct.NaiveDateTime.html" title="struct chrono::naive::NaiveDateTime">NaiveDateTime</a><br>) -&gt; <a class="enum" href="enum.LocalResult.html" title="enum chrono::offset::LocalResult">LocalResult</a>&lt;<a class="struct" href="../struct.DateTime.html" title="struct chrono::DateTime">DateTime</a>&lt;Self&gt;&gt;</h4></section></summary><div class="docblock"><p>Converts the local <code>NaiveDateTime</code> to the timezone-aware <code>DateTime</code> if possible.</p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.from_utc_date" class="method has-srclink"><a class="srclink rightside" href="../../src/chrono/offset/mod.rs.html#491-493">source</a><h4 class="code-header">fn <a href="#method.from_utc_date" class="fnname">from_utc_date</a>(&amp;self, utc: &amp;<a class="struct" href="../naive/struct.NaiveDate.html" title="struct chrono::naive::NaiveDate">NaiveDate</a>) -&gt; <a class="struct" href="../struct.Date.html" title="struct chrono::Date">Date</a>&lt;Self&gt;</h4></section></summary><span class="item-info"><div class="stab deprecated"><span class="emoji">👎</span><span>Deprecated since 0.4.23: use <code>from_utc_datetime()</code> instead</span></div></span><div class="docblock"><p>Converts the UTC <code>NaiveDate</code> to the local time.
The UTC is continuous and thus this cannot fail (but can give the duplicate local time).</p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.from_utc_datetime" class="method has-srclink"><a class="srclink rightside" href="../../src/chrono/offset/mod.rs.html#498-500">source</a><h4 class="code-header">fn <a href="#method.from_utc_datetime" class="fnname">from_utc_datetime</a>(&amp;self, utc: &amp;<a class="struct" href="../naive/struct.NaiveDateTime.html" title="struct chrono::naive::NaiveDateTime">NaiveDateTime</a>) -&gt; <a class="struct" href="../struct.DateTime.html" title="struct chrono::DateTime">DateTime</a>&lt;Self&gt;</h4></section></summary><div class="docblock"><p>Converts the UTC <code>NaiveDateTime</code> to the local time.
The UTC is continuous and thus this cannot fail (but can give the duplicate local time).</p>
</div></details></div><h2 id="implementors" class="small-section-header">Implementors<a href="#implementors" class="anchor"></a></h2><div id="implementors-list"><details class="rustdoc-toggle implementors-toggle"><summary><section id="impl-TimeZone-for-FixedOffset" class="impl has-srclink"><a class="srclink rightside" href="../../src/chrono/offset/fixed.rs.html#116-136">source</a><a href="#impl-TimeZone-for-FixedOffset" class="anchor"></a><h3 class="code-header">impl <a class="trait" href="trait.TimeZone.html" title="trait chrono::offset::TimeZone">TimeZone</a> for <a class="struct" href="struct.FixedOffset.html" title="struct chrono::offset::FixedOffset">FixedOffset</a></h3></section></summary><div class="impl-items"><section id="associatedtype.Offset-1" class="associatedtype trait-impl has-srclink"><a href="#associatedtype.Offset-1" class="anchor"></a><h4 class="code-header">type <a href="#associatedtype.Offset" class="associatedtype">Offset</a> = <a class="struct" href="struct.FixedOffset.html" title="struct chrono::offset::FixedOffset">FixedOffset</a></h4></section></div></details><details class="rustdoc-toggle implementors-toggle"><summary><section id="impl-TimeZone-for-Utc" class="impl has-srclink"><a class="srclink rightside" href="../../src/chrono/offset/utc.rs.html#90-110">source</a><a href="#impl-TimeZone-for-Utc" class="anchor"></a><h3 class="code-header">impl <a class="trait" href="trait.TimeZone.html" title="trait chrono::offset::TimeZone">TimeZone</a> for <a class="struct" href="struct.Utc.html" title="struct chrono::offset::Utc">Utc</a></h3></section></summary><div class="impl-items"><section id="associatedtype.Offset-2" class="associatedtype trait-impl has-srclink"><a href="#associatedtype.Offset-2" class="anchor"></a><h4 class="code-header">type <a href="#associatedtype.Offset" class="associatedtype">Offset</a> = <a class="struct" href="struct.Utc.html" title="struct chrono::offset::Utc">Utc</a></h4></section></div></details></div><script src="../../implementors/chrono/offset/trait.TimeZone.js" async></script></section></div></main><div id="rustdoc-vars" data-root-path="../../" data-current-crate="chrono" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.66.0-nightly (5c8bff74b 2022-10-21)" ></div></body></html>