1a1c3daa6SAndrew Lindesay /* 2*f0e491d3SAndrew Lindesay * Copyright 2017-2020, Andrew Lindesay <apl@lindesay.co.nz>. 3a1c3daa6SAndrew Lindesay * All rights reserved. Distributed under the terms of the MIT License. 4a1c3daa6SAndrew Lindesay */ 5a1c3daa6SAndrew Lindesay 63369e03dSAndrew Lindesay 7a1c3daa6SAndrew Lindesay #include "StandardMetaData.h" 8a1c3daa6SAndrew Lindesay 93369e03dSAndrew Lindesay StandardMetaData()10a1c3daa6SAndrew LindesayStandardMetaData::StandardMetaData() 11a1c3daa6SAndrew Lindesay { 12a1c3daa6SAndrew Lindesay fCreateTimestamp = 0; 13a1c3daa6SAndrew Lindesay fDataModifiedTimestamp = 0; 14a1c3daa6SAndrew Lindesay } 15a1c3daa6SAndrew Lindesay 16a1c3daa6SAndrew Lindesay 17*f0e491d3SAndrew Lindesay /*static*/ BDateTime _CreateDateTime(uint64_t millisSinceEpoc)18a1c3daa6SAndrew LindesayStandardMetaData::_CreateDateTime(uint64_t millisSinceEpoc) 19a1c3daa6SAndrew Lindesay { 20a1c3daa6SAndrew Lindesay time_t secondsSinceEpoc = (millisSinceEpoc / 1000); 21a1c3daa6SAndrew Lindesay BDateTime result; 22a1c3daa6SAndrew Lindesay result.SetTime_t(secondsSinceEpoc); 23a1c3daa6SAndrew Lindesay return result; 24a1c3daa6SAndrew Lindesay } 25a1c3daa6SAndrew Lindesay 26a1c3daa6SAndrew Lindesay 27a1c3daa6SAndrew Lindesay uint64_t GetCreateTimestamp() const28*f0e491d3SAndrew LindesayStandardMetaData::GetCreateTimestamp() const 29a1c3daa6SAndrew Lindesay { 30a1c3daa6SAndrew Lindesay return fCreateTimestamp; 31a1c3daa6SAndrew Lindesay } 32a1c3daa6SAndrew Lindesay 33a1c3daa6SAndrew Lindesay 34a1c3daa6SAndrew Lindesay BDateTime GetCreateTimestampAsDateTime() const35*f0e491d3SAndrew LindesayStandardMetaData::GetCreateTimestampAsDateTime() const 36a1c3daa6SAndrew Lindesay { 37a1c3daa6SAndrew Lindesay return _CreateDateTime(GetCreateTimestamp()); 38a1c3daa6SAndrew Lindesay } 39a1c3daa6SAndrew Lindesay 40a1c3daa6SAndrew Lindesay 41a1c3daa6SAndrew Lindesay void SetCreateTimestamp(uint64_t value)42a1c3daa6SAndrew LindesayStandardMetaData::SetCreateTimestamp(uint64_t value) 43a1c3daa6SAndrew Lindesay { 44a1c3daa6SAndrew Lindesay fCreateTimestamp = value; 45a1c3daa6SAndrew Lindesay } 46a1c3daa6SAndrew Lindesay 47a1c3daa6SAndrew Lindesay 48a1c3daa6SAndrew Lindesay uint64_t GetDataModifiedTimestamp() const49*f0e491d3SAndrew LindesayStandardMetaData::GetDataModifiedTimestamp() const 50a1c3daa6SAndrew Lindesay { 51a1c3daa6SAndrew Lindesay return fDataModifiedTimestamp; 52a1c3daa6SAndrew Lindesay } 53a1c3daa6SAndrew Lindesay 54a1c3daa6SAndrew Lindesay 55a1c3daa6SAndrew Lindesay void SetDataModifiedTimestamp(uint64_t value)56a1c3daa6SAndrew LindesayStandardMetaData::SetDataModifiedTimestamp(uint64_t value) 57a1c3daa6SAndrew Lindesay { 58a1c3daa6SAndrew Lindesay fDataModifiedTimestamp = value; 59a1c3daa6SAndrew Lindesay } 60a1c3daa6SAndrew Lindesay 61a1c3daa6SAndrew Lindesay 62a1c3daa6SAndrew Lindesay BDateTime GetDataModifiedTimestampAsDateTime() const63*f0e491d3SAndrew LindesayStandardMetaData::GetDataModifiedTimestampAsDateTime() const 64a1c3daa6SAndrew Lindesay { 65a1c3daa6SAndrew Lindesay return _CreateDateTime(GetDataModifiedTimestamp()); 66a1c3daa6SAndrew Lindesay } 67a1c3daa6SAndrew Lindesay 68a1c3daa6SAndrew Lindesay 69a1c3daa6SAndrew Lindesay bool IsPopulated() const70*f0e491d3SAndrew LindesayStandardMetaData::IsPopulated() const 71a1c3daa6SAndrew Lindesay { 72a1c3daa6SAndrew Lindesay return fCreateTimestamp != 0 && fDataModifiedTimestamp != 0; 73a1c3daa6SAndrew Lindesay } 74