<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Error with QDateEdit and current time]]></title><description><![CDATA[<p dir="auto">I have the following example code in c++</p>
<pre><code>QDate fecha = QDate::currentDate();
QDateEdit *entrada = new QDateEdit(fecha);
Registro::Aviso(fecha.toString().toStdString());
Registro::Aviso(entrada-&gt;date().toString().toStdString());

</code></pre>
<p dir="auto">It worked perfectly until September 11, 2022 that shows the date of September 14, 1752, today it works fine again, I am in the chile/continental time zone, on September 10 the time was changed from 11:59 p.m. 01:00</p>
<p dir="auto">Terminal output (September 10, 2022)</p>
<pre><code>[2022-09-10 18:14:14][AVISO] sáb sep. 10 2022
[2022-09-10 18:14:14][AVISO] sáb sep. 10 2022
</code></pre>
<p dir="auto">Terminal output (September 11, 2022)</p>
<pre><code>[2022-09-11 18:00:10][AVISO] dom sep. 11 2022
[2022-09-11 18:00:10][AVISO] jue sep. 14 1752
</code></pre>
<p dir="auto">Terminal output (September 12, 2022)</p>
<pre><code>[2022-09-12 18:14:45][AVISO] lun sep. 12 2022
[2022-09-12 18:14:45][AVISO] lun sep. 12 2022
</code></pre>
]]></description><link>https://forum.qt.io/topic/139264/error-with-qdateedit-and-current-time</link><generator>RSS for Node</generator><lastBuildDate>Thu, 05 Nov 2026 03:16:24 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/139264.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 12 Sep 2022 21:16:55 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Error with QDateEdit and current time on Tue, 13 Sep 2022 07:35:19 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/carque">@<bdi>Carque</bdi></a> said in <a href="/post/728441">Error with QDateEdit and current time</a>:</p>
<blockquote>
<p dir="auto">I am in the chile/continental time zone, on September 10 the time was changed from 11:59 p.m. 01:00</p>
</blockquote>
<p dir="auto">That means that on Sep 10/11 a <em>local</em> time between 00:00 and 01:00 "does not exist", there was no 00:00 or 00:30, agreed?  I imagine in some shape or form you passed such an "illegal" datetime to a Qt datetime routine, and got back "illegal" from it.  (See <a href="https://doc.qt.io/qt-6/qdatetime.html#isValid" target="_blank" rel="noopener noreferrer nofollow ugc">bool QDateTime::isValid() const</a> and the notes there.)  That probably returned something like a datetime of <code>0</code>, and I would imagine that maps to the year 1752, hence your output.</p>
<p dir="auto">I am guessing that <code>QDate</code> treats the <em>time</em> element as <code>00:00</code>.  You will have to do something about this to get a correct conversion.</p>
]]></description><link>https://forum.qt.io/post/728485</link><guid isPermaLink="true">https://forum.qt.io/post/728485</guid><dc:creator><![CDATA[JonB]]></dc:creator><pubDate>Tue, 13 Sep 2022 07:35:19 GMT</pubDate></item><item><title><![CDATA[Reply to Error with QDateEdit and current time on Tue, 13 Sep 2022 13:57:49 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/carque">@<bdi>Carque</bdi></a> said in <a href="/post/728577">Error with QDateEdit and current time</a>:</p>
<blockquote>
<p dir="auto">I think the easiest solution is to tell it that this all in utc</p>
</blockquote>
<p dir="auto">Indeed so!  If you can afford to always work in UTC --- and if you're only interested in dates without times that seems reasonable anyway --- you avoid those pesky timezone conversions which can mess up the date.</p>
]]></description><link>https://forum.qt.io/post/728579</link><guid isPermaLink="true">https://forum.qt.io/post/728579</guid><dc:creator><![CDATA[JonB]]></dc:creator><pubDate>Tue, 13 Sep 2022 13:57:49 GMT</pubDate></item><item><title><![CDATA[Reply to Error with QDateEdit and current time on Tue, 13 Sep 2022 14:03:20 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/jonb">@<bdi>JonB</bdi></a> I know but QDateEdit insists on passing me a date from utc to local adding 00:00:00 as the time and it changes me from 2022-09-11 to 2022-09-10, I think the easiest solution is to tell it that this all in utc</p>
<pre><code>m_fecha = new QDateEdit(this);
m_fecha-&gt;setTimeSpec(Qt::UTC);
m_fecha-&gt;setDate(QDate::currentDate());
</code></pre>
]]></description><link>https://forum.qt.io/post/728577</link><guid isPermaLink="true">https://forum.qt.io/post/728577</guid><dc:creator><![CDATA[Carque]]></dc:creator><pubDate>Tue, 13 Sep 2022 14:03:20 GMT</pubDate></item><item><title><![CDATA[Reply to Error with QDateEdit and current time on Tue, 13 Sep 2022 13:45:35 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/carque">@<bdi>Carque</bdi></a><br />
Sorry, I don't know what you mean.  You can't have a "local" date in, or to convert to, UTC without involving the time, because UTC/timezones involve times.</p>
]]></description><link>https://forum.qt.io/post/728575</link><guid isPermaLink="true">https://forum.qt.io/post/728575</guid><dc:creator><![CDATA[JonB]]></dc:creator><pubDate>Tue, 13 Sep 2022 13:45:35 GMT</pubDate></item><item><title><![CDATA[Reply to Error with QDateEdit and current time on Tue, 13 Sep 2022 13:39:36 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/jonb">@<bdi>JonB</bdi></a> How can I save a local date as utc without saving the time? I think I can't because it would end up confusing days. but the invoice do not have hour and I can not invent one</p>
]]></description><link>https://forum.qt.io/post/728574</link><guid isPermaLink="true">https://forum.qt.io/post/728574</guid><dc:creator><![CDATA[Carque]]></dc:creator><pubDate>Tue, 13 Sep 2022 13:39:36 GMT</pubDate></item><item><title><![CDATA[Reply to Error with QDateEdit and current time on Tue, 13 Sep 2022 07:35:19 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/carque">@<bdi>Carque</bdi></a> said in <a href="/post/728441">Error with QDateEdit and current time</a>:</p>
<blockquote>
<p dir="auto">I am in the chile/continental time zone, on September 10 the time was changed from 11:59 p.m. 01:00</p>
</blockquote>
<p dir="auto">That means that on Sep 10/11 a <em>local</em> time between 00:00 and 01:00 "does not exist", there was no 00:00 or 00:30, agreed?  I imagine in some shape or form you passed such an "illegal" datetime to a Qt datetime routine, and got back "illegal" from it.  (See <a href="https://doc.qt.io/qt-6/qdatetime.html#isValid" target="_blank" rel="noopener noreferrer nofollow ugc">bool QDateTime::isValid() const</a> and the notes there.)  That probably returned something like a datetime of <code>0</code>, and I would imagine that maps to the year 1752, hence your output.</p>
<p dir="auto">I am guessing that <code>QDate</code> treats the <em>time</em> element as <code>00:00</code>.  You will have to do something about this to get a correct conversion.</p>
]]></description><link>https://forum.qt.io/post/728485</link><guid isPermaLink="true">https://forum.qt.io/post/728485</guid><dc:creator><![CDATA[JonB]]></dc:creator><pubDate>Tue, 13 Sep 2022 07:35:19 GMT</pubDate></item><item><title><![CDATA[Reply to Error with QDateEdit and current time on Tue, 13 Sep 2022 13:28:42 GMT]]></title><description><![CDATA[<p dir="auto">I found an approximation of solution, don't pass the date through the constructor and use the setDate method instead.<br />
because? I dont know</p>
<pre><code>QDate fecha = QDate::currentDate();
QDateEdit *entrada = new QDateEdit();
entrada-&gt;setDate(fecha);
</code></pre>
<p dir="auto">The other problem with this was</p>
<pre><code>QDate local_date = QDate::fromString("2022-09-11", "yyyy-MM-dd");
</code></pre>
<p dir="auto">this returns year 0</p>
<p dir="auto">instead I had to use</p>
<pre><code>QDate local_date = QDate::fromString("2022-09-11T00:00:00", Qt::ISODate);
</code></pre>
<p dir="auto">because as JonB says it is not a valid time, but I am not interested in the time, I am only interested in the date, I am going to have to read the local date and save it as a utc date?.</p>
]]></description><link>https://forum.qt.io/post/728446</link><guid isPermaLink="true">https://forum.qt.io/post/728446</guid><dc:creator><![CDATA[Carque]]></dc:creator><pubDate>Tue, 13 Sep 2022 13:28:42 GMT</pubDate></item></channel></rss>