NAME

DateTime::Fiscal::Year - Calculate the day or week of the Fiscal Year with an arbitrary start date

SYNOPSIS

  use DateTime;
  use DateTime::Fiscal::Year;

  my $fs = DateTime->new(year=>2003, month=>02, day=>01);
  my $td = DateTime->new(year=>2003, month=>03, day=>01);

  my $df = DateTime::Fiscal::Year->new(fiscal_start => $fs, target_date => $td);

  $df->day_of_fiscal_year();

	or

  $df->week_of_fiscal_year();

DESCRIPTION

This module allows you to calulate the day number or week number of a date, given a start date and a target date. This is often needed in business, where the fiscal year begins and ends on different days than the calendar year. This module is based on the Gregorian calendar. Using other DT calendar objects will return results, but the behavior is unpredicatable for calendars that have more than 365 or 366 days.

USAGE

This module implements the following methods:

  • new(fiscal_start => $fs, target_date => $td)

    Given a valid DateTime object as the fiscal start date and another as the target date, this method returns a new DateTime::Fiscal::Year object. The arguments are "fiscal_start" - this is the first day of the fiscal year; and "target_date" - this is the date you want to know the day or week number of, in relation to the fiscal_start date.

  • day_of_fiscal_year()

    Returns the day of the fiscal year as calculated from the fiscal_start date and target date of a valid DateTime::Fiscal::Year object.

    my $fs = DateTime->new(year=>2003, month=>02, day=>01);
    my $td = DateTime->new(year=>2003, month=>03, day=>01);
    
    my $df = DateTime::Fiscal::Year->new(fiscal_start => $fs, target_date => $td);
    
    my $dofy = $df->day_of_fiscal_year();

    Day of fiscal year ($dofy) is 29. If given the same day for start and target, the value is 1.

  • week_of_fiscal_year()

    Returns the week of the fiscal year as calculated from the fiscal_start date and target date of a valid DateTime::Fiscal::Year object.

    my $fs = DateTime->new(year=>2003, month=>02, day=>01);
    my $td = DateTime->new(year=>2003, month=>03, day=>01);
    
    my $df = DateTime::Fiscal::Year->new(fiscal_start => $fs, target_date => $td);
    
    my $wofy = $df->week_of_fiscal_year();

    Week of fiscal year ($wofy) is 5. There is not a week 0 or 53. This module was built to assist in financial applications not to satisfy the ISO.

  • period_of_fiscal_year()

    Returns the period of the fiscal year.

  • quarter_of_fiscal_year()

    Returns the quater of the fiscal year.

SUPPORT

Support for this module can be obtained from:

datetime@perl.org

AUTHOR

Jesse Shy <jshy@pona.net>, thanks to Dave Rolsky for being brave enough to start the perl date-time project. I hope this helps anyone who has to build programs that due financial date calculations.

COPYRIGHT

Copyright (c) 2003 Jesse Shy. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

The full text of the license can be found in the LICENSE file included with this module.

SEE ALSO

DateTime.pm, datetime@perl.org mailing list

http://datetime.perl.org