diff --git a/Examples-and-Recipes.md b/Examples-and-Recipes.md index f18b6e9..7874512 100644 --- a/Examples-and-Recipes.md +++ b/Examples-and-Recipes.md @@ -2248,6 +2248,37 @@ tzdb_manager(std::atomic& run) } } ``` +The above assumes a build with `DAUTO_DOWNLOAD=0`. That is, the tz lib won't automatically download the IANA tzdb for you. If you want to build with `DAUTO_DOWNLOAD=1` (which is the default on macOS and Linux), the code above can be simplified a bit by changing: + +```c++ + auto rv = remote_version(); + if (rv != get_tzdb().version) + { + // download, install and load the new tzdb + if (remote_download(rv)) + { + if (remote_install(rv)) + { + reload_tzdb(); + // Schedule cleanup of the old tzdb for 10 days from now + clean_at = check_at + days{10}; + } + } + // if anything failed, we just try again tomorrow morning + } +``` +to +```c++ + auto rv = remote_version(); + if (rv != get_tzdb().version) + { + // download, install and load the new tzdb + reload_tzdb(); + // Schedule cleanup of the old tzdb for 10 days from now + clean_at = check_at + days{10}; + // if anything failed, we just try again tomorrow morning + } +``` It isn't the most friendly code to have to write. But on the other hand, it gives you complete discretion on your `tzdb` delete policy and doesn't penalize clients that have no need to update their `tzdb` database.