refactor: use epoch timestamp

Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
This commit is contained in:
2026-07-04 18:38:38 -04:00
parent 858582a4ce
commit 6bf4706556
3 changed files with 13 additions and 11 deletions
+8 -7
View File
@@ -9,6 +9,7 @@ declare(strict_types=1);
namespace KTXM\ProviderLocalPeople\Store\Personal;
use KTXF\Utile\Timestamp;
use KTXC\Db\DataStore;
use KTXF\Resource\Filter\Filter;
use KTXF\Resource\Filter\FilterComparisonOperator;
@@ -252,7 +253,7 @@ class Store {
$data['uid'] = $userId;
$data['cid'] = UUID::v4();
$data['signature'] = isset($data['signature']) && is_numeric($data['signature']) ? (int)$data['signature'] : 0;
$data['createdOn'] = date('c');
$data['createdOn'] = Timestamp::now();
$data['modifiedOn'] = $data['createdOn'];
// create entry
$result = $this->_store->selectCollection($this->_CollectionTable)->insertOne($data);
@@ -280,7 +281,7 @@ class Store {
if ($cid === null) {
throw new \InvalidArgumentException('Collection identifier is required for modification');
}
$data['modifiedOn'] = date('c');
$data['modifiedOn'] = Timestamp::now();
unset($data['_id'], $data['tid'], $data['uid'], $data['cid']);
// modify entry
$this->_store->selectCollection($this->_CollectionTable)->updateOne(
@@ -370,8 +371,8 @@ class Store {
/** @var \KTXF\Resource\Range\IRangeDate $rangeDate */
$rangeDate = $range;
$query['data.startsOn'] = [
'\$gte' => $rangeDate->getStart()->format('c'),
'\$lte' => $rangeDate->getEnd()->format('c')
'\$gte' => Timestamp::toIso8601($rangeDate->getStart()) ?? throw new \InvalidArgumentException('Invalid epoch millisecond range boundary'),
'\$lte' => Timestamp::toIso8601($rangeDate->getEnd()) ?? throw new \InvalidArgumentException('Invalid epoch millisecond range boundary')
];
}
}
@@ -486,7 +487,7 @@ class Store {
$data['uid'] = $userId;
$data['cid'] = $collectionId;
$data['eid'] = UUID::v4();
$data['createdOn'] = date('c');
$data['createdOn'] = Timestamp::now();
$data['createdBy'] = $userId;
$data['modifiedOn'] = $data['createdOn'];
$data['modifiedBy'] = $data['createdBy'];
@@ -518,7 +519,7 @@ class Store {
public function entityModify(string $tenantId, string $userId, string $collectionId, string $identifier, EntityResource $entity): EntityResource {
// convert entity to store format
$data = $entity->toStore();
$data['modifiedOn'] = date('c');
$data['modifiedOn'] = Timestamp::now();
$data['modifiedBy'] = $userId;
// Remove identifiers from update data (they shouldn't change)
unset($data['_id'], $data['tid'], $data['uid'], $data['cid'], $data['eid']);
@@ -632,7 +633,7 @@ class Store {
'eid' => $eid,
'operation' => $operation,
'signature' => $signature,
'mutatedOn' => time(),
'mutatedOn' => Timestamp::now(),
]);
// update signature as normalized numeric value