0

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.

RajeshKannan
  • 894
  • 2
  • 16
  • 32
  • 1
    NodaTime.xml is just the API documentation. Visual Studio uses it to show you Intellisense. It doesn't contain time zone data. – Mike Zboray Jul 23 '14 at 07:56
  • 1
    No, it contains no data. It contains IntelliSense hints, the kind you see back in the editor. Just look at the content of the file to recognize it. Do not update it, do not deploy it to your user's machine. – Hans Passant Jul 23 '14 at 07:58
  • @mikez and Hans Passant Thank you for your reply and information. Could you please provide information for integrating timezone database with NodaTime.NET – RajeshKannan Jul 23 '14 at 09:23
  • 1
    @RajeshKannan - Please consider using the [Noda Time Google Group](https://groups.google.com/group/noda-time) for follow up and general discussion. Stack Overflow is a great place for *specific* questions, but not for broad discussion. Thanks. – Matt Johnson-Pint Jul 27 '14 at 18:11

1 Answers1

3

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.

Matt Johnson-Pint
  • 230,703
  • 74
  • 448
  • 575
Jon Skeet
  • 1,421,763
  • 867
  • 9,128
  • 9,194
  • Thanks for your reply. before an hour I read the documentation and I understood it. – RajeshKannan Jul 23 '14 at 19:36
  • I would like to know the major difference between NodaTime and Microsoft .NET's inbuilt DateTime functionality? We were using Windows Server 2012 for hosting our website and most probably the server sync with the NTP and also I think, the DST details may be updated due to NTP sync. So, can Microsoft .NET's inbuilt DateTime can do the same as NodaTime? I'm not too much clear with NTP and could you please provide your suggestion. – RajeshKannan Jul 24 '14 at 07:49
  • @RajeshKannan: NTP is entirely different - that's about updating the *clock*, not updating the set of time zones. Windows updates its time zone database using Windows Update, and often it takes a very long time to update compared with TZDB... and it's a system-wide thing, whereas with Noda Time you can choose exactly which version you wish to use (although it is a little bit of work to keep up to date automatically, as you've seen). – Jon Skeet Jul 24 '14 at 08:33