[Gambas-devel] Gambas 3.10 - gb.web.feed

Tobias Boege taboege at ...176...
Fri Jul 28 17:20:18 CEST 2017


On Fri, 28 Jul 2017, Benoît Minisini via Gambas-devel wrote:
> > Yes, the timezone is mandatory there.
> > 
> > So, how about this: I make a class called RssDate where I store a UTC-based
> > timestamp (aka Date) and a timezone string. As I mentioned before, I think
> > the timezone string is necessary to let the user specify what timezone the
> > date will be printed in.
> > 
> > When an RFC822 date is read, I want to have its timezone string and the
> > timestamp of that date converted to UTC. When an RFC822 date is written,
> > I take the UTC timestamp and convert it to the string representation in
> > the timezone that the user wants to print the date in.
> > 
> > If that sounds reasonable, I can get to work now.
> > 
> > Regards,
> > Tobi
> > 
> 
> Why do you need the timezone part of the RFC822 date as a string? Why not
> just using Gambas Date and the Date.ToRFC822() / Date.FromRFC822()
> functions?
> 

When I read an RSS document into Rss objects, I want to retain the timezone
strings used in the original document. If I don't know the timezone string,
I would have to reset all timezones to UTC. The dates will be correct but
the timezone in the string representation of the date will have changed
(and the timezone may carry a meaning). It would be nice just to be able
to replicate a document that I have just read into gb.web.feed, too.

The attached script demonstrates two other problems:

  Print Date.ToRFC822(Date.FromRFC822("28 Jul 2017 08:00:00 GMT"), "GMT")
  >>Fri, 28 Jul 2017 4:0:0 GMT

First of all, the time components are not Format$(..., "00")'d, so they
print single digits where the RFC requires 2 digits. And second, shouldn't
reading a GMT date and putting it into GMT again result in the same string
that we started with? The 4 hour different is likely because I'm in +0200.

Regards,
Tobi

-- 
"There's an old saying: Don't change anything... ever!" -- Mr. Monk
-------------- next part --------------
#!/usr/bin/gbs3

Use "gb.util"

Public Sub Main()
  Print Date.ToRFC822(Date.FromRFC822("28 Jul 2017 08:00:00 GMT"), "GMT")
End


More information about the Devel mailing list