[Gambas-user] New component gb.rss to generate and parse RSS documents

Benoît Minisini gambas at ...1...
Sun Apr 2 22:40:33 CEST 2017

Le 02/04/2017 à 22:34, Tobias Boege a écrit :
> On Sun, 02 Apr 2017, Benoît Minisini wrote:
>> Le 02/04/2017 à 18:07, Tobias Boege a écrit :
>>> Hello all,
>>> I wrote an RSS feed generator for one of my projects recently and could
>>> luckily complete also the parser before the new semester starts tomorrow.
>>> So you get a gb.rss component in the latest revision #8117.
>>> It should support all the things that are mentioned in the RSS 2.0
>>> specification here [1], but there are still some problems:
>>>   * The date conversion routines ignore timezones completely, because
>>>     I have no clue about working with timezones in Gambas.
>> As I don't know RSS, can you elaborate? What do you need to do exactly
>> with timezones?
> The items in an RSS feed (and the feed itself) contain publication dates
> such as
>   Sat, 07 Sep 2002 10:00:00 GMT
> At the moment, when I read this string into a Date and use it in a Gambas
> application, the timezone is ignored, i.e. it will be the 7th Sep 2002 at
> 10:00:00 *system-local timezone*, which is not correct. You can see this
> when you serialise the RSS object into an XML document again. It gives:
>   Sat, 07 Sep 2002 10:00:00 +0100
> because my system is in +0100 now.
> I don't know how this situation is best handled. The Gambas Date type is
> not big enough to carry timezone information, is it? Then I would have to
> convert the given time to the system timezone
>   10:00:00 GMT -> 09:00:00 +0100
> which results in the XML output
>   Sat, 07 Sep 2002 09:00:00 +0100
> later, which is not identical to the source but at least represents the same
> point in time. But I could image that being able to set the target timezone
> explicitly would be desirable, e.g. when your RSS feed item represents a
> story in a German newspaper, but your server runs in a US timezone.
> Regards,
> Tobi

Date in Gambas are storead as a number of days and microseconds from a 
specific origin, and are always considered as UTC.

They are converted to the timezone associated with the localisation when 
you use Str() or Format() or Print.

To convert a date ti a specific timezone, you have to convert the date 
part taken as UTC, and then you add (or substract I think, must be 
checked!) the time zone value (which are hours).

Maybe this is an utility function to implement in gb.util.web...

Benoît Minisini

More information about the User mailing list