Time Shield Library
C++ library for working with time
Loading...
Searching...
No Matches
time_conversions.mqh File Reference

Header with helper functions for converting between different time representations in MQL5. More...

Go to the source code of this file.

Namespaces

namespace  time_shield
 Main namespace for the Time Shield library.
 

Macros

#define __TIME_SHIELD_TIME_CONVERSIONS_MQH__
 

Functions

int time_shield::ns_of_sec (double ts)
 Get the nanosecond part of a floating-point timestamp.
 
int time_shield::us_of_sec (double ts)
 Get the microsecond part of a floating-point timestamp.
 
int time_shield::ms_of_sec (double ts)
 Get the millisecond part of a floating-point timestamp.
 
int time_shield::ms_of_ts (long ts_ms)
 Get the millisecond part of a millisecond timestamp.
 
long time_shield::sec_to_ms (double sec)
 Convert seconds to milliseconds.
 
long time_shield::ms_to_sec (long ms)
 Convert milliseconds to seconds (integer part).
 
double time_shield::ms_to_fsec (long ms)
 Convert milliseconds to floating-point seconds.
 
long time_shield::min_to_ms (double min)
 Convert minutes to milliseconds.
 
int time_shield::ms_to_min (long ms)
 Convert milliseconds to minutes (integer part).
 
long time_shield::min_to_sec (double min)
 Convert minutes to seconds.
 
int time_shield::sec_to_min (long sec)
 Convert seconds to minutes (integer part).
 
double time_shield::min_to_fsec (double min)
 Convert minutes to floating-point seconds.
 
double time_shield::sec_to_fmin (long sec)
 Convert seconds to floating-point minutes.
 
long time_shield::hour_to_ms (double hr)
 Convert hours to milliseconds.
 
int time_shield::ms_to_hour (long ms)
 Convert milliseconds to hours (integer part).
 
long time_shield::hour_to_sec (double hr)
 Convert hours to seconds.
 
int time_shield::sec_to_hour (long sec)
 Convert seconds to hours (integer part).
 
double time_shield::hour_to_fsec (double hr)
 Convert hours to floating-point seconds.
 
double time_shield::sec_to_fhour (long sec)
 Convert seconds to floating-point hours.
 
int time_shield::hour24_to_12 (int hour)
 Convert a 24-hour format hour to a 12-hour format.
 
int time_shield::h24_to_h12 (int hour)
 Alias for hour24_to_12.
 
long time_shield::get_unix_year (long ts)
 Convert a UNIX timestamp to a year.
 
long time_shield::unix_year (long ts)
 Alias for get_unix_year function.
 
long time_shield::to_unix_year (long ts)
 Alias for get_unix_year function.
 
long time_shield::get_year (long ts)
 Get the year from a timestamp.
 
long time_shield::year (long ts)
 Alias for get_year.
 
long time_shield::to_year (long ts)
 Alias for get_year.
 
long time_shield::get_year_ms (long ts_ms)
 Get the year from a millisecond timestamp.
 
long time_shield::year_ms (long ts_ms)
 Alias for get_year_ms.
 
long time_shield::to_year_ms (long ts_ms)
 Alias for get_year_ms.
 
DateTimeStruct time_shield::to_date_time (long ts)
 Convert a timestamp to a DateTimeStruct.
 
DateTimeStruct time_shield::to_dt (long ts)
 Alias for to_date_time.
 
MqlDateTime time_shield::to_date_time_mql (long ts)
 Convert a timestamp to the standard MqlDateTime structure.
 
MqlDateTime time_shield::to_mql_dt (long ts)
 Alias for to_date_time_mql.
 
DateTimeStruct time_shield::to_date_time_ms (long ts_ms)
 Convert a timestamp in milliseconds to DateTimeStruct.
 
DateTimeStruct time_shield::to_dt_ms (long ts_ms)
 Alias for to_date_time_ms.
 
long time_shield::dt_to_timestamp (const DateTimeStruct &dt)
 Convert a DateTimeStruct to timestamp.
 
long time_shield::dt_to_timestamp (const MqlDateTime &dt)
 Convert an MqlDateTime structure to timestamp.
 
long time_shield::to_timestamp (const DateTimeStruct &dt)
 Alias for dt_to_timestamp.
 
long time_shield::to_timestamp (const MqlDateTime &dt)
 Alias for dt_to_timestamp taking MqlDateTime.
 
long time_shield::to_timestamp (long year, int mon, int day, int hour=0, int min=0, int sec=0)
 Convert date and time values to a timestamp.
 
long time_shield::to_ts (long year, int mon, int day, int hour=0, int min=0, int sec=0)
 Alias for to_timestamp with explicit date fields.
 
long time_shield::to_timestamp_ms (long year, int mon, int day, int hour=0, int min=0, int sec=0, int ms=0)
 Convert date and time values to a timestamp in milliseconds.
 
long time_shield::to_ts_ms (long year, int mon, int day, int hour=0, int min=0, int sec=0, int ms=0)
 Alias for to_timestamp_ms.
 
long time_shield::ts_ms (long year, int mon, int day, int hour=0, int min=0, int sec=0, int ms=0)
 Alias for to_timestamp_ms.
 
long time_shield::dt_to_timestamp_ms (const DateTimeStruct &dt)
 Convert a DateTimeStruct to a timestamp in milliseconds.
 
long time_shield::dt_to_timestamp_ms (const MqlDateTime &dt)
 Convert an MqlDateTime structure to a timestamp in milliseconds.
 
long time_shield::to_timestamp_ms (const DateTimeStruct &dt)
 Alias for dt_to_timestamp_ms.
 
long time_shield::to_timestamp_ms (const MqlDateTime &dt)
 Alias for dt_to_timestamp_ms.
 
double time_shield::dt_to_ftimestamp (const DateTimeStruct &dt)
 Convert a DateTimeStruct to floating-point timestamp.
 
double time_shield::dt_to_ftimestamp (const MqlDateTime &dt)
 Convert an MqlDateTime structure to floating-point timestamp.
 
double time_shield::to_ftimestamp (const DateTimeStruct &dt)
 Alias for dt_to_ftimestamp.
 
double time_shield::to_ftimestamp (const MqlDateTime &dt)
 Alias for dt_to_ftimestamp.
 
long time_shield::start_of_day (long ts)
 Get the start of the day for a timestamp.
 
long time_shield::day_start (long ts)
 Alias for start_of_day.
 
long time_shield::start_of_prev_day (long ts, int days=1)
 Get the start of the previous day.
 
long time_shield::previous_day_start (long ts, int days=1)
 Alias for start_of_prev_day.
 
long time_shield::start_of_day_sec (long ts_ms)
 Get the start of the day in seconds from milliseconds timestamp.
 
long time_shield::day_start_sec (long ts_ms)
 Alias for start_of_day_sec.
 
long time_shield::start_of_day_ms (long ts_ms)
 Get the start of the day for a millisecond timestamp.
 
long time_shield::day_start_ms (long ts_ms)
 Alias for start_of_day_ms.
 
long time_shield::start_of_next_day (long ts, int days=1)
 Get the start of the next day.
 
long time_shield::next_day_start (long ts, int days=1)
 Alias for start_of_next_day.
 
long time_shield::start_of_next_day_ms (long ts_ms, int days=1)
 Get the start of the next day in milliseconds.
 
long time_shield::next_day_start_ms (long ts_ms, int days=1)
 Alias for start_of_next_day_ms.
 
long time_shield::next_day (long ts, int days=1)
 Add days to a timestamp without adjusting to start of day.
 
long time_shield::next_day_ms (long ts_ms, int days=1)
 Add days to a millisecond timestamp without adjusting to start of day.
 
long time_shield::end_of_day (long ts)
 Get the end of the day for a timestamp.
 
long time_shield::day_end (long ts)
 Alias for end_of_day.
 
long time_shield::end_of_day_sec (long ts_ms)
 Get the end of the day in seconds from milliseconds timestamp.
 
long time_shield::day_end_sec (long ts_ms)
 Alias for end_of_day_sec.
 
long time_shield::end_of_day_ms (long ts_ms)
 Get the end of the day for a millisecond timestamp.
 
long time_shield::day_end_ms (long ts_ms)
 Alias for end_of_day_ms.
 
int time_shield::day_of_week_date (long year, int month, int day)
 Get the day of the week for a date.
 
int time_shield::get_weekday (long year, int month, int day)
 Alias for day_of_week_date.
 
int time_shield::day_of_week (long year, int month, int day)
 Alias for day_of_week_date.
 
int time_shield::get_weekday_from_date (const DateTimeStruct &dt)
 Get weekday from a DateTimeStruct.
 
int time_shield::get_weekday_from_date (const MqlDateTime &dt)
 Get weekday from a MqlDateTime structure.
 
int time_shield::day_of_week_dt (const DateTimeStruct &dt)
 Alias for get_weekday_from_date with DateTimeStruct.
 
int time_shield::day_of_week (const DateTimeStruct &dt)
 Alias for get_weekday_from_date with DateTimeStruct.
 
int time_shield::day_of_week_dt (const MqlDateTime &dt)
 Alias for get_weekday_from_date with MqlDateTime.
 
int time_shield::day_of_week (const MqlDateTime &dt)
 Alias for get_weekday_from_date with MqlDateTime.
 
int time_shield::get_weekday_from_ts (long ts)
 Get weekday from timestamp.
 
int time_shield::day_of_week (long ts)
 Alias for get_weekday_from_ts.
 
int time_shield::get_weekday_from_ts_ms (long ts_ms)
 Get weekday from millisecond timestamp.
 
int time_shield::day_of_week_ms (long ts_ms)
 Alias for get_weekday_from_ts_ms.
 
long time_shield::start_of_year (long ts)
 Get the start of the year for a timestamp.
 
long time_shield::end_of_year (long ts)
 Get the end of the year for a timestamp.
 
long time_shield::year_start (long ts)
 Alias for start_of_year.
 
long time_shield::year_begin (long ts)
 Alias for start_of_year.
 
long time_shield::start_of_year_ms (long ts_ms)
 Get the start of the year in milliseconds.
 
long time_shield::year_start_ms (long ts_ms)
 Alias for start_of_year_ms.
 
long time_shield::year_begin_ms (long ts_ms)
 Alias for start_of_year_ms.
 
long time_shield::start_of_year_date (long year)
 Get the timestamp for the start of the specified year.
 
long time_shield::year_start_date (long year)
 Alias for start_of_year_date.
 
long time_shield::year_begin_date (long year)
 Alias for start_of_year_date.
 
long time_shield::start_of_year_date_ms (long year)
 Get the timestamp in milliseconds for the start of the specified year.
 
long time_shield::year_start_date_ms (long year)
 Alias for start_of_year_date_ms.
 
long time_shield::year_begin_date_ms (long year)
 Alias for start_of_year_date_ms.
 
long time_shield::end_of_year_ms (long ts_ms)
 Get the end of the year in milliseconds.
 
long time_shield::year_end_ms (long ts_ms)
 Alias for end_of_year_ms.
 
int time_shield::day_of_year (long ts)
 Get the day of the year.
 
Month time_shield::month_of_year (long ts)
 Get the month of the year.
 
int time_shield::day_of_month (long ts)
 Get the day of the month.
 
int time_shield::num_days_in_month (long year, int month)
 Get the number of days in a month.
 
int time_shield::days_in_month (long year, int month)
 Alias for num_days_in_month.
 
int time_shield::num_days_in_month_ts (long ts)
 Get the number of days in the month of a timestamp.
 
int time_shield::num_days_in_month (long ts)
 Alias for num_days_in_month_ts.
 
int time_shield::days_in_month (long ts)
 Alias for num_days_in_month_ts.
 
int time_shield::num_days_in_year (long year)
 Get number of days in a year.
 
int time_shield::days_in_year (long year)
 Alias for num_days_in_year.
 
int time_shield::num_days_in_year_ts (long ts)
 Get number of days in the year of the timestamp.
 
int time_shield::days_in_year_ts (long ts)
 Alias for num_days_in_year_ts.
 
long time_shield::start_of_month (long ts)
 Get the timestamp at the start of the month.
 
long time_shield::month_begin (long ts)
 Alias for start_of_month.
 
long time_shield::end_of_month (long ts)
 Get the timestamp at the end of the month.
 
long time_shield::last_day_of_month (long ts)
 Alias for end_of_month.
 
long time_shield::last_sunday_of_month (long ts)
 Get the timestamp of the last Sunday of the month.
 
long time_shield::final_sunday_of_month (long ts)
 Alias for last_sunday_of_month.
 
int time_shield::last_sunday_month_day (long year, int month)
 Get the day of the last Sunday for the given month and year.
 
int time_shield::final_sunday_month_day (long year, int month)
 Alias for last_sunday_month_day.
 
long time_shield::start_of_hour (long ts)
 Get the start of the hour for a timestamp.
 
long time_shield::hour_begin (long ts)
 Alias for start_of_hour.
 
long time_shield::start_of_hour_sec (long ts_ms)
 Get the start of the hour in seconds from milliseconds timestamp.
 
long time_shield::hour_begin_sec (long ts_ms)
 Alias for start_of_hour_sec.
 
long time_shield::start_of_hour_ms (long ts_ms)
 Get the start of the hour for a millisecond timestamp.
 
long time_shield::hour_begin_ms (long ts_ms)
 Alias for start_of_hour_ms.
 
long time_shield::end_of_hour (long ts)
 Get the end of the hour for a timestamp.
 
long time_shield::finish_of_hour (long ts)
 Alias for end_of_hour.
 
long time_shield::end_of_hour_sec (long ts_ms)
 Get the end of the hour in seconds from milliseconds timestamp.
 
long time_shield::finish_of_hour_sec (long ts_ms)
 Alias for end_of_hour_sec.
 
long time_shield::end_of_hour_ms (long ts_ms)
 Get the end of the hour for a millisecond timestamp.
 
long time_shield::finish_of_hour_ms (long ts_ms)
 Alias for end_of_hour_ms.
 
int time_shield::hour_of_day (long ts)
 Get the hour of the day.
 
int time_shield::hour_in_day (long ts)
 Alias for hour_of_day.
 
long time_shield::start_of_week (long ts)
 Get the start of the week (Sunday).
 
long time_shield::week_begin (long ts)
 Alias for start_of_week.
 
long time_shield::end_of_week (long ts)
 Get the end of the week (Saturday end).
 
long time_shield::finish_of_week (long ts)
 Alias for end_of_week.
 
long time_shield::start_of_saturday (long ts)
 Get the start of Saturday for the week of the timestamp.
 
long time_shield::saturday_begin (long ts)
 Alias for start_of_saturday.
 
long time_shield::start_of_min (long ts)
 Get the start of the minute for a timestamp.
 
long time_shield::min_begin (long ts)
 Alias for start_of_min.
 
long time_shield::end_of_min (long ts)
 Get the end of the minute for a timestamp.
 
long time_shield::finish_of_min (long ts)
 Alias for end_of_min.
 
int time_shield::min_of_day (long ts)
 Get the minute of the day.
 
int time_shield::min_of_hour (long ts)
 Get the minute of the hour.
 
int time_shield::min_in_hour (long ts)
 Alias for min_of_hour.
 
long time_shield::start_of_period (int p, long ts)
 Get the start of a period.
 
long time_shield::end_of_period (int p, long ts)
 Get the end of a period.
 
long time_shield::get_unix_day (long ts)
 Get UNIX day from timestamp.
 
long time_shield::unix_day (long ts)
 Alias for get_unix_day.
 
long time_shield::get_unixday (long ts)
 Alias for get_unix_day.
 
long time_shield::unixday (long ts)
 Alias for get_unix_day.
 
long time_shield::uday (long ts)
 Alias for get_unix_day.
 
int time_shield::get_days_difference (long start, long stop)
 Get number of days between two timestamps.
 
int time_shield::get_days (long start, long stop)
 Alias for get_days_difference.
 
int time_shield::days (long start, long stop)
 Alias for get_days_difference.
 
long time_shield::get_unix_day_ms (long ts_ms)
 Get UNIX day from milliseconds timestamp.
 
long time_shield::unix_day_ms (long ts_ms)
 Alias for get_unix_day_ms.
 
long time_shield::get_unixday_ms (long ts_ms)
 Alias for get_unix_day_ms.
 
long time_shield::unixday_ms (long ts_ms)
 Alias for get_unix_day_ms.
 
long time_shield::uday_ms (long ts_ms)
 Alias for get_unix_day_ms.
 
long time_shield::unix_day_to_timestamp (long uday)
 Convert UNIX day to timestamp in seconds.
 
long time_shield::unix_day_to_ts (long uday)
 Alias for unix_day_to_timestamp.
 
long time_shield::unixday_to_ts (long uday)
 Alias for unix_day_to_timestamp.
 
long time_shield::uday_to_ts (long uday)
 Alias for unix_day_to_timestamp.
 
long time_shield::start_of_day_from_unix_day (long uday)
 Alias for unix_day_to_timestamp.
 
long time_shield::unix_day_to_timestamp_ms (long uday)
 Convert UNIX day to timestamp in milliseconds.
 
long time_shield::unix_day_to_ts_ms (long uday)
 Alias for unix_day_to_timestamp_ms.
 
long time_shield::unixday_to_ts_ms (long uday)
 Alias for unix_day_to_timestamp_ms.
 
long time_shield::uday_to_ts_ms (long uday)
 Alias for unix_day_to_timestamp_ms.
 
long time_shield::start_of_day_from_unix_day_ms (long uday)
 Alias for unix_day_to_timestamp_ms.
 
long time_shield::end_of_day_from_unix_day (long uday)
 Get end of day timestamp from UNIX day.
 
long time_shield::end_of_day_from_unix_day_ms (long uday)
 Get end of day timestamp in ms from UNIX day.
 
long time_shield::eod_from_unix_day (long uday)
 Alias for end_of_day_from_unix_day.
 
long time_shield::eod_from_unix_day_ms (long uday)
 Alias for end_of_day_from_unix_day_ms.
 
long time_shield::start_of_next_day_from_unix_day (long uday)
 Get start of next day timestamp from UNIX day.
 
long time_shield::start_of_next_day_from_unix_day_ms (long uday)
 Get start of next day timestamp in ms from UNIX day.
 
long time_shield::next_day_unix_day (long uday)
 Alias for start_of_next_day_from_unix_day.
 
long time_shield::next_day_unixday (long uday)
 Alias for start_of_next_day_from_unix_day.
 
long time_shield::next_day_unix_day_ms (long uday)
 Alias for start_of_next_day_from_unix_day_ms.
 
long time_shield::next_day_unixday_ms (long uday)
 Alias for start_of_next_day_from_unix_day_ms.
 
long time_shield::next_day_from_unix_day (long uday)
 Alias for start_of_next_day_from_unix_day.
 
long time_shield::get_unix_min (long ts)
 Get UNIX minute from timestamp.
 
long time_shield::unix_min (long ts)
 Alias for get_unix_min.
 
long time_shield::to_unix_min (long ts)
 Alias for get_unix_min.
 
long time_shield::umin (long ts)
 Alias for get_unix_min.
 
int time_shield::sec_of_day (long ts)
 Get second of day from timestamp.
 
int time_shield::sec_of_day_ms (long ts_ms)
 Get second of day from milliseconds timestamp.
 
int time_shield::sec_of_day (int hour, int min, int sec)
 Get second of day from hours, minutes and seconds.
 
TimeZoneStruct time_shield::to_time_zone (int offset)
 Convert an integer offset to a TimeZoneStruct.
 
TimeZoneStruct time_shield::to_tz_struct (int offset)
 Alias for to_time_zone.
 

Detailed Description

Header with helper functions for converting between different time representations in MQL5.

This file contains utility functions to convert timestamps between seconds, milliseconds and minutes, as well as helpers for obtaining sub-second parts and working with date structures.

Definition in file time_conversions.mqh.

Macro Definition Documentation

◆ __TIME_SHIELD_TIME_CONVERSIONS_MQH__

#define __TIME_SHIELD_TIME_CONVERSIONS_MQH__

Definition at line 8 of file time_conversions.mqh.