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