ExcelMapper icon indicating copy to clipboard operation
ExcelMapper copied to clipboard

Return a converted date from UTC to local

Open emkoos opened this issue 3 years ago • 3 comments

Hi, I have UTC date in the database. Is there any possibility to shift the responsibility of changing the time to local time in the exported file? I cannot get the user's time zone in the backend application

emkoos avatar Aug 31 '22 13:08 emkoos

Can you elaborate a little? What is the DateTimeKind of the DateTime values you're exporting and what kind of value do you expect in the exported Excel file?

mganss avatar Aug 31 '22 14:08 mganss

I export DateTime objects with Kind=Unspecified or Kind=UTC (I would prefer the second one). In the exported file, I would like the client to get the dates in the local time zone.

For example, with an offset of + 2H, I have the date 2022-08-31 00: 00: 00.000Z in the system and I want the date 2022-08-31 02:00:00 in the exported file.

Similarly, when importing -> the client sets the date in the local time zone and I want to receive it in UTC but the ToUniversalTime() method will help here.

emkoos avatar Sep 01 '22 05:09 emkoos

I think before exporting you need to map the DateTime values to local time using ToLocalTime().

mganss avatar Sep 01 '22 17:09 mganss