1

I'm developing a Xamarin.Forms project and utilizing Akavache as a caching solution. In my code, I have set the localBlobCache instance to BlobCache.LocalMachine to ensure it uses the time zone of my local environment.

However, I have observed that despite this configuration, Akavache ignores the local time zone setting. When I save a date and retrieve it later, Akavache converts the stored date to UTC. This conversion to UTC is not desired in my scenario, and I would like to maintain the original time zone information.

As a workaround, I have implemented a solution where, upon retrieving the cached data, I iterate through the collection and convert the dates from UTC to my local time zone. However, this approach becomes inefficient due to the large number of elements (over a thousand) in the collection.

Is there a more efficient solution to prevent this UTC conversion and preserve the original time zone when using Akavache in Xamarin.Forms?

I have researched and reviewed the Akavache documentation, but I couldn't find a direct solution for this issue. Any guidance or suggestions on how to address this problem in a more efficient manner would be greatly appreciated.

SarPa
  • 35
  • 8
  • 1
    Consider solving your problem when interact with user, instead of in the data itself. Your ultimate goal is to let user work in their local timezone. It "shouldn't matter" how it is stored. In the long run, it often works best for all datetimes to be stored in UTC, and then converted to/from user's local timezone, for user input and display, If you really want to store local timezone, either store DateTime.Ticks (a long), or store as a string. – ToolmakerSteve May 15 '23 at 20:16

0 Answers0