Zoned date/time conversions

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Zoned date/time conversions

Graeme Geldenhuys-6
Hi,

I need to do timezone enabled date/time conversions...

Use case 1)
We want the application server to always use UCT and the application
server might not be in the sime timezone as the client app. So we need
to convert local time to UCT, do some time based processing on the
server, then return data and convert all times back to the local time.

Use case 2)
Client's home address is in Spain. The application server is hosted in
London. The client is on holiday in Australia. They book a grocery
delivery while on holiday, and it must be delivered at 4pm the day
they return from their holiday. So 4pm will be local Spainish time.


Data will be transported to/from the application server using JSON
and REST API. So date/time info needs to be converted to/from string
format.

What classes or methods are available in FPC to convert local
date/time to UCT based time with offset and zone information?


Regards,
  Graeme
_______________________________________________
fpc-pascal maillist  -  [hidden email]
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Zoned date/time conversions

Michael Van Canneyt


On Sun, 24 May 2020, Graeme Geldenhuys wrote:

> Hi,
>
> I need to do timezone enabled date/time conversions...
>
> Use case 1)
> We want the application server to always use UCT and the application
> server might not be in the sime timezone as the client app. So we need
> to convert local time to UCT, do some time based processing on the
> server, then return data and convert all times back to the local time.
>
> Use case 2)
> Client's home address is in Spain. The application server is hosted in
> London. The client is on holiday in Australia. They book a grocery
> delivery while on holiday, and it must be delivered at 4pm the day
> they return from their holiday. So 4pm will be local Spainish time.
>
>
> Data will be transported to/from the application server using JSON
> and REST API. So date/time info needs to be converted to/from string
> format.
>
> What classes or methods are available in FPC to convert local
> date/time to UCT based time with offset and zone information?

In the RTL, there is none.
There are some methods to find out local time zone, but that's about it.

However, there is some third-party class which has complete date/time
handling:
https://wiki.freepascal.org/PascalTZ
sources on :
https://github.com/dezlov/PascalTZ

Michael.
_______________________________________________
fpc-pascal maillist  -  [hidden email]
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Zoned date/time conversions

Graeme Geldenhuys-6
On 24/05/2020 12:56 pm, Michael Van Canneyt wrote:
> However, there is some third-party class which has complete date/time
> handling:
> https://wiki.freepascal.org/PascalTZ


Thanks Michael, that looks like what I need. Good to see it has support
for the time zone database too.


Regards,
  Graeme
_______________________________________________
fpc-pascal maillist  -  [hidden email]
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal