|
Functions by Category Functions by Alphabetical list
This function can be called in two different ways, in scalar and list context. In scalar context this function returns the number of the week of the year for the current bar, or from the passed in datetime. In list context this function returns the number for the week and the year for the current bar, or from the passed in datetime. In many cases the last few days of the year are actually in week one of the following year. Depending how you are using this function, this may, or may not be an issue for you. For example, look at the following code: my $dt=20031230000000; #30-Dec-2003
my $week=WeekOfYear($dt);
In this case, the variable week will contain 1, because 30-Dec-2003 is in the first week of 2004. my $dt=20031230000000; #30-Dec-2004
my ($week,$year)=WeekOfYear($dt);
In this case, the variable week will also contain 1, and year will contain 2004. Examples (Scalar context): WeekOfYear; #returns week for the current bar
WeekOfYear(Ago(DateTime,15)); #returns the week for the bar 15 bars ago
Examples (List context): #returns the week and year for the current bar
my ($week,$year)=WeekOfYear;
#returns the week and year for the bar 15 bars ago
my ($week,$year)=WeekOfYear(Ago(DateTime,15));
Note: Because this function has an optional parameter, it is sometimes necessary to specify the parenthesis on the function when passing no parameters, for example use WeekOfYear() instead of WeekOfYear. Related functions: DateTime , Time , Second , Minute , Hour , Month , Year , DayOfWeek , DayOfMonth , DayOfYear , NewHour , NewDay , NewWeek , NewMonth , NewYear , Monday , Tuesday , Wednesday , Thursday , Friday , FormatDateTime , ValidateDateTime , AddDeltaDHMS , AddDeltaYM , DeltaDateTime
|