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 10 StandardMetaData::StandardMetaData() 11 { 12 fCreateTimestamp = 0; 13 fDataModifiedTimestamp = 0; 14 } 15 16 17 /*static*/ BDateTime 18 StandardMetaData::_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 28 StandardMetaData::GetCreateTimestamp() const 29 { 30 return fCreateTimestamp; 31 } 32 33 34 BDateTime 35 StandardMetaData::GetCreateTimestampAsDateTime() const 36 { 37 return _CreateDateTime(GetCreateTimestamp()); 38 } 39 40 41 void 42 StandardMetaData::SetCreateTimestamp(uint64_t value) 43 { 44 fCreateTimestamp = value; 45 } 46 47 48 uint64_t 49 StandardMetaData::GetDataModifiedTimestamp() const 50 { 51 return fDataModifiedTimestamp; 52 } 53 54 55 void 56 StandardMetaData::SetDataModifiedTimestamp(uint64_t value) 57 { 58 fDataModifiedTimestamp = value; 59 } 60 61 62 BDateTime 63 StandardMetaData::GetDataModifiedTimestampAsDateTime() const 64 { 65 return _CreateDateTime(GetDataModifiedTimestamp()); 66 } 67 68 69 bool 70 StandardMetaData::IsPopulated() const 71 { 72 return fCreateTimestamp != 0 && fDataModifiedTimestamp != 0; 73 } 74