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