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