Loading...
Searching...
No Matches
ChatMessage.h
Go to the documentation of this file.
1//
2// Created by Dave Smith on 4/30/26.
3//
4
5#ifndef CHATMESSAGE_H
6#define CHATMESSAGE_H
7#include <string>
8#include <chrono>
9#include <ctime>
10namespace ml
11{
12 struct ChatMessage {
13 std::string sender;
14 std::string text;
15 std::string timestamp;
16 bool isMine = false;
17 static std::string isoToHM(const std::string& iso = "")
18 {
19 if (iso.empty())
20 {
21 std::time_t now = std::time(nullptr);
22 std::tm* lt = std::localtime(&now);
23 char buf[6];
24 std::strftime(buf, sizeof(buf), "%H:%M", lt);
25 return buf;
26 }
27 const auto t = iso.find('T');
28 if (t == std::string::npos || t + 6 > iso.size()) return iso;
29 return iso.substr(t + 1, 5);
30 }
31 };
32}
33
34
35#endif //CHATMESSAGE_H
Definition Component.h:22
std::string text
Definition ChatMessage.h:14
std::string sender
Definition ChatMessage.h:13
static std::string isoToHM(const std::string &iso="")
Definition ChatMessage.h:17
std::string timestamp
Definition ChatMessage.h:15