Commit bb839768 authored by Vincent Hamp's avatar Vincent Hamp
Browse files

Update README.md

parent 4f05c899
......@@ -2,7 +2,7 @@
"version": "2.0.0",
"tasks": [
{
"label": "Jidai doxygen",
"label": "Doxygen",
"type": "shell",
"isBackground": true,
"options": {
......@@ -11,13 +11,13 @@
"command": "doxygen Jidai.doxyfile"
},
{
"label": "Jidai make test",
"label": "Make test",
"type": "shell",
"isBackground": true,
"command": "make test"
},
{
"label": "Jidai run test",
"label": "Run test",
"type": "shell",
"isBackground": true,
"options": {
......
# Bla
Some words about this
\ No newline at end of file
# Jidai
Jidai is a miniature single header library for generating compilation time stamps from the [standard preprocessor defines](https://gcc.gnu.org/onlinedocs/cpp/Standard-Predefined-Macros.html) \__DATE__ and \__TIME__.
The lib comes with two different functions.
One which returns the compilation time as plain struct with integer values for date and time.
```cpp
constexpr CompilationTime make_compilation_time();
struct CompilationTime {
uint8_t day{};
uint8_t month{};
uint16_t year{};
uint8_t hour{};
uint8_t minute{};
uint8_t second{};
};
```
And one which returns a unix time stamp since an epoch passed in. The default here is the classic unix epoch 1/1/1970.
```cpp
inline constexpr CompilationTime default_epoch{.day = 1, .month = 1, .year = 1970};
template<typename T = time_t>
constexpr T make_unix_compilation_time(CompilationTime epoch = default_epoch);
```
The src/test folder contains a little test case which i checked against the unix time stamp converter on [unixtimestamp.com](https://www.unixtimestamp.com/index.php).
```cpp
#include <iostream>
#include "jidai.hpp"
int main() {
constexpr auto ct{jidai::make_compilation_time()};
constexpr auto ut{jidai::make_unix_compilation_time()};
std::cout << "Test compiled at " << (int)ct.day << "/"
<< (int)ct.month << "/" << (int)ct.year << " "
<< (int)ct.hour << ":" << (int)ct.minute << ":"
<< (int)ct.second << " which equals " << ut
<< "seconds since 1/1/1970.\n";
}
```
......@@ -771,7 +771,7 @@ WARN_LOGFILE =
# spaces. See also FILE_PATTERNS and EXTENSION_MAPPING
# Note: If this tag is empty the current directory is searched.
INPUT = ../
INPUT = ../inc ../src ../README.md
# This tag can be used to specify the character encoding of the source files
# that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses
......
......@@ -14,12 +14,12 @@ namespace jidai {
/// Compilation date and time
struct CompilationTime {
uint8_t day;
uint8_t month;
uint16_t year;
uint8_t hour;
uint8_t minute;
uint8_t second;
uint8_t day{};
uint8_t month{};
uint16_t year{};
uint8_t hour{};
uint8_t minute{};
uint8_t second{};
};
namespace detail {
......@@ -153,8 +153,8 @@ constexpr CompilationTime make_compilation_time() {
///
/// \param time Compilation time to convert
/// \return Compilation time in seconds
constexpr size_t compilation_time2seconds(CompilationTime const time) {
auto const count_leap_years{[&time]() {
constexpr size_t compilation_time2seconds(CompilationTime time) {
auto count_leap_years{[&time]() {
size_t retval{time.year};
if (time.month <= 2)
--retval;
......@@ -194,8 +194,7 @@ inline constexpr CompilationTime default_epoch{
/// \tparam epoch Epoch to use
/// \return Unix compilation time since epoch
template<typename T = time_t>
constexpr T make_unix_compilation_time(
CompilationTime const epoch = default_epoch) {
constexpr T make_unix_compilation_time(CompilationTime epoch = default_epoch) {
return static_cast<T>(compilation_time2seconds(make_compilation_time()) -
compilation_time2seconds(epoch));
}
......
......@@ -29,15 +29,15 @@ $(LIB): $(OBJS)
# Assembly
$(TARGET_DIR)/%.asm.o: %.asm
$(MKDIR_P) $(dir $@)
$(AS) $(ASFLAGS) -c $< -o $@
$(AS) $(CPPFLAGS) $(ASFLAGS) -c $< -o $@
$(TARGET_DIR)/%.s.o: %.s
$(MKDIR_P) $(dir $@)
$(AS) $(ASFLAGS) -c $< -o $@
$(AS) $(CPPFLAGS) $(ASFLAGS) -c $< -o $@
$(TARGET_DIR)/%.S.o: %.S
$(MKDIR_P) $(dir $@)
$(AS) $(ASFLAGS) -c $< -o $@
$(AS) $(CPPFLAGS) $(ASFLAGS) -c $< -o $@
# C
$(TARGET_DIR)/%.c.o: %.c
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment