[Gambas-user] gb.web.feed not stable yet?

T Lee Davidson t.lee.davidson at gmail.com
Sat Jan 5 02:39:40 CET 2019


On 1/4/19 7:16 PM, T Lee Davidson wrote:
[snip]
> 
> * However, there does seem to be an issue with FromRFC822():
> 
> [Code]
> Public Sub Main()
> 
> Dim sDate As String = "Sun, 21 Apr 2019 05:00:00 GMT"
> Dim dDate As Date
> 
> dDate = Date.FromRFC822(sDate)
> Print CFloat(dDate)
> Print Frac(dDate) * 24
> Print Date.ToRFC822(dDate)
> Print Date.ToRFC822(dDate, "EST")
> Print Date.ToRFC822(dDate, "+0200")
> ' Get timezone From RFC8222 Date string
> Print Split(sDate, " ").Last
> 
> End
> [/Code]
> 
> [Result]
> 2490699.20833333
> 5.00000000372529
> Sun, 21 Apr 2019 05:00:00 GMT
> Sun, 21 Apr 2019 00:00:00 EST
> Sun, 21 Apr 2019 07:00:00 +0200
> GMT
> [/Result : Correct]
> 
> With `Dim sDate As String = "Sun, 21 Apr 2019 00:00:00 EST"`
> [Result]
> 2490698.79166667
> 18.9999999962747
> Sat, 20 Apr 2019 19:00:00 GMT
> Sat, 20 Apr 2019 14:00:00 EST
> Sat, 20 Apr 2019 21:00:00 +0200
> EST
> [/Result : Incorrect]
> 
> Perhaps my understanding is quite faulty.
> 

The following in FromRFC822() seems to work.

[Code]
  dDate -= (System.TimeZone / 86400 + GetRFC822Zone(aDate[6]))
  ' dDate += GetRFC822Zone(aDate[6])

  Return dDate
[/Code]

I may, though, have the order of operands and the operator reversed.

Note: As far as I can tell System.TimeZone / 86400 is roughly equivalent to Frac(Date(Now).


More information about the User mailing list