isar / isar/hive

Retrieving DateTime from Hive storage precision is being lost.

Open
#474 5 comments 1 reaction 0 assignees View on GitHub
question
Dominant language
Dart
Stars
4.4k
Forks
449
PR merge metrics
No merged PRs in 30d

Description

**Question**
When retrieving DateTime from storage the precision is lost, the precision is maintained when stored in memory it is only when retrieval from storage is triggered that the resulting date has now lost precision.

**Code sample**
```dart
var myBox = await Hive.openBox('myBox');
if(myBox.get('dateTest') == null)
{
var timeToStore = DateTime.parse('2020-10-19 18:11:29.497022');
await myBox.put('dateTest', timeToStore);
print('Storing date in HIVE');
}
print(await myBox.get('dateTest'));

// RESTART APP

```

This code will display the date correctly after it is first stored and being retrieved from memory, but after restarting the app the date retrieved from storage and then shown is

2020-10-19 18:11:29.497000

which has lost the precision compared with memory storage.

**Version**
- Platform: iOS
- Flutter version: stable, 1.22.2, on Mac OS X 10.15.6 19G2021, locale en-GB
- Hive version: 1.4.4+1
- Hive Flutter: 0.3.1

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.