lecui 1.0.0-alpha.20
lecui C++ user interface library
date_time.h
1//
2// date_time.h - date/time interface
3//
4// lecui user interface library, part of the liblec library
5// Copyright (c) 2019 Alec Musasa (alecmus at live dot com)
6//
7// Released under the MIT license. For full details see the
8// file LICENSE.txt
9//
10
11#pragma once
12
13#if defined(LECUI_EXPORTS)
14#include "../form.h"
15#else
16#include <liblec/lecui/form.h>
17#endif
18
19namespace liblec {
20 namespace lecui {
22 class lecui_api date_time {
23 public:
27 static std::string time_stamp();
28
32 static std::string weekday_to_string(unsigned short d);
33
37 static std::string month_to_string(unsigned short m);
38
42 static unsigned short month_from_string(std::string m);
43
47 static std::string to_string(date dt);
48
52 static date from_string(const std::string& dt);
53
56 static date today();
57
61 static date last_day_of_month(const date& dt);
62
66 static unsigned short day_of_week(date dt);
67
72 static date add_days(date dt, int n);
73
78 static void get_week(const date dt, date& start, date& end);
79
84 static void get_month(const date dt, date& start, date& end);
85
90 static void get_year(const date dt, date& start, date& end);
91
92 private:
93 class impl;
94 impl& _d;
95
96 // Copying an object of this class are not allowed
97 date_time(const date_time&) = delete;
98 date_time& operator=(const date_time&) = delete;
99 };
100 }
101}
Interact with date/time.
Definition: date_time.h:22
static unsigned short month_from_string(std::string m)
Get month from string.
static std::string month_to_string(unsigned short m)
Get month in the form of a string.
static void get_week(const date dt, date &start, date &end)
Get the start and end days of the week for a given date.
static std::string to_string(date dt)
Get date in the form of a string.
static date last_day_of_month(const date &dt)
Get the last day of the month for a given date.
static unsigned short day_of_week(date dt)
Get the day of the week for a given date.
static void get_year(const date dt, date &start, date &end)
Get the start and end days of the year for a given date.
static std::string time_stamp()
Make timestamp from current local time in the form 20190802 20:48:06.
static date from_string(const std::string &dt)
Parse date from a date string.
static std::string weekday_to_string(unsigned short d)
Get week day in the form of a string.
static date today()
Get the current local date.
static void get_month(const date dt, date &start, date &end)
Get the start and end days of the month for a given date.
static date add_days(date dt, int n)
Add days to a given date.
Top level namespace for the liblec libraries.
Definition: appearance.h:19
Date class.
Definition: lecui.h:904