OpenSRX 0.1.0
C++ library for interfacing with Keyence SR series barcode readers
Loading...
Searching...
No Matches
Timestamp.hpp
Go to the documentation of this file.
1#pragma once
2#include <cstddef>
3#include <tuple>
4#include <vector>
5
6namespace OpenSRX {
7
11class Timestamp {
12 public:
23 Timestamp(int second = 0, int minute = 0, int hour = 0, int day = 1, int month = 1,
24 int year = 1970)
26
28 Timestamp() : Timestamp(0, 0, 0, 1, 1, 1970) {}
29
34 Timestamp(std::vector<std::byte> buff);
35 ~Timestamp() = default;
36
41 std::tuple<int, int, int, int, int, int> asTuple() const {
42 return std::make_tuple(year, month, day, hour, minute, second);
43 }
44
49 std::tuple<int, int, int> asDate() const { return std::make_tuple(year, month, day); }
50
51 int second;
52 int minute;
53 int hour;
54 int day;
55 int month;
56 int year;
57};
58
59} // namespace OpenSRX
Timestamp(int second=0, int minute=0, int hour=0, int day=1, int month=1, int year=1970)
Construct a Timestamp with explicit components.
Definition Timestamp.hpp:23
int month
Month (1–12).
Definition Timestamp.hpp:55
int year
Four-digit year.
Definition Timestamp.hpp:56
std::tuple< int, int, int > asDate() const
Return the date portion as a tuple.
Definition Timestamp.hpp:49
std::tuple< int, int, int, int, int, int > asTuple() const
Return all components as a tuple.
Definition Timestamp.hpp:41
~Timestamp()=default
int day
Day of month (1–31).
Definition Timestamp.hpp:54
int hour
Hours (0–23).
Definition Timestamp.hpp:53
int second
Seconds (0–59).
Definition Timestamp.hpp:51
Timestamp()
Default constructor (1970-01-01 00:00:00).
Definition Timestamp.hpp:28
Timestamp(std::vector< std::byte > buff)
Construct a Timestamp from a raw byte buffer.
int minute
Minutes (0–59).
Definition Timestamp.hpp:52
Definition AsioInterface.hpp:5