<turbo-stream action="append" target="posts_list"><template>    <div class="postbit" id="212404" data-post-id="212404">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="mathieuprog" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/mathieuprog/120/16860_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  mathieuprog
                    <span class="op-star" title="Thread Starter">
                      <img alt="OP" class="op-star-icon" src="/assets/thread-icons/thread-icon-thread-starter-df91e872.png" />
                    </span>
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>I refactored <code>tz_extra</code> API. To get the list of time zones you have now two functions:</p>
<ul>
<li><code>TzExtra.time_zone_identifiers/1</code></li>
<li><code>TzExtra.civil_time_zone_identifiers/1</code></li>
</ul>
<p>The latter will only return the time zones attached to a country. For example, it will not return the “Etc/GMT+6” time zone. Both functions take some options, and note that the previous option names have been changed.</p>
<p>I also added Ecto Changeset validators:</p>
<ul>
<li><code>validate_civil_time_zone_identifier/3</code></li>
<li><code>validate_time_zone_identifier/3</code></li>
<li><code>validate_iso_country_code/3</code></li>
</ul>
<p>Example:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">import TzExtra.Changeset

def changeset(location, attrs) do
  location
  |&gt; cast(attrs, @required_fields ++ @optional_fields)
  |&gt; validate_required(@required_fields)
  |&gt; validate_iso_country_code(:country_code)
  |&gt; validate_civil_time_zone_identifier(:time_zone)
end
</code></pre> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="212404" data-batch-url="/posts/batch_likers">
                        3
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/tz-time-zone-support-for-elixir-alternative-to-tzdata-that-comes-with-a-lot-of-bugfixes/29358/33">Post #32</a>
	                </div>
	            </div>
              <div id="likers-container-212404" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="212404"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #32"></div>
  </section>
</div>
    <div class="postbit" id="212428" data-post-id="212428">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="slouchpie" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/slouchpie/120/34819_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  slouchpie
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Wow! That’s beautiful!</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="212428" data-batch-url="/posts/batch_likers">
                        0
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/tz-time-zone-support-for-elixir-alternative-to-tzdata-that-comes-with-a-lot-of-bugfixes/29358/34">Post #33</a>
	                </div>
	            </div>
              <div id="likers-container-212428" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="212428"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #33"></div>
  </section>
</div>
    <div class="postbit" id="212621" data-post-id="212621">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="mathieuprog" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/mathieuprog/120/16860_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  mathieuprog
                    <span class="op-star" title="Thread Starter">
                      <img alt="OP" class="op-star-icon" src="/assets/thread-icons/thread-icon-thread-starter-df91e872.png" />
                    </span>
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Added a function to <code>tz_extra</code> allowing you to retrieve the canonical time zone of a time zone:<br>
<code>get_canonical_time_zone_identifier/1</code></p>
<pre data-code-wrap="elixir"><code class="lang-elixir">iex&gt; TzExtra.get_canonical_time_zone_identifier("Asia/Phnom_Penh")
"Asia/Bangkok"
</code></pre>
<pre data-code-wrap="elixir"><code class="lang-elixir">iex&gt; TzExtra.get_canonical_time_zone_identifier("Asia/Bangkok")
"Asia/Bangkok"
</code></pre>
<p>cc <a class="mention" href="/u/jsmestad" rel="nofollow">@jsmestad</a></p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="212621" data-batch-url="/posts/batch_likers">
                        4
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/tz-time-zone-support-for-elixir-alternative-to-tzdata-that-comes-with-a-lot-of-bugfixes/29358/35">Post #34</a>
	                </div>
	            </div>
              <div id="likers-container-212621" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="212621"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #34"></div>
  </section>
</div>
    <div class="postbit" id="212795" data-post-id="212795">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="jsmestad" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/jsmestad/120/14153_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  jsmestad
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Awesome!</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="212795" data-batch-url="/posts/batch_likers">
                        0
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/tz-time-zone-support-for-elixir-alternative-to-tzdata-that-comes-with-a-lot-of-bugfixes/29358/36">Post #35</a>
	                </div>
	            </div>
              <div id="likers-container-212795" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="212795"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #35"></div>
  </section>
</div>
    <div class="postbit" id="218251" data-post-id="218251">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="mathieuprog" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/mathieuprog/120/16860_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  mathieuprog
                    <span class="op-star" title="Thread Starter">
                      <img alt="OP" class="op-star-icon" src="/assets/thread-icons/thread-icon-thread-starter-df91e872.png" />
                    </span>
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>From version 0.17 it is now possible to:</p>
<ul>
<li>
<p>specify a custom HTTP client, you may find an example using <code>:finch</code> in the Readme.<br>
Thank you for the suggestion <a class="mention" href="/u/benwilson512" rel="nofollow">@benwilson512</a>! Took only a little over a year <img src="https://forum.elixirforum.com/images/emoji/apple/smiley.png?v=15" title=":smiley:" class="emoji" alt=":smiley:" loading="lazy" width="20" height="20"></p>
</li>
<li>
<p>specify a custom directory for the storage of the IANA time zone data files.</p>
</li>
</ul>
<p>But most importantly, a lot of work has been put into the project to increase the performance. It is now <em>very</em> fast, compared to the early versions and compared to the performance of the Tzdata lib.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="218251" data-batch-url="/posts/batch_likers">
                        4
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/tz-time-zone-support-for-elixir-alternative-to-tzdata-that-comes-with-a-lot-of-bugfixes/29358/37">Post #36</a>
	                </div>
	            </div>
              <div id="likers-container-218251" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="218251"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #36"></div>
  </section>
</div>
    <div class="postbit" id="218252" data-post-id="218252">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="LostKobrakai" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/LostKobrakai/120/3072_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  LostKobrakai
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="mathieuprog" data-post="37" data-topic="29358">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/mathieuprog/48/16860_2.png" class="avatar"> mathieuprog:</div>
<blockquote>
<p>But most importantly, a lot of work has been put into the project to increase the performance. It is now <em>very</em> fast, compared to the early versions and compared to the performance of the Tzdata lib.</p>
</blockquote>
</aside>
<p>Do you have some comparisons for that?</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="218252" data-batch-url="/posts/batch_likers">
                        2
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/tz-time-zone-support-for-elixir-alternative-to-tzdata-that-comes-with-a-lot-of-bugfixes/29358/38">Post #37</a>
	                </div>
	            </div>
              <div id="likers-container-218252" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="218252"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #37"></div>
  </section>
</div>
    <div class="postbit" id="218430" data-post-id="218430">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="mathieuprog" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/mathieuprog/120/16860_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  mathieuprog
                    <span class="op-star" title="Thread Starter">
                      <img alt="OP" class="op-star-icon" src="/assets/thread-icons/thread-icon-thread-starter-df91e872.png" />
                    </span>
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Adding benchmarks is part of the roadmap to v1.0. I’ll update this thread when those will be ready:)</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="218430" data-batch-url="/posts/batch_likers">
                        0
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/tz-time-zone-support-for-elixir-alternative-to-tzdata-that-comes-with-a-lot-of-bugfixes/29358/39">Post #38</a>
	                </div>
	            </div>
              <div id="likers-container-218430" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="218430"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #38"></div>
  </section>
</div>
    <div class="postbit" id="267171" data-post-id="267171">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="silvagustin" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/silvagustin/120/20412_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  silvagustin
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Hello there.</p>
<p>I’m using the <code>tz</code> dependency and I want to add the <code>tz_extra</code> dependency.</p>
<p>My doubts are:</p>
<ul>
<li>Do I have to add <code>{TzExtra.UpdatePeriodically, []}</code> as a child in my supervisor too?</li>
<li>Can I use the same custom HTTP client as in <code>tz</code> so I don’t have to add <code>castore</code> and <code>mint</code> dependencies?</li>
</ul>
<p>Cheers.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="267171" data-batch-url="/posts/batch_likers">
                        0
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/tz-time-zone-support-for-elixir-alternative-to-tzdata-that-comes-with-a-lot-of-bugfixes/29358/40">Post #39</a>
	                </div>
	            </div>
              <div id="likers-container-267171" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="267171"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #39"></div>
  </section>
</div>
    <div class="postbit" id="267192" data-post-id="267192">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="mathieuprog" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/mathieuprog/120/16860_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  mathieuprog
                    <span class="op-star" title="Thread Starter">
                      <img alt="OP" class="op-star-icon" src="/assets/thread-icons/thread-icon-thread-starter-df91e872.png" />
                    </span>
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>You would need to add <code>TzExtra.UpdatePeriodically</code> in your supervisor, but then you do not need to add <code>Tz.UpdatePeriodically</code>. This is mentioned in the docs:</p>
<blockquote>
<p><code>TzExtra.UpdatePeriodically</code> also triggers <code>tz</code> 's time zone recompilation; so you don’t need to add <code>Tz.UpdatePeriodically</code> if you added <code>TzExtra.UpdatePeriodically</code> in your supervisor.</p>
</blockquote>
<p>TzExtra would take the http client as defined in tz, so it would take your custom http client. <code>Tz.HTTP.get_http_client!()</code> is called in the <code>UpdatePeriodically</code> module. I should add that in the docs.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="267192" data-batch-url="/posts/batch_likers">
                        2
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/tz-time-zone-support-for-elixir-alternative-to-tzdata-that-comes-with-a-lot-of-bugfixes/29358/41">Post #40</a>
	                </div>
	            </div>
              <div id="likers-container-267192" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="267192"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #40"></div>
  </section>
</div>
    <div class="postbit" id="267257" data-post-id="267257">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="silvagustin" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/silvagustin/120/20412_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  silvagustin
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p><a class="mention" href="/u/mathieuprog" rel="nofollow">@mathieuprog</a> I want to run <code>Datetime.shift_zone/2</code> using “Pacific/Auckland” time zone. The thing is that in the current month (November) they increase their time by one our for daylight saving purposes:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">%{
  coordinates: "-3652+17446",
  country: %{code: "NZ", name: "New Zealand"},
  dst_offset: 46800,
  dst_zone_abbr: "NZDT",
  pretty_dst_offset: "+13:00",
  pretty_utc_offset: "+12:00",
  time_zone: "Pacific/Auckland",
  time_zone_links: [],
  utc_offset: 43200,
  zone_abbr: "NZST"
}
</code></pre>
<p>Should I always use the <code>dst_offset</code> in case any other country has DST too? Also, suppose we are in a month where the DST ended, the <code>dst_offset</code> for New Zealand will be the same as the <code>utc_offset</code>?</p>
<p>This is the function I use to convert a <code>NaiveDateTime</code> to a <code>DateTime</code> with a specific <code>time_zone</code>:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">def shift_time_based_on_timezone(%NaiveDateTime{} = naive, timezone) do
  datetime = DateTime.from_naive!(naive, timezone)
  DateTime.add(datetime, datetime.utc_offset, :second)
end
</code></pre>
<p>PS: thanks for your fast response in my other <code>reply</code>.</p>
<p><strong>UPDATE</strong></p>
<p>I’ve changed my function as follows and now I’m getting the right converted time:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">defp shift_time_based_on_timezone(%NaiveDateTime{} = naive, timezone) do
  datetime = DateTime.from_naive!(naive, timezone)
  offset = datetime.utc_offset + datetime.std_offset # Added this line
  DateTime.add(datetime, offset, :second)
end
</code></pre> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="267257" data-batch-url="/posts/batch_likers">
                        0
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/tz-time-zone-support-for-elixir-alternative-to-tzdata-that-comes-with-a-lot-of-bugfixes/29358/42">Post #41</a>
	                </div>
	            </div>
              <div id="likers-container-267257" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="267257"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #41"></div>
  </section>
</div>
</template></turbo-stream><turbo-stream action="replace" target="load-more-container"><template><div id="load-more-container" class="load-more-container">
    <a class="load-more-button" data-turbo-stream="true" href="/topics/29358/load_more?page=5">Load more posts (7 remaining)</a>
</div></template></turbo-stream>