NAME

Month::Simple - Simple month-based date arithmetics

VERSION

Version 0.03

SYNOPSIS

use Month::Simple;

my $month = Month::Simple->new();
my $prev  = $month->prev;
my $stamp = $prev->first_second;
my $in_yr = $month->delta(12);

METHODS

new

Month::Simple->new();             # current month, using $^T as base
Month::Simple->new('2011-01');
Month::Simple->new('2011-01-02'); # day is ignored
Month::Simple->new(timestamp => time); # extract month from UNIX timestamp

Creates a new Month::Simple object. If no argument is provided, the current month (based on the startup of the script, i.e. based on $^T) is returned.

The argument can be a date in format YYYY-MM, YYYYMM, YYYY-MM-DD or a Date::Simple object. Days are ignored.

prev

Returns a new Month::Simple object for the month before the invocant month.

next

Returns a new Month::Simple object for the month after the invocant month.

delta(N)

Returns a new Month::Simple object. For positive N, it goes forward N months, and backwards for negative N.

first_second

Returns a UNIX timestamp for the first second of the month.

last_second

Returns a UNIX timestamp for the last second of the month.

month

Returns the month as an integer between 1 and 12.

say Month::Simple->new(201602)->month;      2

year

Returns the year as an integer.

say Month::Simple->new(201602)->year;       2016

first_day

Returns a Date::Simple object for the first day of the month.

State of this module

This module has been in production usage for quite some time, and is considered complete in the sense that no more features are planned.

AUTHOR

Moritz Lenz, <moritz.lenz at noris.de> for the noris network AG.

BUGS

Please report any bugs or feature requests to bug-month-simple at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Month-Simple. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

SUPPORT

You can find documentation for this module with the perldoc command.

perldoc Month::Simple

You can also look for information at:

LICENSE AND COPYRIGHT

Copyright 2013 Moritz Lenz.

This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.

See http://dev.perl.org/licenses/ for more information.