<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>About leap years in the nrf5-calendar-example.</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/86872/about-leap-years-in-the-nrf5-calendar-example</link><description>Hi all, 
 
 I want to implement a calendar that can be used for many years with nRF52840. 
 Will leap years be corrected in the nrf5-calendar-example? I looked at the code a bit, but couldn&amp;#39;t know if the sample-code corresponded to a leap year. 
 https</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 13 Apr 2022 13:11:19 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/86872/about-leap-years-in-the-nrf5-calendar-example" /><item><title>RE: About leap years in the nrf5-calendar-example.</title><link>https://devzone.nordicsemi.com/thread/363203?ContentTypeID=1</link><pubDate>Wed, 13 Apr 2022 13:11:19 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e227ec64-27a2-46a4-b0f3-fe8ecb2aee93</guid><dc:creator>AHaug</dc:creator><description>&lt;p&gt;Hi Yukio,&lt;/p&gt;
[quote user="yukio oyama"]&amp;quot;The localtime() in the C standard library supports leap years.&amp;nbsp;the&amp;nbsp;&lt;span&gt;nrf5-calendar-example&lt;/span&gt; uses localtime() so leap years are supported.&amp;quot;[/quote]
&lt;p&gt;I do not know if localtime() supports leap years, so I would recommend you verify this yourself by looking up the documentation for the functions in time.h. &lt;strong&gt;&lt;span style="text-decoration:underline;"&gt;If&lt;/span&gt;&lt;/strong&gt; localtime() supports leap years, there is a good chance that the nrf_calendar sample supports it as well.&lt;/p&gt;
[quote user="yukio oyama"]&amp;quot;There is no guarantee in the sample code, so&amp;nbsp;I have to try any&amp;nbsp;patterns of dates and times myself to see it. &amp;quot;[/quote]
&lt;p&gt;Yes, that would be the safest!&lt;/p&gt;
[quote user="yukio oyama"]And, where is the RTC counter written as an input to the time.h library?[/quote]
&lt;p&gt;How the&amp;nbsp;RT Counter&amp;nbsp;is defined and used together with time.h is written in the files nrf_calendar.c and &lt;span&gt;nrf_&lt;/span&gt;calendar.h!&lt;/p&gt;
[quote user="yukio oyama"]According to your advice, I think I have no choice but to check it in real action.[/quote]
&lt;p&gt;I can ask the employee who wrote this sample years ago if they&amp;nbsp;know/remember when they return to the office, although this might take longer time than to examine the patterns yourself.&lt;/p&gt;
&lt;p&gt;I hope this is any help!&lt;br /&gt;&lt;br /&gt;Kind regards,&lt;br /&gt;Andreas&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: About leap years in the nrf5-calendar-example.</title><link>https://devzone.nordicsemi.com/thread/363094?ContentTypeID=1</link><pubDate>Wed, 13 Apr 2022 04:55:32 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e1814ca5-d036-410e-b38a-2fe8d5bff55f</guid><dc:creator>OYAMA YUKIO</dc:creator><description>&lt;p&gt;Hi Andreas-san,&lt;/p&gt;
&lt;p&gt;Thank you for your advice.&lt;/p&gt;
&lt;p&gt;Do you mean the following?&lt;/p&gt;
&lt;p&gt;&amp;quot;The localtime() in the C standard library supports leap years.&amp;nbsp;the&amp;nbsp;&lt;span&gt;nrf5-calendar-example&lt;/span&gt; uses localtime() so leap years are supported.&amp;quot;&lt;/p&gt;
&lt;p&gt;&amp;quot;There is no guarantee in the sample code, so&amp;nbsp;I have to try any&amp;nbsp;patterns of dates and times myself to see it. &amp;quot;&lt;/p&gt;
&lt;p&gt;And, where is the RTC counter written as an input to the time.h library?&lt;/p&gt;
&lt;p&gt;According to your advice, I think I have no choice but to check it in real action.&lt;/p&gt;
&lt;p&gt;Thank you.&lt;/p&gt;
&lt;p&gt;BR&lt;/p&gt;
&lt;p&gt;Yukio Oyama&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: About leap years in the nrf5-calendar-example.</title><link>https://devzone.nordicsemi.com/thread/363024?ContentTypeID=1</link><pubDate>Tue, 12 Apr 2022 12:55:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d80e9a0e-8385-44e0-bdb9-73fcaa2eed47</guid><dc:creator>AHaug</dc:creator><description>&lt;p&gt;Hi Yukio,&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
[quote user=""]Will leap years be corrected in the nrf5-calendar-example?[/quote]
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;The sample is based on time.h and its function localtime(), so it might be the case.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
[quote user=""]If I set the data for a leap year and it works correctly, can I say that it supports all leap years?[/quote]
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I would say that is a sane assumption to make. However it might be different for&amp;nbsp;&lt;a href="https://en.wikipedia.org/wiki/Leap_second"&gt;leap seconds&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;To verify both of these you could build and test the sample and cross check with&amp;nbsp;&lt;a href="https://www.geeksforgeeks.org/time-h-localtime-function-in-c-with-examples/"&gt;a simple open source sample for localtime()&lt;/a&gt;&amp;nbsp;to validate. If you set the date and time to a point in time close to when it should change to something&amp;nbsp;(23:59, the 28th of february 2022), it should go to (00:00, the 1st of march 2022) after a minute. If it goes to Feb. 29th on a non-leap year, it is also could be that this sample is based on a calendar model that assumes that every month has 31 days. In that case you would also need to implement something that checks if the month has 30, 31 or 28 days, and if it is a leap year.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Please note that this sample is only a demo-sample and&amp;nbsp;it is hence provided as-is, without any warranty, and redistribution and use of source with or without modifications must meet the conditions written in the project code.&lt;/p&gt;
[quote user=""]Or is there a library to correct leap years?[/quote]
&lt;p&gt;Unless time.h handles this, there might be some open source code online that handles this. Currently we have no other samples or libraries that explicitly does this.&lt;/p&gt;
[quote user=""]I think the RTC of nrf52840 is a counter and the calendar (and date and time) is implemented in the library.&amp;nbsp;Is my understanding correct?[/quote]
&lt;p&gt;From our infocenter pages concerning Real-time counter (&lt;a href="https://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.nrf52832.ps.v1.1%2Frtc.html"&gt;RTC&lt;/a&gt;) we have that the&amp;nbsp;&lt;em&gt;&amp;quot;&lt;span&gt;module provides a generic, low power timer on the low-frequency clock source (LFCLK).&amp;quot;.&lt;/span&gt;&lt;/em&gt;&amp;nbsp;The date and time part of this comes from using this timer as input to the time.h libraries.&lt;/p&gt;
&lt;p&gt;I hope this clarifies things for you!&lt;br /&gt;&lt;br /&gt;Kind regards,&lt;br /&gt;Andreas&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>