FileSystemIndexer v0.1.2-beta
File System Indexer - An API to index files from your system
Loading...
Searching...
No Matches
fsi::utils Namespace Reference

Classes

struct  TimeUtils_DateTime

Typedefs

typedef struct fsi::utils::TimeUtils_DateTime TimeUtils_DateTime

Functions

TimeUtils_DateTime fsClockDataToDT (const fs::file_time_type &time)
 Set std::filesystem clock data to an actual usable Date and Time format.

Typedef Documentation

◆ TimeUtils_DateTime

typedef struct fsi::utils::TimeUtils_DateTime fsi::utils::TimeUtils_DateTime

Function Documentation

◆ fsClockDataToDT()

TimeUtils_DateTime fsi::utils::fsClockDataToDT ( const fs::file_time_type & time)

Set std::filesystem clock data to an actual usable Date and Time format.

Parameters
timeGet std::filesystem::file_time_type that is to be converted to a usuable time format
Returns
Date-Time object to be used

Definition at line 8 of file FSI_timeUtils.cpp.

9 {
11
12 const auto &sctp = std::chrono::time_point_cast<std::chrono::system_clock::duration>(
13 time - fs::file_time_type::clock::now() + std::chrono::system_clock::now()
14 );
15
16 auto epochSec = std::chrono::time_point_cast<std::chrono::seconds>(sctp);
17 auto epochMs = std::chrono::duration_cast<std::chrono::microseconds>(sctp - epochSec).count();
18
19 std::time_t timeInfo = std::chrono::system_clock::to_time_t(epochSec);
20 std::tm tm{};
21
22 __FSI_LOCALTIME(&timeInfo, &tm);
23
24 // Time
25 dt.hour = tm.tm_hour;
26 dt.min = tm.tm_min;
27 dt.sec = tm.tm_sec;
28 dt.ms = (unsigned int)(epochMs);
29
30 // Date
31 dt.year = tm.tm_year + 1900;
32 dt.month = tm.tm_mon + 1;
33 dt.day = tm.tm_mday;
34
35 return dt;
36 }
#define __FSI_LOCALTIME(_tt, _tm)

References __FSI_LOCALTIME, fsi::utils::TimeUtils_DateTime::day, fsi::utils::TimeUtils_DateTime::hour, fsi::utils::TimeUtils_DateTime::min, fsi::utils::TimeUtils_DateTime::month, fsi::utils::TimeUtils_DateTime::ms, fsi::utils::TimeUtils_DateTime::sec, and fsi::utils::TimeUtils_DateTime::year.

Referenced by fsi::Indexer::getFileDTInfo().

Here is the caller graph for this function: