aboutsummaryrefslogtreecommitdiffstats
path: root/SQLiteStudio3/coreSQLiteStudio/chillout/common
diff options
context:
space:
mode:
Diffstat (limited to 'SQLiteStudio3/coreSQLiteStudio/chillout/common')
-rw-r--r--SQLiteStudio3/coreSQLiteStudio/chillout/common/common.cpp24
-rw-r--r--SQLiteStudio3/coreSQLiteStudio/chillout/common/common.h24
2 files changed, 48 insertions, 0 deletions
diff --git a/SQLiteStudio3/coreSQLiteStudio/chillout/common/common.cpp b/SQLiteStudio3/coreSQLiteStudio/chillout/common/common.cpp
new file mode 100644
index 0000000..2f51fc1
--- /dev/null
+++ b/SQLiteStudio3/coreSQLiteStudio/chillout/common/common.cpp
@@ -0,0 +1,24 @@
+#include "common.h"
+#include <ctime>
+#include <locale>
+#include <cstring>
+
+namespace Debug {
+ tm now() {
+ time_t now = time(0);
+ return *localtime(&now);
+ }
+
+#ifdef _WIN32
+ std::wostream& formatDateTime(std::wostream& out, const tm& t, const wchar_t* fmt) {
+ const std::time_put<wchar_t>& dateWriter = std::use_facet<std::time_put<wchar_t> >(out.getloc());
+ const size_t n = wcslen(fmt);
+#else
+ std::ostream& formatDateTime(std::ostream& out, const tm& t, const char* fmt) {
+ const std::time_put<char>& dateWriter = std::use_facet<std::time_put<char> >(out.getloc());
+ const size_t n = strlen(fmt);
+#endif
+ dateWriter.put(out, out, ' ', &t, fmt, fmt + n);
+ return out;
+ }
+}
diff --git a/SQLiteStudio3/coreSQLiteStudio/chillout/common/common.h b/SQLiteStudio3/coreSQLiteStudio/chillout/common/common.h
new file mode 100644
index 0000000..85b479a
--- /dev/null
+++ b/SQLiteStudio3/coreSQLiteStudio/chillout/common/common.h
@@ -0,0 +1,24 @@
+#ifndef COMMON_H
+#define COMMON_H
+
+#include <ctime>
+#include <ostream>
+
+#define CHILLOUT_DATETIME "%Y%m%d_%H%M%S"
+
+namespace Debug {
+ tm now();
+#ifdef _WIN32
+ std::wostream& formatDateTime(std::wostream& out, const tm& t, const wchar_t *fmt);
+#else
+ std::ostream& formatDateTime(std::ostream& out, const tm& t, const char* fmt);
+#endif
+
+ enum CrashDumpSize {
+ CrashDumpSmall,
+ CrashDumpNormal,
+ CrashDumpFull
+ };
+}
+
+#endif // COMMON_H