[Gambas-user] Format function changes date value
George
gambas at geodosch.com
Thu Jun 7 15:52:06 CEST 2018
This is what broke my code:
Dim Dat1 As Date
Dat1 = "6/1/2018"
Message("Dat1: " & Dat1 & " Formatted: " & Format(Dat1, "mm/dd/yyyy"))
Result: Dat1: 06/01/2018 Formatted: 05/31/2018
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.
On Thu, Jun 7, 2018 at 8:42 AM, Benoît Minisini <g4mba5 at gmail.com> wrote:
> Le 07/06/2018 à 11:55, George a écrit :
>
>> It's not a lack of understanding on my part. I have developed software
>> that must work across different time zones, and it certainly adds a layer
>> of complication to things, since time data must be dealt with based on
>> location, and display of times must take into account the user's location
>> (showing everything as GMT is the lazy way out, as it puts the burden of
>> time conversion on the user.)
>>
>> However, in this particular case I'm working with data that's in a single
>> location, and only deals with days, not times. That should be easy, since
>> it shouldn't need to deal with time zones. And yet, due to the way date
>> functions work, what should be a simple calculation, such as how many days
>> are between 1-Jun-2018 and 3-Jun-2018, needs to know the GMT offset of the
>> machine it's running on, and fudge the date into a date/time value in order
>> to get the correct result. (Just changing CDate() to Date(), as previously
>> suggested, did not work for me.) Yes, that can be done, but because of
>> what that would have entailed, in this case I decided that porting the app
>> to a different language was the better option for me.
>>
>
> You get the difference between two dates with DateDiff(). Where did you
> see that you had to deal with timezones?
>
>
>> IMHO all date functions should work internally as based on GMT or local
>> time, not a mix of both.
>>
>
> All date & times are internally stored in UTC.
>
> But all date & times functions that deal with date & time string printed
> representation (Str & Val & Format) have to supposed a local date, because
> none of them have an optional argument that would tell the timezone.
>
> Date & times functions using a non-printed string representation (CStr &
> CDate) assume an UTC timezone.
>
>
> --
> Benoît Minisini
>
> ----[ Gambas mailing-list is hosted by https://www.hostsharing.net ]----
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.gambas-basic.org/pipermail/user/attachments/20180607/54f2542d/attachment.html>
More information about the User
mailing list