Bug fixes for alias&join. Add test in presentation.

This commit is contained in:
2022-09-20 02:21:49 +08:00
parent 2614d010da
commit ff63be720c
24 changed files with 1135 additions and 146 deletions
+3 -3
View File
@@ -181,7 +181,7 @@ namespace types {
return !operator==(other);
}
bool time_t::validate() const{
return hours < 24 && minutes < 60 && seconds < 60 && ms < 1000;
return hours < 24 && minutes < 60 && seconds < 60 && ms < 1000000;
}
timestamp_t::timestamp_t(const char* str) { fromString(str); }
@@ -244,13 +244,13 @@ std::ostream& operator<<(std::ostream& os, types::timestamp_t & v)
using std::string;
string base62uuid(int l = 8) {
string base62uuid(int l) {
using namespace std;
constexpr static const char* base62alp = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
static mt19937_64 engine(chrono::system_clock::now().time_since_epoch().count());
static uniform_int_distribution<uint64_t> u(0x10000, 0xfffff);
uint64_t uuid = (u(engine) << 32ull) + (chrono::system_clock::now().time_since_epoch().count() & 0xffffffff);
printf("%llu\n", uuid);
//printf("%llu\n", uuid);
string ret;
while (uuid && l-- >= 0) {
ret = string("") + base62alp[uuid % 62] + ret;
+1 -1
View File
@@ -69,7 +69,7 @@ namespace types {
time_t& fromString(const char*);
bool validate() const;
constexpr static unsigned string_length() {
return 13;
return 16;
};
char* toString(char* buf) const;
bool operator > (const time_t&) const;
+3 -2
View File
@@ -1,5 +1,4 @@
#pragma once
#include <string>
#include <ctime>
#if ((defined(_MSVC_LANG) && _MSVC_LANG >= 201703L) || __cplusplus >= 201703L)
constexpr static bool cpp_17 = true;
@@ -13,4 +12,6 @@ inline const char* str(const T& v) {
template <>
inline const char* str(const bool& v) {
return v ? "true" : "false";
}
}
#include<string>
extern std::string base62uuid(int l = 6);