How to use TimeZoneInfo with GroupDocs.Viewer in .NET

Hi,

I’ve found this article, describing how to use TimeZoneOffset property, to adjust timestamps in emails for viewing.

The article also mentions TimeZoneInfo as a way of correctly handling daylight saving time.
Unfortunately, the article does not mention any details.
Can you please tell me, how GroupDocs.Viewer can make use of the time zone information?
The HtmlViewOptions.EmailOptions only have TimeZoneOffset and DateTimeFormat.

Best regards,
Clemens

1 Like

@Clemens

Hi Clemens,

First of all, I suggest you to take a look at the public documentation, because it is the most accurate and reliable source, which is written by the developers of the GroupDocs.Viewer. In particular, here you can find explanation, source code example and a screenshot.

But let me explain it how I see this. maybe, every format of email letters has fields like “From”, “To”, “Subject”, and also a “Sent”. Both TimeZoneOffset and DateTimeFormat controls how the value of the “Sent” field should be displayed.

Regarding the DateTimeFormat property, I think, it is obvious - allows to specify the format of the datetime.
With TimeZoneOffset you can specify your own time offset, which will be appended to the datetime. For example, if you email letter has “Sent” = " Tue, 25 Apr 2017 11:28:00", it will be displayed as is. But if you specify the <options>.EmailOptions.TimeZoneOffset = new TimeSpan(-7, 0, 0), then in the output PDF/HTML/JPEG/PNG document you will see the “Sent” = “Tue, 25 Apr 2017 04:28:00 -0700”.

Hope I was able to clear this.

With best regards,
Denis Gvardionov

1 Like

@denisgvardionov
Hi Denis,

Thank you so much for the detailed reply.
You described quite well how to use TimeZoneOffset and DateTimeFormat, but I knew that already actually :sweat_smile:

What I would be interested, is the TimeZoneInfo that the article has mentioned.
The problem with the TimeZoneOffset, is that it’s not aware of daylight saving time.
Depending if the “sent” date is in summer-time or winter-time, the offset will be different.
So without knowing the “sent” date, I cannot provide the right offset.
If I can provide the TimeZoneInfo to GroupDocs class, then it could do this evaluation.
If there is no such option, despite the article mentioning it, then I’d need a way to get the sent date from the loaded email.

Best regards,
Clemens

1 Like

@Clemens

Hi Clemens,

Now I understand you clearly.

As I told earlier, you should rely on the public documentation as on the most precise and correct documentation of the GroupDocs.Viewer, because it is written and controlled by us, developers. Regarding the Tutorials — they are written by other staff members and the existence of such page was a surprise for me. Currently the GroupDocs.Viewer does not support the TimeZoneInfo in context of the email messages and never had such a support.

However, I understand your requirement and will implement an option to retrieve the original “Sent datetime” from the mail message, loaded to the Viewer instance via its constructor, through the Viewer.GetViewInfo() method — now for email messages it will return the instance of MailMessageViewInfo (which implements ViewInfo), and this class will have the requested property. Version 26.1 will have this new feature as well as some others (I plan to also add the “Subject” and “From” properties too).

With best regards,
Denis Gvardionov

1 Like

@denisgvardionov
Hi Denis,

Thank you so much adding that as a new feature! :star_struck:
Looking forward to the next version :slight_smile:

Best regards,
Clemens

1 Like