|
Time Shield Library 2.0.0
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 23 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 473 of file time_formatting.mqh.
|
inline |
Converts a timestamp in seconds to a human-readable format.
| ts | The timestamp in seconds. |
Definition at line 970 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 481 of file time_formatting.mqh.
|
inline |
Converts a timestamp in milliseconds to a human-readable format.
| ts | The timestamp in milliseconds. |
Definition at line 989 of file time_formatting.hpp.
| string time_shield::to_iso8601 | ( | long | ts | ) |
Convert timestamp to ISO8601 string.
| ts | Timestamp in seconds. |
Definition at line 351 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 406 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 575 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 757 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 367 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 613 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 359 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 416 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 731 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 831 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 375 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 634 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 383 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 653 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 391 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 672 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 398 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 708 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 437 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 902 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 429 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 874 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 452 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 892 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 445 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 921 of file time_formatting.hpp.
|
inline |
Alias for to_string function.
| format_str | Format string with custom parameters. |
| timestamp | Timestamp in seconds. |
| utc_offset | UTC offset in seconds. |
Definition at line 474 of file time_formatting.hpp.
| string time_shield::to_str | ( | string | format_str, |
| long | timestamp, | ||
| int | utc_offset = 0 ) |
Alias for to_string.
| format_str | Format string with custom parameters. |
| timestamp | Timestamp in seconds. |
| utc_offset | UTC offset in seconds. |
Definition at line 283 of file time_formatting.mqh.
|
inline |
Alias for to_string function.
| format_str | Format string with custom parameters. |
| timestamp | Timestamp in milliseconds. |
| utc_offset | UTC offset in seconds. |
Definition at line 560 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.
| format_str | Format string with custom parameters. |
| timestamp_ms | Timestamp in milliseconds. |
| utc_offset | UTC offset in seconds. |
Definition at line 340 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.
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 422 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.
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 508 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 295 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 457 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 931 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 465 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 950 of file time_formatting.hpp.