How to update NodaTime.xml for NodaTime .NET?

I am new to NodaTime and doing samples with it. NodaTime is great and while reading the documentation for NodaTime implementation, I noticed that there was a file(contains timezone data) downloaded along with the NodaTime.dll library.

I added NodaTime library to my project using "Nuget Packages" and while installing NodaTime package to my project, I saw NodaTime.dll and NodaTime.xml in the bin folder.

Info about the NodaTime library installed in my project:

   NodaTime.dll version 1.3.0
   NodaTime.xml (came along with the NodaTime.dll)

Questions:

  1. Do I need to update the NodaTime.xml manually?

  2. In this Link(Update tz database), I read some information for updating the tz database but it seems confusing for me. How to download and update the NodaTime.xml file?

  3. provide a short explanation for updating the NodaTime.xml file and some related paths?

  4. Is there any link which may be helpful for me to understand about the update in NodaTime?

Also provide your valuable suggestions regarding issues and solutions for it, some valuable tips for using it.

The major role of NodaTime in my project is to find whether the given timezone has DST or not and to convert the datetime according to DST.

Jon Skeet
people
quotationmark

You're getting confused between XML documentation files and the time zone (nzd) files. You don't need to update XML files at all.

To get the most recent version of the TZDB data, you should:

  • Fetch (and store) the contents of http://nodatime.org/tzdb/latest.txt. That's just a URL.
  • If that isn't the same as the value you last fetched, you should fetch the contents of the URL, e.g. http://nodatime.org/tzdb/tzdb2014e.nzd
  • Open a stream to the downloaded file (which will depend on your platform, but something like FileStream) and use TzdbDateTimeZoneSource.FromStream to load a TzdbDateTimeZoneSource from it
  • Wrap the TzdbDateTimeZoneSource in a DateTimeZoneCache (just with the constructor) to get an IDateTimeZoneProvider, which is what you should be using in your main application code

If your application is periodically restarted, you could do this on startup, potentially - it's slightly harder if it's something like a web server which needs to be constantly running, just because you'll need a way of telling your application to use the new IDateTimeZoneProvider.

This is basically what the documentation says already, of course - you've said that you find it confusing, but not in what way... if this answer is still unclear, please elaborate and I'll see what I can do.

people

See more on this question at Stackoverflow