GT::DateTime - Manage TimeFrames and provides date/time helper functions


This module exports all the variable describing the available "periods" commonly used for trading : $PERIOD_TICK $PERIOD_1MIN, $PERIOD_5MIN, $PERIOD_10MIN, $PERIOD_15MIN, $PERIOD_30MIN, $HOUR, $PERIOD_2HOUR, $PERIOD_3HOUR, $PERIOD_4HOUR, $DAY, $WEEK, $MONTH, $YEAR.

The timeframes are represented by those variables which are only numbers. You can compare those numbers to know which timeframe is smaller or which one is bigger.

It also provides several functions to manipulate dates and periods. Those functions use modules GT::DateTime::* to do the actual work depending on the selected timeframe.

Functions provided by submodules

map_date_to_time($date) is a function returning a time (ie a number of seconds since 1970) representing that date in the history. It is usually corresponding to the first second of the given period.

map_time_to_date($time) is the complementary function. It will return a date describing the period that includes the given time.


GT::DateTime::map_date_to_time($timeframe, $date)
GT::DateTime::map_time_to_date($timeframe, $time)

Those are the generic functions used to convert a date into a time and vice versa.

GT::DateTime::convert_date($date, $orig_timeframe, $dest_timeframe)

This function does convert the given date from the $orig_timeframe in a date of the $dest_timeframe. Take care that the destination timeframe must be bigger than the original timeframe.


Returns the list of timeframes that are managed by the DateTime framework.


Return the official name of the corresponding timeframe.


Returns the timeframe associated to the given name.

GT::DateTime::timeframe_ratio($first, $second)

Returns how many times the second timeframe fits in the first one.