LastModificationTime and different time zones

2013-12-31
2014-01-03
  • I was just looking through the source code of Keepass (because I'm using it in Keepass2Android) and as far as I can tell, the LastModificationTime property of PwEntry (type DateTime) stores local times. The Touch method sets this property to DateTime.Now, which, according to http://msdn.microsoft.com/de-de/library/system.datetime.now(v=vs.100).aspx, uses the local time.

    According to http://msdn.microsoft.com/en-us/library/ms973825.aspx, "A developer is responsible for keeping track of time-zone information associated with a DateTime value via some external mechanism". Does any such mechanism exist in Keepass?

    This is important if changes from different devices are synchronized in order to keep the latest changes. Am I missing something?

     
  • Dominik Reichl
    Dominik Reichl
    2013-12-31

    In KDBX files, times are always stored in UTC.

    While KeePass is running, it uses local times (i.e. when KeePass opens a KDBX file, it loads all times in UTC and converts them to local, and when saving it converts them back from local to UTC).

    Best regards,
    Dominik

     
  • ah, thanks for pointing that out!
    This means that the serializing code is responsible for this (which makes sense). So the next question is for Alex Vallat: I think this conversion is not performed in the Kdbp serializing code, right?

     
  • AlexVallat
    AlexVallat
    2014-01-03

    Yes, thanks for letting me know, I was just serialising the times exactly as they were stored in memory. I've fixed this now, in KdbpFile v0.3 and sent you a pull request for the same change to the implementation in Keepass2Android.

    Alex