xref: /haiku/src/apps/haikudepot/server/StandardMetaData.cpp (revision 3369e03d5cde9709c8aa70c99bfe6ce24ba65bf9)
1a1c3daa6SAndrew Lindesay /*
2a1c3daa6SAndrew Lindesay  * Copyright 2017, Andrew Lindesay <apl@lindesay.co.nz>.
3a1c3daa6SAndrew Lindesay  * All rights reserved. Distributed under the terms of the MIT License.
4a1c3daa6SAndrew Lindesay  */
5a1c3daa6SAndrew Lindesay 
6*3369e03dSAndrew Lindesay 
7a1c3daa6SAndrew Lindesay #include "StandardMetaData.h"
8a1c3daa6SAndrew Lindesay 
9*3369e03dSAndrew Lindesay 
10a1c3daa6SAndrew Lindesay StandardMetaData::StandardMetaData()
11a1c3daa6SAndrew Lindesay {
12a1c3daa6SAndrew Lindesay 	fCreateTimestamp = 0;
13a1c3daa6SAndrew Lindesay 	fDataModifiedTimestamp = 0;
14a1c3daa6SAndrew Lindesay }
15a1c3daa6SAndrew Lindesay 
16a1c3daa6SAndrew Lindesay 
17a1c3daa6SAndrew Lindesay BDateTime
18a1c3daa6SAndrew Lindesay StandardMetaData::_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
28a1c3daa6SAndrew Lindesay StandardMetaData::GetCreateTimestamp()
29a1c3daa6SAndrew Lindesay {
30a1c3daa6SAndrew Lindesay 	return fCreateTimestamp;
31a1c3daa6SAndrew Lindesay }
32a1c3daa6SAndrew Lindesay 
33a1c3daa6SAndrew Lindesay 
34a1c3daa6SAndrew Lindesay BDateTime
35a1c3daa6SAndrew Lindesay StandardMetaData::GetCreateTimestampAsDateTime()
36a1c3daa6SAndrew Lindesay {
37a1c3daa6SAndrew Lindesay 	return _CreateDateTime(GetCreateTimestamp());
38a1c3daa6SAndrew Lindesay }
39a1c3daa6SAndrew Lindesay 
40a1c3daa6SAndrew Lindesay 
41a1c3daa6SAndrew Lindesay void
42a1c3daa6SAndrew Lindesay StandardMetaData::SetCreateTimestamp(uint64_t value)
43a1c3daa6SAndrew Lindesay {
44a1c3daa6SAndrew Lindesay 	fCreateTimestamp = value;
45a1c3daa6SAndrew Lindesay }
46a1c3daa6SAndrew Lindesay 
47a1c3daa6SAndrew Lindesay 
48a1c3daa6SAndrew Lindesay uint64_t
49a1c3daa6SAndrew Lindesay StandardMetaData::GetDataModifiedTimestamp()
50a1c3daa6SAndrew Lindesay {
51a1c3daa6SAndrew Lindesay 	return fDataModifiedTimestamp;
52a1c3daa6SAndrew Lindesay }
53a1c3daa6SAndrew Lindesay 
54a1c3daa6SAndrew Lindesay 
55a1c3daa6SAndrew Lindesay void
56a1c3daa6SAndrew Lindesay StandardMetaData::SetDataModifiedTimestamp(uint64_t value)
57a1c3daa6SAndrew Lindesay {
58a1c3daa6SAndrew Lindesay 	fDataModifiedTimestamp = value;
59a1c3daa6SAndrew Lindesay }
60a1c3daa6SAndrew Lindesay 
61a1c3daa6SAndrew Lindesay 
62a1c3daa6SAndrew Lindesay BDateTime
63a1c3daa6SAndrew Lindesay StandardMetaData::GetDataModifiedTimestampAsDateTime()
64a1c3daa6SAndrew Lindesay {
65a1c3daa6SAndrew Lindesay 	return _CreateDateTime(GetDataModifiedTimestamp());
66a1c3daa6SAndrew Lindesay }
67a1c3daa6SAndrew Lindesay 
68a1c3daa6SAndrew Lindesay 
69a1c3daa6SAndrew Lindesay bool
70a1c3daa6SAndrew Lindesay StandardMetaData::IsPopulated()
71a1c3daa6SAndrew Lindesay {
72a1c3daa6SAndrew Lindesay 	return fCreateTimestamp != 0 && fDataModifiedTimestamp != 0;
73a1c3daa6SAndrew Lindesay }
74