Skip to content

Commit

Permalink
Switch to using format and chrono.
Browse files Browse the repository at this point in the history
  • Loading branch information
Masfo committed Apr 24, 2022
1 parent 390d0ee commit 7814f48
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 33 deletions.
4 changes: 2 additions & 2 deletions buildinc.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@
<ClInclude Include="src\buildnumber.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="bin\test.h">
<ClInclude Include="effwords.h">
<Filter>Source Files</Filter>
</ClInclude>
<ClInclude Include="effwords.h">
<ClInclude Include="bin\test.h">
<Filter>Source Files</Filter>
</ClInclude>
</ItemGroup>
Expand Down
18 changes: 9 additions & 9 deletions src/buildnumber.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// AUTOMATICALLY GENERATED BY BUILDINC v0.1.88 TOOL
// LAST BUILD: 2022-01-24 15:11:15
// AUTOMATICALLY GENERATED BY BUILDINC v0.1.98 TOOL
// LAST BUILD: 2022-04-24 20:47:29

#pragma once

Expand All @@ -15,15 +15,15 @@ namespace BuildIncVersion
constexpr uint32_t minor = 1;

// Do not modify these
constexpr uint32_t build = 88;
constexpr uint32_t build = 99;

constexpr uint32_t version = major * 1000 + minor * 100 + build;
constexpr uint64_t random_seed = 0x1c7f372cae5b19e2;
constexpr uint64_t random_seed = 0x1420fe4586eca80c;

constexpr char version_string[] = "v0.1.88";
constexpr char build_time_string[] = "2022-01-24 15:11:15";
constexpr char phrase[] = "untwist-shock-politely";
constexpr char calver[] = "2022.04.88";
constexpr char version_string[] = "v0.1.99";
constexpr char build_time_string[] = "2022-04-24 20:47:29";
constexpr char phrase[] = "battery-willpower-donut";
constexpr char calver[] = "2022.16.99";

// Copy paste to import to your project
/*
Expand All @@ -36,7 +36,7 @@ namespace BuildIncVersion
constexpr auto version_string = BuildIncVersion::version_string;
constexpr auto build_time_string = BuildIncVersion::build_time_string;
constexpr auto phrase = BuildIncVersion::phrase;
constexpr auto phrase = BuildIncVersion::calver;
constexpr auto calver = BuildIncVersion::calver;
*/
}
#endif // BUILDINCVERSION_BUILDNUMBER_HEADER_H
Expand Down
28 changes: 6 additions & 22 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,34 +116,21 @@ static std::string ToUpper(const std::string &s)
return ret;
}


std::string GetDateString()
{
std::stringstream buffer;
auto now = std::chrono::system_clock::now();
auto in_time_t = std::chrono::system_clock::to_time_t(now);

tm nt;
localtime_s(&nt, &in_time_t);

buffer << std::put_time(&nt, "%F %T");
return buffer.str();
auto const time = std::chrono::current_zone()->to_local(std::chrono::system_clock::now());
return std::format("{:%Y-%m-%d %X}", time);
}

std::string cal_version_string(uint32_t build)
{
std::stringstream buffer;
auto now = std::chrono::system_clock::now();
auto in_time_t = std::chrono::system_clock::to_time_t(now);

tm nt;
localtime_s(&nt, &in_time_t);

buffer << std::put_time(&nt, "%Y.%V");
return std::format("{}.{}", buffer.str(), build);
auto const time = std::chrono::current_zone()->to_local(std::chrono::system_clock::now());
return std::format("{:%Y.%V}.{}", time, build);
}

void WriteHeader(std::filesystem::path &HeaderFile,
const std::string & project_namespace,
const std::string &project_namespace,
uint32_t major,
uint32_t minor,
uint32_t build)
Expand Down Expand Up @@ -199,7 +186,6 @@ void WriteHeader(std::filesystem::path &HeaderFile,
generated.append(std::format("\t\tconstexpr char calver[] = \"{}\";\n", cal_version_string(build)));



generated.append("\n");

generated.append("\t\t// Copy paste to import to your project\n");
Expand All @@ -218,8 +204,6 @@ void WriteHeader(std::filesystem::path &HeaderFile,
generated.append(std::format("\t\t\tconstexpr auto calver = {}::calver;\n", modns));




generated.append("\t\t*/\n");


Expand Down

0 comments on commit 7814f48

Please sign in to comment.