<?xml version="1.0" encoding="utf-8"?>
<feed xml:lang="en" xmlns="http://www.w3.org/2005/Atom"><title>Recent posts to Leap Year error in CAA DTUtils.GetDayOfWeek function</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/4f408f553e/" rel="alternate"/><link href="https://forge.codesys.com/forge/talk/Engineering/thread/4f408f553e/feed.atom" rel="self"/><id>https://forge.codesys.com/forge/talk/Engineering/thread/4f408f553e/</id><updated>2020-03-02T15:11:29.330000Z</updated><subtitle>Recent posts to Leap Year error in CAA DTUtils.GetDayOfWeek function</subtitle><entry><title>Leap Year error in CAA DTUtils.GetDayOfWeek function</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/4f408f553e/?limit=25#d7a0" rel="alternate"/><published>2020-03-02T15:11:29.330000Z</published><updated>2020-03-02T15:11:29.330000Z</updated><author><name>tvm</name><uri>https://forge.codesys.com/u/tvm/</uri></author><id>https://forge.codesys.comc1116246c952247acad2ec7ec30c5df2083f9c14</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;For anyone who needs to replace it, here's a function that works&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="nt"&gt;FUNCTION&lt;/span&gt; &lt;span class="nt"&gt;DATE_TO_DAY&lt;/span&gt; &lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="nt"&gt;INT&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nt"&gt;0&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;6&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
&lt;span class="nt"&gt;VAR_INPUT&lt;/span&gt;
    &lt;span class="nt"&gt;DateIn&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;                 &lt;span class="nt"&gt;DATE&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="nt"&gt;END_VAR&lt;/span&gt;
&lt;span class="nt"&gt;VAR&lt;/span&gt; &lt;span class="nt"&gt;CONSTANT&lt;/span&gt;
    &lt;span class="nt"&gt;SECONDS_PER_DAY&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;        &lt;span class="nt"&gt;DINT&lt;/span&gt;&lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="nt"&gt;24&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="nt"&gt;60&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="nt"&gt;60&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;    &lt;span class="o"&gt;//&lt;/span&gt;&lt;span class="nt"&gt;number&lt;/span&gt; &lt;span class="nt"&gt;of&lt;/span&gt; &lt;span class="nt"&gt;seconds&lt;/span&gt; &lt;span class="nt"&gt;in&lt;/span&gt; &lt;span class="nt"&gt;a&lt;/span&gt; &lt;span class="nt"&gt;day&lt;/span&gt;
    &lt;span class="nt"&gt;EPOCH_STARTDAY&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;         &lt;span class="nt"&gt;DINT&lt;/span&gt;&lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="nt"&gt;4&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;           &lt;span class="o"&gt;//&lt;/span&gt;&lt;span class="nt"&gt;DATE&lt;/span&gt; &lt;span class="nt"&gt;variable&lt;/span&gt; &lt;span class="nt"&gt;is&lt;/span&gt; &lt;span class="nt"&gt;stored&lt;/span&gt; &lt;span class="nt"&gt;as&lt;/span&gt; &lt;span class="nt"&gt;seconds&lt;/span&gt; &lt;span class="nt"&gt;since&lt;/span&gt; &lt;span class="nt"&gt;Jan&lt;/span&gt; &lt;span class="nt"&gt;1&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nt"&gt;1970&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nt"&gt;which&lt;/span&gt; &lt;span class="nt"&gt;was&lt;/span&gt; &lt;span class="nt"&gt;a&lt;/span&gt; &lt;span class="nt"&gt;Thursday&lt;/span&gt; 
&lt;span class="nt"&gt;END_VAR&lt;/span&gt;

&lt;span class="o"&gt;(*====================================================================================&lt;/span&gt;
&lt;span class="nt"&gt;DATE_TO_DAY&lt;/span&gt;
&lt;span class="nt"&gt;Calculate&lt;/span&gt; &lt;span class="nt"&gt;day&lt;/span&gt; &lt;span class="nt"&gt;of&lt;/span&gt; &lt;span class="nt"&gt;week&lt;/span&gt; &lt;span class="nt"&gt;from&lt;/span&gt; &lt;span class="nt"&gt;date&lt;/span&gt; 
&lt;span class="nt"&gt;Sunday&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nt"&gt;0&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nt"&gt;Saturday&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nt"&gt;6&lt;/span&gt;
&lt;span class="o"&gt;======================================================================================*)&lt;/span&gt;

&lt;span class="nt"&gt;DATE_TO_DAY&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="nt"&gt;DINT_TO_INT&lt;/span&gt;&lt;span class="o"&gt;(((&lt;/span&gt;&lt;span class="nt"&gt;DATE_TO_DINT&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nt"&gt;DateIn&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="nt"&gt;SECONDS_PER_DAY&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nt"&gt;EPOCH_STARTDAY&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="nt"&gt;MOD&lt;/span&gt; &lt;span class="nt"&gt;7&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;

&lt;/div&gt;</summary></entry><entry><title>Leap Year error in CAA DTUtils.GetDayOfWeek function</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/4f408f553e/?limit=25#493d" rel="alternate"/><published>2020-03-02T13:11:50.743000Z</published><updated>2020-03-02T13:11:50.743000Z</updated><author><name>tvm</name><uri>https://forge.codesys.com/u/tvm/</uri></author><id>https://forge.codesys.com79ae6b4730872ffc387af7e774c01e19a6777ecb</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;@ThK you seem to have access to this developer database.  Can you explain why this kind of information is not publicly available?  I used the CAA library because I made the assumption that a date and time utility would have been tested against dates and times, leap years being one of the most obvious tests.  Knowing that it doesn't work, I don't see the use of it--I might as well write my own function.&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Leap Year error in CAA DTUtils.GetDayOfWeek function</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/4f408f553e/?limit=25#4962" rel="alternate"/><published>2020-03-02T08:16:21.990000Z</published><updated>2020-03-02T08:16:21.990000Z</updated><author><name>ThK</name><uri>https://forge.codesys.com/u/thk/</uri></author><id>https://forge.codesys.comf7c1148842ab2af8440026cb0ad2f52361d17063</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Hi,&lt;br/&gt;
Yes, it is an known bug. &lt;br/&gt;
The entry in our developer database is:&lt;br/&gt;
CDS-47688: Library: CAA DTUtility GetDayOfWeek returns wrong weekday for leap day &lt;/p&gt;
&lt;p&gt;Regards Thomas&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Leap Year error in CAA DTUtils.GetDayOfWeek function</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/4f408f553e/?limit=25#8eb4" rel="alternate"/><published>2020-02-29T16:45:13.608000Z</published><updated>2020-02-29T16:45:13.608000Z</updated><author><name>tvm</name><uri>https://forge.codesys.com/u/tvm/</uri></author><id>https://forge.codesys.com777c0e6879d23067a6fc15a7351fbf498ad7a151</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;I believe I have found an error in the CAA DTUtils GetDayOfWeek function.  According to the documentation, it should return 0-6 for days of the week, Sunday-Saturday.  Today, I'm getting a return value of 7, and an error of DTU_ERROR_UNKNOWN.&lt;br/&gt;
I have library  version 3.5.12.0.  Anyone else have this problem?&lt;br/&gt;
&lt;img src="./attachment/attachment.png" width="50%"/&gt;&lt;/p&gt;&lt;/div&gt;</summary></entry></feed>