Time Shield Library
C++ library for working with time
|
A comprehensive set of functions for converting timestamps to formatted strings. More...
Topics | |
Time structure formatting | |
void | time_shield::process_format_impl (char last_char, size_t repeat_count, ts_t ts, tz_t utc_offset, const DateTimeStruct &dt, std::string &result) |
template<class T = ts_t> | |
const std::string | time_shield::to_string (const std::string &format_str, T timestamp, tz_t utc_offset=0) |
Convert timestamp to string with custom format. | |
template<class T = ts_t> | |
const std::string | time_shield::to_str (const std::string &format_str, T timestamp, tz_t utc_offset=0) |
Alias for to_string function. | |
template<class T = ts_ms_t> | |
const std::string | time_shield::to_string_ms (const std::string &format_str, T timestamp, tz_t utc_offset=0) |
Convert timestamp in milliseconds to string with custom format. | |
template<class T = ts_t> | |
const std::string | time_shield::to_str_ms (const std::string &format_str, T timestamp, tz_t utc_offset=0) |
Alias for to_string function. | |
template<class T = ts_t> | |
const std::string | time_shield::to_iso8601 (T ts) |
Converts a timestamp to an ISO8601 string. | |
template<class T = ts_t> | |
const std::string | time_shield::to_iso8601_date (T ts) |
Converts a timestamp to an ISO8601 date string. | |
template<class T = ts_t> | |
const std::string | time_shield::to_iso8601_time (T ts) |
Converts a timestamp to an ISO8601 time string. | |
template<class T = ts_t> | |
const std::string | time_shield::to_iso8601_time_utc (T ts) |
Converts a timestamp to an ISO8601 UTC time string. | |
template<class T = ts_t> | |
const std::string | time_shield::to_iso8601_utc (T ts) |
Converts a timestamp to an ISO8601 string in UTC format. | |
const std::string | time_shield::to_iso8601_utc_ms (ts_ms_t ts_ms) |
Converts a timestamp in milliseconds to an ISO8601 string in UTC format. | |
const std::string | time_shield::to_iso8601_ms (ts_ms_t ts_ms) |
Converts a timestamp in milliseconds to an ISO8601 string. | |
template<class T = ts_t> | |
const std::string | time_shield::to_iso8601 (T ts, tz_t utc_offset) |
Converts a timestamp to an ISO8601 string with timezone offset. | |
const std::string | time_shield::to_iso8601_ms (ts_ms_t ts_ms, tz_t utc_offset) |
Converts a timestamp in milliseconds to an ISO8601 string with timezone offset. | |
const std::string | time_shield::to_mql5_date_time (ts_t ts) |
Converts a timestamp to a string in MQL5 date and time format. | |
const std::string | time_shield::to_mql5_full (ts_t ts) |
Alias for to_mql5_date_time_str function. | |
const std::string | time_shield::to_mql5_date (ts_t ts) |
Converts a timestamp to a string in MQL5 date format. | |
const std::string | time_shield::to_mql5_time (ts_t ts) |
Converts a timestamp to a string in MQL5 time format. | |
const std::string | time_shield::to_windows_filename (ts_t ts) |
Converts a timestamp in seconds to a Windows-compatible filename format. | |
const std::string | time_shield::to_windows_filename_ms (ts_ms_t ts) |
Converts a timestamp in milliseconds to a Windows-compatible filename format. | |
std::string | time_shield::to_human_readable (ts_t ts) |
Converts a timestamp in seconds to a human-readable format. | |
std::string | time_shield::to_human_readable_ms (ts_ms_t ts) |
Converts a timestamp in milliseconds to a human-readable format. | |
string | time_shield::pad_int (int value, int width) |
Internal helper to pad integer with leading zeros. | |
void | time_shield::process_format_impl (const char last_char, int repeat_count, long ts, int utc_offset, const DateTimeStruct &dt, string &result) |
Internal helper for custom formatting processing. | |
string | time_shield::to_string (string format_str, long timestamp, int utc_offset=0) |
Convert timestamp to string with custom format. | |
string | time_shield::to_str (string format_str, long timestamp, int utc_offset=0) |
Alias for to_string. | |
string | time_shield::to_string_ms (string format_str, long timestamp_ms, int utc_offset=0) |
Convert millisecond timestamp to string with custom format. | |
string | time_shield::to_str_ms (string format_str, long timestamp_ms, int utc_offset=0) |
Alias for to_string_ms. | |
string | time_shield::to_iso8601 (long ts) |
Convert timestamp to ISO8601 string. | |
string | time_shield::to_iso8601_ms (long ts_ms) |
Convert millisecond timestamp to ISO8601 string. | |
string | time_shield::to_iso8601_date (long ts) |
Convert timestamp to ISO8601 date string. | |
string | time_shield::to_iso8601_time (long ts) |
Convert timestamp to ISO8601 time string. | |
string | time_shield::to_iso8601_time_ms (long ts_ms) |
Convert millisecond timestamp to ISO8601 time string. | |
string | time_shield::to_iso8601_utc (long ts) |
Convert timestamp to ISO8601 string in UTC. | |
string | time_shield::to_iso8601_utc_ms (long ts_ms) |
Convert millisecond timestamp to ISO8601 string in UTC. | |
string | time_shield::to_iso8601 (long ts, int utc_offset) |
Convert timestamp to ISO8601 string with timezone offset. | |
string | time_shield::to_iso8601_ms (long ts_ms, int utc_offset) |
Convert millisecond timestamp to ISO8601 string with timezone offset. | |
string | time_shield::to_mql5_date_time (long ts) |
Convert timestamp to MQL5 date-time string. | |
string | time_shield::to_mql5_date (long ts) |
Convert timestamp to MQL5 date string. | |
string | time_shield::to_mql5_time (long ts) |
Convert timestamp to MQL5 time string. | |
string | time_shield::to_mql5_full (long ts) |
Alias for to_mql5_date_time. | |
string | time_shield::to_windows_filename (long ts) |
Convert timestamp to Windows-compatible filename. | |
string | time_shield::to_windows_filename_ms (long ts_ms) |
Convert millisecond timestamp to Windows-compatible filename. | |
string | time_shield::to_human_readable (long ts) |
Convert timestamp to human-readable string. | |
string | time_shield::to_human_readable_ms (long ts_ms) |
Convert millisecond timestamp to human-readable string. | |
A comprehensive set of functions for converting timestamps to formatted strings.
This module provides utilities for formatting timestamps into human-readable strings, custom formats, ISO8601, and other standardized formats.
strftime
-like specifiers.string time_shield::pad_int | ( | int | value, |
int | width ) |
Internal helper to pad integer with leading zeros.
value | Integer value to pad. |
width | Desired width of the number. |
Definition at line 37 of file time_formatting.mqh.
|
inline |
Definition at line 21 of file time_formatting.hpp.
void time_shield::process_format_impl | ( | const char | last_char, |
int | repeat_count, | ||
long | ts, | ||
int | utc_offset, | ||
const DateTimeStruct & | dt, | ||
string & | result ) |
Internal helper for custom formatting processing.
This function handles individual format specifiers used by to_string and to_string_ms.
last_char | Current format character. |
repeat_count | Number of repeats of the format character. |
ts | Timestamp in seconds. |
utc_offset | UTC offset in seconds. |
dt | DateTimeStruct corresponding to the timestamp. |
result | Output string being built. |
Definition at line 59 of file time_formatting.mqh.
string time_shield::to_human_readable | ( | long | ts | ) |
Convert timestamp to human-readable string.
ts | Timestamp in seconds. |
Definition at line 469 of file time_formatting.mqh.
std::string time_shield::to_human_readable | ( | ts_t | ts | ) |
Converts a timestamp in seconds to a human-readable format.
ts | The timestamp in seconds. |
Definition at line 750 of file time_formatting.hpp.
string time_shield::to_human_readable_ms | ( | long | ts_ms | ) |
Convert millisecond timestamp to human-readable string.
ts_ms | Timestamp in milliseconds. |
Definition at line 477 of file time_formatting.mqh.
std::string time_shield::to_human_readable_ms | ( | ts_ms_t | ts | ) |
Converts a timestamp in milliseconds to a human-readable format.
ts | The timestamp in milliseconds. |
Definition at line 760 of file time_formatting.hpp.
string time_shield::to_iso8601 | ( | long | ts | ) |
Convert timestamp to ISO8601 string.
ts | Timestamp in seconds. |
Definition at line 347 of file time_formatting.mqh.
string time_shield::to_iso8601 | ( | long | ts, |
int | utc_offset ) |
Convert timestamp to ISO8601 string with timezone offset.
ts | Timestamp in seconds. |
utc_offset | Offset from UTC in seconds. |
Definition at line 402 of file time_formatting.mqh.
|
inline |
Converts a timestamp to an ISO8601 string.
This function converts a timestamp to a string in ISO8601 format.
T | The type of the timestamp (default is ts_t). |
ts | The timestamp to convert. |
Definition at line 525 of file time_formatting.hpp.
|
inline |
Converts a timestamp to an ISO8601 string with timezone offset.
This function converts a timestamp to a string in ISO8601 format with timezone offset.
T | The type of the timestamp (default is ts_t). |
ts | The timestamp to convert. |
utc_offset | The timezone offset in seconds. |
Definition at line 643 of file time_formatting.hpp.
string time_shield::to_iso8601_date | ( | long | ts | ) |
Convert timestamp to ISO8601 date string.
ts | Timestamp in seconds. |
Definition at line 363 of file time_formatting.mqh.
|
inline |
Converts a timestamp to an ISO8601 date string.
This function converts the date part of a timestamp to a string in ISO8601 format.
T | The type of the timestamp (default is ts_t). |
ts | The timestamp to convert. |
Definition at line 544 of file time_formatting.hpp.
string time_shield::to_iso8601_ms | ( | long | ts_ms | ) |
Convert millisecond timestamp to ISO8601 string.
ts_ms | Timestamp in milliseconds. |
Definition at line 355 of file time_formatting.mqh.
string time_shield::to_iso8601_ms | ( | long | ts_ms, |
int | utc_offset ) |
Convert millisecond timestamp to ISO8601 string with timezone offset.
ts_ms | Timestamp in milliseconds. |
utc_offset | Offset from UTC in seconds. |
Definition at line 412 of file time_formatting.mqh.
|
inline |
Converts a timestamp in milliseconds to an ISO8601 string.
This function converts a timestamp in milliseconds to a string in ISO8601 format.
ts_ms | The timestamp in milliseconds to convert. |
Definition at line 627 of file time_formatting.hpp.
Converts a timestamp in milliseconds to an ISO8601 string with timezone offset.
This function converts a timestamp in milliseconds to a string in ISO8601 format with timezone offset.
ts_ms | The timestamp in milliseconds to convert. |
utc_offset | The timezone offset in seconds. |
Definition at line 670 of file time_formatting.hpp.
string time_shield::to_iso8601_time | ( | long | ts | ) |
Convert timestamp to ISO8601 time string.
ts | Timestamp in seconds. |
Definition at line 371 of file time_formatting.mqh.
|
inline |
Converts a timestamp to an ISO8601 time string.
This function converts the time part of a timestamp to a string in ISO8601 format.
T | The type of the timestamp (default is ts_t). |
ts | The timestamp to convert. |
Definition at line 559 of file time_formatting.hpp.
string time_shield::to_iso8601_time_ms | ( | long | ts_ms | ) |
Convert millisecond timestamp to ISO8601 time string.
ts_ms | Timestamp in milliseconds. |
Definition at line 379 of file time_formatting.mqh.
|
inline |
Converts a timestamp to an ISO8601 UTC time string.
This function converts the time part of a timestamp to a string in ISO8601 format with 'Z' indicating UTC.
T | The type of the timestamp (default is ts_t). |
ts | The timestamp to convert. |
Definition at line 578 of file time_formatting.hpp.
string time_shield::to_iso8601_utc | ( | long | ts | ) |
Convert timestamp to ISO8601 string in UTC.
ts | Timestamp in seconds. |
Definition at line 387 of file time_formatting.mqh.
|
inline |
Converts a timestamp to an ISO8601 string in UTC format.
This function converts a timestamp to a string in ISO8601 format with UTC timezone.
T | The type of the timestamp (default is ts_t). |
ts | The timestamp to convert. |
Definition at line 597 of file time_formatting.hpp.
string time_shield::to_iso8601_utc_ms | ( | long | ts_ms | ) |
Convert millisecond timestamp to ISO8601 string in UTC.
ts_ms | Timestamp in milliseconds. |
Definition at line 394 of file time_formatting.mqh.
|
inline |
Converts a timestamp in milliseconds to an ISO8601 string in UTC format.
This function converts a timestamp in milliseconds to a string in ISO8601 format with UTC timezone.
ts_ms | The timestamp in milliseconds to convert. |
Definition at line 614 of file time_formatting.hpp.
string time_shield::to_mql5_date | ( | long | ts | ) |
Convert timestamp to MQL5 date string.
ts | Timestamp in seconds. |
Definition at line 433 of file time_formatting.mqh.
|
inline |
Converts a timestamp to a string in MQL5 date format.
This function converts a timestamp to a string in MQL5 date format (yyyy.mm.dd).
ts | The timestamp to convert. |
Definition at line 707 of file time_formatting.hpp.
string time_shield::to_mql5_date_time | ( | long | ts | ) |
Convert timestamp to MQL5 date-time string.
ts | Timestamp in seconds. |
Definition at line 425 of file time_formatting.mqh.
|
inline |
Converts a timestamp to a string in MQL5 date and time format.
This function converts a timestamp to a string in MQL5 date and time format (yyyy.mm.dd hh:mm:ss).
ts | The timestamp to convert. |
Definition at line 688 of file time_formatting.hpp.
string time_shield::to_mql5_full | ( | long | ts | ) |
Alias for to_mql5_date_time.
Converts a timestamp to a string in MQL5 date and time format.
This function converts a timestamp to a string in MQL5 date and time format (yyyy.mm.dd hh:mm:ss).
ts | The timestamp to convert. |
Definition at line 448 of file time_formatting.mqh.
|
inline |
Alias for to_mql5_date_time_str function.
Converts a timestamp to a string in MQL5 date and time format.
This function converts a timestamp to a string in MQL5 date and time format (yyyy.mm.dd hh:mm:ss).
ts | The timestamp to convert. |
Definition at line 697 of file time_formatting.hpp.
string time_shield::to_mql5_time | ( | long | ts | ) |
Convert timestamp to MQL5 time string.
ts | Timestamp in seconds. |
Definition at line 441 of file time_formatting.mqh.
|
inline |
Converts a timestamp to a string in MQL5 time format.
This function converts a timestamp to a string in MQL5 time format (hh:mm:ss).
ts | The timestamp to convert. |
Definition at line 720 of file time_formatting.hpp.
|
inline |
Alias for to_string function.
Convert timestamp to string with custom format.
This function is similar to the strftime function and supports the majority of its specifiers, as well as additional ones: YY, YYYY, YYYYYY, WWW, www, hh, mm, ss, dd, sss.
The function accepts the following format specifiers as parameters:
For more information, see the strftime specifiers documentation:
format_str | Format string with custom parameters, e.g., "%H:%M:%S". |
timestamp | Timestamp. |
utc_offset | UTC offset in seconds (default is 0). |
Definition at line 427 of file time_formatting.hpp.
string time_shield::to_str | ( | string | format_str, |
long | timestamp, | ||
int | utc_offset = 0 ) |
Alias for to_string.
Convert timestamp to string with custom format.
This function is similar to the strftime function and supports the majority of its specifiers, as well as additional ones: YY, YYYY, YYYYYY, WWW, www, hh, mm, ss, dd, sss.
The function accepts the following format specifiers as parameters:
For more information, see the strftime specifiers documentation:
format_str | Format string with custom parameters, e.g., "%H:%M:%S". |
timestamp | Timestamp. |
utc_offset | UTC offset in seconds (default is 0). |
Definition at line 281 of file time_formatting.mqh.
|
inline |
Alias for to_string function.
Convert timestamp to string with custom format.
This function is similar to the strftime function and supports the majority of its specifiers, as well as additional ones: YY, YYYY, YYYYYY, WWW, www, hh, mm, ss, dd, sss.
The function accepts the following format specifiers as parameters:
For more information, see the strftime specifiers documentation:
format_str | Format string with custom parameters, e.g., "%H:%M:%S". |
timestamp | Timestamp. |
utc_offset | UTC offset in seconds (default is 0). |
Definition at line 510 of file time_formatting.hpp.
string time_shield::to_str_ms | ( | string | format_str, |
long | timestamp_ms, | ||
int | utc_offset = 0 ) |
Alias for to_string_ms.
Definition at line 336 of file time_formatting.mqh.
const std::string time_shield::to_string | ( | const std::string & | format_str, |
T | timestamp, | ||
tz_t | utc_offset = 0 ) |
Convert timestamp to string with custom format.
This function is similar to the strftime function and supports the majority of its specifiers, as well as additional ones: YY, YYYY, YYYYYY, WWW, www, hh, mm, ss, dd, sss.
The function accepts the following format specifiers as parameters:
For more information, see the strftime specifiers documentation:
format_str | Format string with custom parameters, e.g., "%H:%M:%S". |
timestamp | Timestamp. |
utc_offset | UTC offset in seconds (default is 0). |
Definition at line 378 of file time_formatting.hpp.
string time_shield::to_string | ( | string | format_str, |
long | timestamp, | ||
int | utc_offset = 0 ) |
Convert timestamp to string with custom format.
This function works similarly to the C++ strftime
implementation and supports most of its specifiers along with several custom ones.
format_str | Format string with specifiers, e.g. "%H:%M:%S". |
timestamp | Timestamp in seconds. |
utc_offset | UTC offset in seconds (default 0). |
format_str
. Definition at line 238 of file time_formatting.mqh.
const std::string time_shield::to_string_ms | ( | const std::string & | format_str, |
T | timestamp, | ||
tz_t | utc_offset = 0 ) |
Convert timestamp in milliseconds to string with custom format.
This function is similar to the strftime function and supports the majority of its specifiers, as well as additional ones: YY, YYYY, YYYYYY, WWW, www, hh, mm, ss, dd, sss.
The function accepts the following format specifiers as parameters:
For more information, see the strftime specifiers documentation:
format_str | Format string with custom parameters, e.g., "%H:%M:%S". |
timestamp | Timestamp in milliseconds. |
utc_offset | UTC offset in seconds (default is 0). |
Definition at line 461 of file time_formatting.hpp.
string time_shield::to_string_ms | ( | string | format_str, |
long | timestamp_ms, | ||
int | utc_offset = 0 ) |
Convert millisecond timestamp to string with custom format.
Works the same as to_string but accepts a timestamp in milliseconds.
format_str | Format string with specifiers. |
timestamp_ms | Timestamp in milliseconds. |
utc_offset | UTC offset in seconds (default 0). |
format_str
. Definition at line 293 of file time_formatting.mqh.
string time_shield::to_windows_filename | ( | long | ts | ) |
Convert timestamp to Windows-compatible filename.
ts | Timestamp in seconds. |
Definition at line 453 of file time_formatting.mqh.
|
inline |
Converts a timestamp in seconds to a Windows-compatible filename format.
ts | The timestamp in seconds. |
Definition at line 730 of file time_formatting.hpp.
string time_shield::to_windows_filename_ms | ( | long | ts_ms | ) |
Convert millisecond timestamp to Windows-compatible filename.
ts_ms | Timestamp in milliseconds. |
Definition at line 461 of file time_formatting.mqh.
|
inline |
Converts a timestamp in milliseconds to a Windows-compatible filename format.
ts | The timestamp in milliseconds. |
Definition at line 740 of file time_formatting.hpp.