<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">2018-06-07 16:00 GMT+02:00 Benoît Minisini <span dir="ltr"><<a href="mailto:g4mba5@gmail.com" target="_blank">g4mba5@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Le 07/06/2018 à 15:52, George a écrit :<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
This is what broke my code:<br>
Dim Dat1 As Date<br>
Dat1 = "6/1/2018"<br>
</blockquote>
<br>
The problem is here. The automatic conversion is done by CStr(), i.e. it assumes that "6/1/2018" is UTC...<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Message("Dat1: " & Dat1 & " Formatted: " & Format(Dat1, "mm/dd/yyyy"))<br>
</blockquote>
<br>
...but Format() prints the date in local timezone...<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Result: Dat1: 06/01/2018 Formatted: 05/31/2018<br>
</blockquote>
<br>
...And so you may have a difference.<br>
<br>
Each time you have a string converted to a date or the contrary, you must know which timezone Gambas assumes.<br>
<br>
To convert a string in local date, you have to use Val("6/1/2018"), or, faster, Date(2018,1,6).<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
I stand corrected on the DateDiff issue; my code was not using it because it's counting days based on a schedule of working/non-working days. Since I hadn't gotten past the 'Format' issue, I never dove into that part of the code to see why it was breaking, other than seeing that day calculations, which used to work, no longer did since the patch.<br>
<br>
</blockquote>
<br>
For working / non-working days, I have written my own function (based on French days-off), but I didn't put it in Gambas yet.<span class="HOEnZb"><font color="#888888"><br>
<br>
-- <br>
Benoît Minisini<br>
<br></font></span></blockquote><div><br></div><div>I believe that coercion should always be avoided.<br>You have passed a string to a date type:<br> Dim Dat1 As Date<br> Dat1 = "6/1/2018"<br>By writing Dat1 = CDate ("6/1/2018") the error would have been avoided.<br><br>Regards<br>Gianluigi<br></div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="HOEnZb"><font color="#888888">
----[ Gambas mailing-list is hosted by <a href="https://www.hostsharing.net" rel="noreferrer" target="_blank">https://www.hostsharing.net</a> ]----<br>
</font></span></blockquote></div><br></div></div>