Venus::Date

Date Class

Date Class for Perl 5

method: add method: add_days method: add_hours method: add_hms method: add_mdy method: add_minutes method: add_months method: add_seconds method: add_years method: epoch method: explain method: format method: hms method: iso8601 method: mdy method: new method: parse method: reset method: restart method: restart_day method: restart_hour method: restart_minute method: restart_month method: restart_quarter method: restart_second method: restart_year method: rfc1123 method: rfc3339 method: rfc7231 method: rfc822 method: set method: set_hms method: set_mdy method: string method: sub method: sub_days method: sub_hours method: sub_hms method: sub_mdy method: sub_minutes method: sub_months method: sub_seconds method: sub_years

package main;

use Venus::Date;

my $date = Venus::Date->new(570672000);

# $date->string;

# '1988-02-01T00:00:00Z'

This package provides methods for formatting, parsing, and manipulating date and time data.

Venus::Kind::Utility

Venus::Role::Buildable Venus::Role::Explainable

day: rw, opt, Int month: rw, opt, Int year: rw, opt, Int hour: rw, opt, Int minute: rw, opt, Int second: rw, opt, Int

The add method increments the date and time attributes specified.

add(hashref $data) (Venus::Date)

{ since => '0.01', }

=example-1 add

# given: synopsis;

$date = $date->add({
  days => 1,
  months => 1,
  years => 1,
});

# $date->string; # 1989-03-03T16:17:54Z

# $date->epoch; # 604945074

The add_days method increments the day attribute.

add_days(number $days) (any)

{ since => '0.01', }

=example-1 add_days

# given: synopsis;

$date = $date->add_days(1);

# $date->string; # 1988-02-02T00:00:00Z

# $date->epoch; # 570758400

The add_hours method increments the hour attribute.

add_hours(number $hours) (any)

{ since => '0.01', }

=example-1 add_hours

# given: synopsis;

$date = $date->add_hours(1);

# $date->string; # 1988-02-01T01:00:00Z

# $date->epoch; # 570675600

The add_hms method increments the hour, minute, and second attributes.

add_hms(maybe[number] $hours, maybe[number] $minutes, maybe[number] $seconds) (Venus::Date)

{ since => '0.01', }

=example-1 add_hms

# given: synopsis;

$date = $date->add_hms(1, 0, 0);

# $date->string; # 1988-02-01T01:00:00Z

# $date->epoch; # 570675600

The add_mdy method increments the month, day, and years attributes.

add_mdy(maybe[number] $months, maybe[number] $days, maybe[number] $years) (Venus::Date)

{ since => '0.01', }

=example-1 add_mdy

# given: synopsis;

$date = $date->add_mdy(1, 0, 0);

# $date->string; # 1988-03-02T10:29:04Z

# $date->epoch; # 573301744

The add_minutes method increments the minute attribute.

add_minutes(number $minutes) (Venus::Date)

{ since => '0.01', }

=example-1 add_minutes

# given: synopsis;

$date = $date->add_minutes(1);

# $date->string; # 1988-02-01T00:01:00Z

# $date->epoch; # 570672060

The add_months method increments the month attribute.

add_months(number $months) (Venus::Date)

{ since => '0.01', }

=example-1 add_months

# given: synopsis;

$date = $date->add_months(1);

# $date->string; # 1988-03-02T10:29:04Z

# $date->epoch; # 573301744

The add_seconds method increments the second attribute.

add_seconds(number $seconds) (Venus::Date)

{ since => '0.01', }

=example-1 add_seconds

# given: synopsis;

$date = $date->add_seconds(1);

# $date->string; # 1988-02-01T00:00:01Z

# $date->epoch; # 570672001

The add_years method increments the year attribute.

add_years(number $years) (Venus::Date)

{ since => '0.01', }

=example-1 add_years

# given: synopsis;

$date = $date->add_years(1);

# $date->string; # 1989-01-31T05:48:50Z

# $date->epoch; # 602228930

The epoch method returns the epoch.

epoch() (number)

{ since => '0.01', }

=example-1 epoch

# given: synopsis;

my $epoch = $date->epoch;

# 570672000

The explain method returns the epoch and is used in stringification operations.

explain() (number)

{ since => '0.01', }

=example-1 explain

# given: synopsis;

my $explain = $date->explain;

# 570672000

The format method returns the formatted date and time string. See strftime for formatting rules.

format(string $format) (string)

{ since => '0.01', }

=example-1 format

# given: synopsis;

my $format = $date->format('%A, %B %e, %Y');

# Monday, February  1, 1988

The hms method returns the time formatted as hh:mm:ss.

hms() (string)

{ since => '0.01', }

=example-1 hms

# given: synopsis;

my $hms = $date->hms;

# 00:00:00

The iso8601 method returns the date and time formatted as an ISO8601 string.

iso8601() (string)

{ since => '0.01', }

=example-1 iso8601

# given: synopsis;

my $iso8601 = $date->iso8601;

# 1988-02-01T00:00:00

The mdy method returns the date formatted as mm-dd-yyyy.

mdy() (string)

{ since => '0.01', }

=example-1 mdy

# given: synopsis;

my $mdy = $date->mdy;

# 02-01-1988

The new method constructs an instance of the package.

new(any @args) (Venus::Date)

{ since => '4.15', }

The parse method resets and returns a date object based on the parsed time provided. See strptime for parsing rules.

parse(any @data) (Venus::Date)

{ since => '0.01', }

=example-1 parse

# given: synopsis;

$date = $date->parse('Monday, February  1, 1988', '%A, %B %e, %Y');

# $date->string; # 1988-02-01T00:00:00Z

# $date->epoch; # 570672000

The reset method resets all attributes to correspond with the epoch provided.

reset(number $time) (Venus::Date)

{ since => '0.01', }

=example-1 reset

# given: synopsis;

$date = $date->reset(631152000);

# $date->string; # 1990-01-01T00:00:00Z

# $date->epoch; # 631152000

The restart method truncates the date and time to the specified unit of time, e.g. year, quarter, month, day, hour, minute, second.

restart(string $interval) (Venus::Date)

{ since => '0.01', }

=example-1 restart

# given: synopsis;

$date = $date->restart('year');

# $date->string; # 1988-01-01T00:00:00Z

# $date->epoch; # 567993600

The restart_day method truncates the date and time to the day.

restart_day() (Venus::Date)

{ since => '1.02', }

=example-1 restart_day

# given: synopsis;

$date = $date->restart_day;

# $date->string; # 1988-02-01T00:00:00Z

# $date->epoch; # 570672000

The restart_hour method truncates the date and time to the hour.

restart_hour() (Venus::Date)

{ since => '1.02', }

=example-1 restart_hour

# given: synopsis;

$date = $date->restart_hour;

# $date->string; # 1988-02-01T00:00:00Z

# $date->epoch; # 570672000

The restart_minute method truncates the date and time to the minute.

restart_minute() (Venus::Date)

{ since => '1.02', }

=example-1 restart_minute

# given: synopsis;

$date = $date->restart_minute;

# $date->string; # 1988-02-01T00:00:00Z

# $date->epoch; # 570672000

The restart_month method truncates the date and time to the month.

restart_month() (Venus::Date)

{ since => '1.02', }

=example-1 restart_month

# given: synopsis;

$date = $date->restart_month;

# $date->string; # 1988-02-01T00:00:00Z

# $date->epoch; # 570672000

The restart_quarter method truncates the date and time to the quarter.

restart_quarter() (Venus::Date)

{ since => '1.02', }

=example-1 restart_quarter

# given: synopsis;

$date = $date->restart_quarter;

# $date->string; # 1988-01-01T00:00:00Z

# $date->epoch; # 567993600

The restart_second method truncates the date and time to the second.

restart_second() (Venus::Date)

{ since => '1.02', }

=example-1 restart_second

# given: synopsis;

$date = $date->restart_second;

# $date->string; # 1988-02-01T00:00:00Z

# $date->epoch; # 570672000

The restart_year method truncates the date and time to the year.

restart_year() (Venus::Date)

{ since => '1.02', }

=example-1 restart_year

# given: synopsis;

$date = $date->restart_year;

# $date->string; # 1988-01-01T00:00:00Z

# $date->epoch; # 567993600

The rfc822 method returns the date and time formatted as an RFC822 string.

rfc822() (string)

{ since => '0.01', }

=example-1 rfc822

# given: synopsis;

my $rfc822 = $date->rfc822;

# Mon, 01 Feb 1988 00:00:00 +0000

The rfc1123 method returns the date and time formatted as an RFC1123 string.

rfc1123() (string)

{ since => '0.01', }

=example-1 rfc1123

# given: synopsis;

my $rfc1123 = $date->rfc1123;

# Mon, 01 Feb 1988 00:00:00 GMT

The rfc3339 method returns the date and time formatted as an RFC3339 string.

rfc3339() (string)

{ since => '0.01', }

=example-1 rfc3339

# given: synopsis;

my $rfc3339 = $date->rfc3339;

# 1988-02-01T00:00:00Z

The rfc7231 method returns the date and time formatted as an RFC7231 string.

rfc7231() (string)

{ since => '0.01', }

=example-1 rfc7231

# given: synopsis;

my $rfc7231 = $date->rfc7231;

# Mon, 01 Feb 1988 00:00:00 UTC

The set method sets the date and time attributes specified.

set(hashref $data) (Venus::Date)

{ since => '0.01', }

=example-1 set

# given: synopsis;

$date = $date->set({
  day => 1,
  month => 1,
  year => 2000,
});

# $date->string; # 2000-01-01T00:00:00Z

# $date->epoch; # 946684800

The set_hms method sets the hour, minute, and second attributes.

set_hms(maybe[number] $hours, maybe[number] $minutes, maybe[number] $seconds) (Venus::Date)

{ since => '0.01', }

=example-1 set_hms

# given: synopsis;

$date = $date->set_hms(1, 0, 0);

# $date->string; # 1988-02-01T01:00:00Z

# $date->epoch; # 570675600

The set_mdy method sets the month, day, and year attributes.

set_mdy(maybe[number] $months, maybe[number] $days, maybe[number] $years) (Venus::Date)

{ since => '0.01', }

=example-1 set_mdy

# given: synopsis;

$date = $date->set_mdy(4, 30, 1990);

# $date->string; # 1990-04-30T00:00:00Z

# $date->epoch; # 641433600

The string method returns a date and time string, and is an alias for "rfc3339".

string() (string)

{ since => '0.01', }

=example-1 string

# given: synopsis;

my $string = $date->string;

# 1988-02-01T00:00:00Z

The sub method method decrements the date and time attributes specified.

sub(hashref $data) (Venus::Date)

{ since => '0.01', }

=example-1 sub

# given: synopsis;

$date = $date->sub({
  days => 1,
  months => 1,
  years => 1,
});

# $date->string; # 1986-12-31T07:42:06Z

# $date->epoch; # 536398926

The sub_days method decrements the day attribute.

sub_days(number $days) (Venus::Date)

{ since => '0.01', }

=example-1 sub_days

# given: synopsis;

$date = $date->sub_days(1);

# $date->string; # 1988-01-31T00:00:00Z

# $date->epoch; # 570585600

The sub_hours method decrements the hour attribute.

sub_hours(number $hours) (any)

{ since => '0.01', }

=example-1 sub_hours

# given: synopsis;

$date = $date->sub_hours(1);

# $date->string; # 1988-01-31T23:00:00Z

# $date->epoch; # 570668400

The sub_hms method decrements the hour, minute, and second attributes.

sub_hms(maybe[number] $hours, maybe[number] $minutes, maybe[number] $seconds) (Venus::Date)

{ since => '0.01', }

=example-1 sub_hms

# given: synopsis;

$date = $date->sub_hms(1, 0, 0);

# $date->string; # 1988-01-31T23:00:00Z

# $date->epoch; # 570668400

The sub_mdy method decrements the month, day, and year attributes.

sub_mdy(maybe[number] $months, maybe[number] $days, maybe[number] $years) (Venus::Date)

{ since => '0.01', }

=example-1 sub_mdy

# given: synopsis;

$date = $date->sub_mdy(1, 1, 1);

# $date->string; # 1986-12-31T07:42:06Z

# $date->epoch; # 536398926

The sub_minutes method decrements the minute attribute.

sub_minutes(number $minutes) (Venus::Date)

{ since => '0.01', }

=example-1 sub_minutes

# given: synopsis;

$date = $date->sub_minutes(1);

# $date->string; # 1988-01-31T23:59:00Z

# $date->epoch; # 570671940

The sub_months method decrements the month attribute.

sub_months(number $months) (Venus::Date)

{ since => '0.01', }

=example-1 sub_months

# given: synopsis;

$date = $date->sub_months(1);

# $date->string; # 1988-01-01T13:30:56Z

# $date->epoch; # 568042256

The sub_seconds method decrements the second attribute.

sub_seconds(number $seconds) (Venus::Date)

{ since => '0.01', }

=example-1 sub_seconds

# given: synopsis;

$date = $date->sub_seconds(1);

# $date->string; # 1988-01-31T23:59:59Z

# $date->epoch; # 570671999

The sub_years method decrements the years attribute.

sub_years(number $years) (Venus::Date)

{ since => '0.01', }

=example-1 sub_years

# given: synopsis;

$date = $date->sub_years(1);

# $date->string; # 1987-01-31T18:11:10Z

# $date->epoch; # 539115070

This package overloads the != operator.

This package overloads the + operator.

This package overloads the - operator.

This package overloads the 0+ operator.

This package overloads the < operator.

This package overloads the <= operator.

This package overloads the == operator.

This package overloads the > operator.

This package overloads the >= operator.

This package overloads the eq operator.

This package overloads the ne operator.

This package overloads the "" operator.

This package overloads the ~~ operator.

t/Venus.t: present: authors t/Venus.t: present: license

211 POD Errors

The following errors were encountered while parsing the POD:

Around line 14:

Unknown directive: =name

Around line 22:

Unknown directive: =tagline

Around line 30:

Unknown directive: =abstract

Around line 38:

Unknown directive: =includes

Around line 88:

Unknown directive: =synopsis

Around line 109:

Unknown directive: =description

Around line 118:

Unknown directive: =inherits

Around line 126:

Unknown directive: =integrates

Around line 135:

Unknown directive: =attributes

Around line 148:

Unknown directive: =method

Around line 152:

Unknown directive: =signature

Around line 156:

Unknown directive: =metadata

Around line 202:

=cut found outside a pod block. Skipping to next block.

Around line 213:

Unknown directive: =method

Around line 217:

Unknown directive: =signature

Around line 221:

Unknown directive: =metadata

Around line 257:

=cut found outside a pod block. Skipping to next block.

Around line 277:

=cut found outside a pod block. Skipping to next block.

Around line 287:

Unknown directive: =method

Around line 291:

Unknown directive: =signature

Around line 295:

Unknown directive: =metadata

Around line 331:

=cut found outside a pod block. Skipping to next block.

Around line 351:

=cut found outside a pod block. Skipping to next block.

Around line 361:

Unknown directive: =method

Around line 365:

Unknown directive: =signature

Around line 369:

Unknown directive: =metadata

Around line 405:

=cut found outside a pod block. Skipping to next block.

Around line 425:

=cut found outside a pod block. Skipping to next block.

Around line 435:

Unknown directive: =method

Around line 439:

Unknown directive: =signature

Around line 443:

Unknown directive: =metadata

Around line 479:

=cut found outside a pod block. Skipping to next block.

Around line 499:

=cut found outside a pod block. Skipping to next block.

Around line 509:

Unknown directive: =method

Around line 513:

Unknown directive: =signature

Around line 517:

Unknown directive: =metadata

Around line 553:

=cut found outside a pod block. Skipping to next block.

Around line 573:

=cut found outside a pod block. Skipping to next block.

Around line 583:

Unknown directive: =method

Around line 587:

Unknown directive: =signature

Around line 591:

Unknown directive: =metadata

Around line 627:

=cut found outside a pod block. Skipping to next block.

Around line 647:

=cut found outside a pod block. Skipping to next block.

Around line 657:

Unknown directive: =method

Around line 661:

Unknown directive: =signature

Around line 665:

Unknown directive: =metadata

Around line 701:

=cut found outside a pod block. Skipping to next block.

Around line 721:

=cut found outside a pod block. Skipping to next block.

Around line 731:

Unknown directive: =method

Around line 735:

Unknown directive: =signature

Around line 739:

Unknown directive: =metadata

Around line 775:

=cut found outside a pod block. Skipping to next block.

Around line 795:

=cut found outside a pod block. Skipping to next block.

Around line 805:

Unknown directive: =method

Around line 809:

Unknown directive: =signature

Around line 813:

Unknown directive: =metadata

Around line 837:

Unknown directive: =method

Around line 841:

Unknown directive: =signature

Around line 845:

Unknown directive: =metadata

Around line 869:

Unknown directive: =method

Around line 875:

Unknown directive: =signature

Around line 879:

Unknown directive: =metadata

Around line 912:

=cut found outside a pod block. Skipping to next block.

Around line 923:

Unknown directive: =method

Around line 927:

Unknown directive: =signature

Around line 931:

Unknown directive: =metadata

Around line 955:

Unknown directive: =method

Around line 959:

Unknown directive: =signature

Around line 963:

Unknown directive: =metadata

Around line 987:

Unknown directive: =method

Around line 991:

Unknown directive: =signature

Around line 995:

Unknown directive: =metadata

Around line 1019:

Unknown directive: =method

Around line 1023:

Unknown directive: =signature

Around line 1027:

Unknown directive: =metadata

Around line 1045:

=cut found outside a pod block. Skipping to next block.

Around line 1065:

=cut found outside a pod block. Skipping to next block.

Around line 1092:

=cut found outside a pod block. Skipping to next block.

Around line 1103:

Unknown directive: =method

Around line 1109:

Unknown directive: =signature

Around line 1113:

Unknown directive: =metadata

Around line 1139:

Unknown directive: =method

Around line 1143:

Unknown directive: =signature

Around line 1147:

Unknown directive: =metadata

Around line 1173:

Unknown directive: =method

Around line 1178:

Unknown directive: =signature

Around line 1182:

Unknown directive: =metadata

Around line 1222:

=cut found outside a pod block. Skipping to next block.

Around line 1246:

=cut found outside a pod block. Skipping to next block.

Around line 1260:

Unknown directive: =method

Around line 1264:

Unknown directive: =signature

Around line 1268:

Unknown directive: =metadata

Around line 1298:

Unknown directive: =method

Around line 1302:

Unknown directive: =signature

Around line 1306:

Unknown directive: =metadata

Around line 1336:

Unknown directive: =method

Around line 1340:

Unknown directive: =signature

Around line 1344:

Unknown directive: =metadata

Around line 1374:

Unknown directive: =method

Around line 1378:

Unknown directive: =signature

Around line 1382:

Unknown directive: =metadata

Around line 1412:

Unknown directive: =method

Around line 1416:

Unknown directive: =signature

Around line 1420:

Unknown directive: =metadata

Around line 1450:

Unknown directive: =method

Around line 1454:

Unknown directive: =signature

Around line 1458:

Unknown directive: =metadata

Around line 1488:

Unknown directive: =method

Around line 1492:

Unknown directive: =signature

Around line 1496:

Unknown directive: =metadata

Around line 1526:

Unknown directive: =method

Around line 1530:

Unknown directive: =signature

Around line 1534:

Unknown directive: =metadata

Around line 1560:

Unknown directive: =method

Around line 1564:

Unknown directive: =signature

Around line 1568:

Unknown directive: =metadata

Around line 1593:

Unknown directive: =method

Around line 1597:

Unknown directive: =signature

Around line 1601:

Unknown directive: =metadata

Around line 1625:

Unknown directive: =method

Around line 1629:

Unknown directive: =signature

Around line 1633:

Unknown directive: =metadata

Around line 1657:

Unknown directive: =method

Around line 1661:

Unknown directive: =signature

Around line 1665:

Unknown directive: =metadata

Around line 1708:

=cut found outside a pod block. Skipping to next block.

Around line 1732:

=cut found outside a pod block. Skipping to next block.

Around line 1742:

Unknown directive: =method

Around line 1746:

Unknown directive: =signature

Around line 1750:

Unknown directive: =metadata

Around line 1786:

=cut found outside a pod block. Skipping to next block.

Around line 1806:

=cut found outside a pod block. Skipping to next block.

Around line 1816:

Unknown directive: =method

Around line 1821:

Unknown directive: =signature

Around line 1825:

Unknown directive: =metadata

Around line 1861:

=cut found outside a pod block. Skipping to next block.

Around line 1881:

=cut found outside a pod block. Skipping to next block.

Around line 1891:

Unknown directive: =method

Around line 1896:

Unknown directive: =signature

Around line 1900:

Unknown directive: =metadata

Around line 1924:

Unknown directive: =method

Around line 1928:

Unknown directive: =signature

Around line 1932:

Unknown directive: =metadata

Around line 1976:

=cut found outside a pod block. Skipping to next block.

Around line 1986:

Unknown directive: =method

Around line 1990:

Unknown directive: =signature

Around line 1994:

Unknown directive: =metadata

Around line 2030:

=cut found outside a pod block. Skipping to next block.

Around line 2050:

=cut found outside a pod block. Skipping to next block.

Around line 2060:

Unknown directive: =method

Around line 2064:

Unknown directive: =signature

Around line 2068:

Unknown directive: =metadata

Around line 2104:

=cut found outside a pod block. Skipping to next block.

Around line 2124:

=cut found outside a pod block. Skipping to next block.

Around line 2134:

Unknown directive: =method

Around line 2138:

Unknown directive: =signature

Around line 2142:

Unknown directive: =metadata

Around line 2178:

=cut found outside a pod block. Skipping to next block.

Around line 2198:

=cut found outside a pod block. Skipping to next block.

Around line 2208:

Unknown directive: =method

Around line 2212:

Unknown directive: =signature

Around line 2216:

Unknown directive: =metadata

Around line 2252:

=cut found outside a pod block. Skipping to next block.

Around line 2272:

=cut found outside a pod block. Skipping to next block.

Around line 2282:

Unknown directive: =method

Around line 2286:

Unknown directive: =signature

Around line 2290:

Unknown directive: =metadata

Around line 2326:

=cut found outside a pod block. Skipping to next block.

Around line 2346:

=cut found outside a pod block. Skipping to next block.

Around line 2356:

Unknown directive: =method

Around line 2360:

Unknown directive: =signature

Around line 2364:

Unknown directive: =metadata

Around line 2400:

=cut found outside a pod block. Skipping to next block.

Around line 2420:

=cut found outside a pod block. Skipping to next block.

Around line 2430:

Unknown directive: =method

Around line 2434:

Unknown directive: =signature

Around line 2438:

Unknown directive: =metadata

Around line 2474:

=cut found outside a pod block. Skipping to next block.

Around line 2494:

=cut found outside a pod block. Skipping to next block.

Around line 2504:

Unknown directive: =method

Around line 2508:

Unknown directive: =signature

Around line 2512:

Unknown directive: =metadata

Around line 2548:

=cut found outside a pod block. Skipping to next block.

Around line 2568:

=cut found outside a pod block. Skipping to next block.

Around line 2578:

Unknown directive: =operator

Around line 2594:

=cut found outside a pod block. Skipping to next block.

Around line 2604:

Unknown directive: =operator

Around line 2620:

=cut found outside a pod block. Skipping to next block.

Around line 2630:

Unknown directive: =operator

Around line 2646:

=cut found outside a pod block. Skipping to next block.

Around line 2656:

Unknown directive: =operator

Around line 2672:

=cut found outside a pod block. Skipping to next block.

Around line 2682:

Unknown directive: =operator

Around line 2698:

=cut found outside a pod block. Skipping to next block.

Around line 2708:

Unknown directive: =operator

Around line 2724:

=cut found outside a pod block. Skipping to next block.

Around line 2734:

Unknown directive: =operator

Around line 2750:

=cut found outside a pod block. Skipping to next block.

Around line 2760:

Unknown directive: =operator

Around line 2776:

=cut found outside a pod block. Skipping to next block.

Around line 2786:

Unknown directive: =operator

Around line 2802:

=cut found outside a pod block. Skipping to next block.

Around line 2812:

Unknown directive: =operator

Around line 2828:

=cut found outside a pod block. Skipping to next block.

Around line 2838:

Unknown directive: =operator

Around line 2854:

=cut found outside a pod block. Skipping to next block.

Around line 2864:

Unknown directive: =operator

Around line 2880:

=cut found outside a pod block. Skipping to next block.

Around line 2890:

Unknown directive: =operator

Around line 2906:

=cut found outside a pod block. Skipping to next block.

Around line 2912:

Unknown directive: =partials