libcron icon indicating copy to clipboard operation
libcron copied to clipboard

added timezone support

Open BestITUserEUW opened this issue 1 year ago • 3 comments

added simple tests

updated README.md

BestITUserEUW avatar Feb 21 '24 21:02 BestITUserEUW

Linux test passed Ubuntu 22.04 gcc-11.4.0 Windows test passed Windows 10 MSVC 19.34.31937.0

Windows took quite long to setup with libcurl and openssl. Looks like date-tz from date on windows uses 7-Zip to unpack the received tar ball, so it's not really straightforward using it on Windows.

BestITUserEUW avatar Feb 21 '24 22:02 BestITUserEUW

I think we can stick to PC for now, no need to do something no one has asked for.

Sent from Outlook for Androidhttps://aka.ms/AAb9ysg


From: Philemon Benner @.> Sent: Thursday, February 22, 2024 9:48:07 PM To: PerMalmberg/libcron @.> Cc: Per Malmberg @.>; Comment @.> Subject: Re: [PerMalmberg/libcron] added timezone support (PR #34)

@BestITUserEUW commented on this pull request.


In README.mdhttps://github.com/PerMalmberg/libcron/pull/34#discussion_r1499916365:

+``` +Cron<TzClock> cron; +if(cron.get_clock().set_time_zone("Africa/Maputo"))

  • std::cout << "Successfully set timezone to: Africa/Maputo \n"; +else
  • std::cout << "Failed to set timezone to: Africa/Maputo \n"; +```

+libcron::TzClock behaves like libcron::UTCClock if no timezone is set. + +If you want to use TzClock you have to set -DLIBCRON_BUILD_TZ_CLOCK=ON when building libcron. TzClock is a fully optional feature +if you don't enable it, it won't be build at all. + +Using TzClock has the following side effects:

    1. Date requires linkage to libcurl
    1. First time TzClocks timezone lookup will occur it will download the most up to date timezone: "~/Downloads/tzdata" ("%homedrive%%homepath%\downloads\tzdata" on Windows).

I will have a look on Sunday if anything of the following will be possible. Setting database install path will be possible out of the box from date-tz but only at build time trough -DINSTALL=/some/path. I'm sure embedded is possible but would require a good amount of work, like different platform support (Arduino, ESP-IDF, Micro-python, Rust), either embedding db into flash at compile time or using Eeprom at runtime to store latest db, if you are targeting microcontrollers. I don't think I will have time doing all of this.

PerMalmberg avatar Feb 22 '24 22:02 PerMalmberg

Windows build is not working yet

BestITUserEUW avatar Feb 29 '24 02:02 BestITUserEUW

Closing this stale PR.

PerMalmberg avatar Aug 02 '24 16:08 PerMalmberg