Where to convert date to UTC?

I was wondering what area it makes sense to convert dates to UTC and vice versa. We save the dates in UTC and convert users to the local time zone. Right now, I think that embedding in the repository layer makes the most sense, because you do not need to remember its conversion every time you create service level methods that require it. My teammate suggests putting him at the service level because this is a business rule ...

Where would you put this conversion function? Service level or repository level? This may include looping through a list of objects and transforming on each of them.

+4
source share
1 answer

Where would you put this conversion function? Service level or repository level?

None of these layers. I would put it in a view model. If a presentation needs to show dates in the local time zone, and your dates are stored in UTC in the model, then the presentation model is an ideal place to format the data displayed on the screen.

+8
source

Source: https://habr.com/ru/post/1338660/


All Articles