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: 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 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

205 POD Errors

The following errors were encountered while parsing the POD:

Around line 13:

Unknown directive: =name

Around line 21:

Unknown directive: =tagline

Around line 29:

Unknown directive: =abstract

Around line 37:

Unknown directive: =includes

Around line 86:

Unknown directive: =synopsis

Around line 107:

Unknown directive: =description

Around line 116:

Unknown directive: =inherits

Around line 124:

Unknown directive: =integrates

Around line 133:

Unknown directive: =attributes

Around line 146:

Unknown directive: =method

Around line 150:

Unknown directive: =signature

Around line 154:

Unknown directive: =metadata

Around line 200:

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

Around line 211:

Unknown directive: =method

Around line 215:

Unknown directive: =signature

Around line 219:

Unknown directive: =metadata

Around line 255:

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

Around line 275:

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

Around line 285:

Unknown directive: =method

Around line 289:

Unknown directive: =signature

Around line 293:

Unknown directive: =metadata

Around line 329:

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

Around line 349:

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

Around line 359:

Unknown directive: =method

Around line 363:

Unknown directive: =signature

Around line 367:

Unknown directive: =metadata

Around line 403:

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

Around line 423:

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

Around line 433:

Unknown directive: =method

Around line 437:

Unknown directive: =signature

Around line 441:

Unknown directive: =metadata

Around line 477:

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

Around line 497:

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

Around line 507:

Unknown directive: =method

Around line 511:

Unknown directive: =signature

Around line 515:

Unknown directive: =metadata

Around line 551:

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

Around line 571:

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

Around line 581:

Unknown directive: =method

Around line 585:

Unknown directive: =signature

Around line 589:

Unknown directive: =metadata

Around line 625:

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

Around line 645:

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

Around line 655:

Unknown directive: =method

Around line 659:

Unknown directive: =signature

Around line 663:

Unknown directive: =metadata

Around line 699:

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

Around line 719:

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

Around line 729:

Unknown directive: =method

Around line 733:

Unknown directive: =signature

Around line 737:

Unknown directive: =metadata

Around line 773:

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

Around line 793:

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

Around line 803:

Unknown directive: =method

Around line 807:

Unknown directive: =signature

Around line 811:

Unknown directive: =metadata

Around line 835:

Unknown directive: =method

Around line 839:

Unknown directive: =signature

Around line 843:

Unknown directive: =metadata

Around line 867:

Unknown directive: =method

Around line 873:

Unknown directive: =signature

Around line 877:

Unknown directive: =metadata

Around line 910:

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

Around line 921:

Unknown directive: =method

Around line 925:

Unknown directive: =signature

Around line 929:

Unknown directive: =metadata

Around line 953:

Unknown directive: =method

Around line 957:

Unknown directive: =signature

Around line 961:

Unknown directive: =metadata

Around line 985:

Unknown directive: =method

Around line 989:

Unknown directive: =signature

Around line 993:

Unknown directive: =metadata

Around line 1017:

Unknown directive: =method

Around line 1023:

Unknown directive: =signature

Around line 1027:

Unknown directive: =metadata

Around line 1053:

Unknown directive: =method

Around line 1057:

Unknown directive: =signature

Around line 1061:

Unknown directive: =metadata

Around line 1087:

Unknown directive: =method

Around line 1092:

Unknown directive: =signature

Around line 1096:

Unknown directive: =metadata

Around line 1136:

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

Around line 1160:

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

Around line 1174:

Unknown directive: =method

Around line 1178:

Unknown directive: =signature

Around line 1182:

Unknown directive: =metadata

Around line 1212:

Unknown directive: =method

Around line 1216:

Unknown directive: =signature

Around line 1220:

Unknown directive: =metadata

Around line 1250:

Unknown directive: =method

Around line 1254:

Unknown directive: =signature

Around line 1258:

Unknown directive: =metadata

Around line 1288:

Unknown directive: =method

Around line 1292:

Unknown directive: =signature

Around line 1296:

Unknown directive: =metadata

Around line 1326:

Unknown directive: =method

Around line 1330:

Unknown directive: =signature

Around line 1334:

Unknown directive: =metadata

Around line 1364:

Unknown directive: =method

Around line 1368:

Unknown directive: =signature

Around line 1372:

Unknown directive: =metadata

Around line 1402:

Unknown directive: =method

Around line 1406:

Unknown directive: =signature

Around line 1410:

Unknown directive: =metadata

Around line 1440:

Unknown directive: =method

Around line 1444:

Unknown directive: =signature

Around line 1448:

Unknown directive: =metadata

Around line 1474:

Unknown directive: =method

Around line 1478:

Unknown directive: =signature

Around line 1482:

Unknown directive: =metadata

Around line 1507:

Unknown directive: =method

Around line 1511:

Unknown directive: =signature

Around line 1515:

Unknown directive: =metadata

Around line 1539:

Unknown directive: =method

Around line 1543:

Unknown directive: =signature

Around line 1547:

Unknown directive: =metadata

Around line 1571:

Unknown directive: =method

Around line 1575:

Unknown directive: =signature

Around line 1579:

Unknown directive: =metadata

Around line 1622:

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

Around line 1646:

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

Around line 1656:

Unknown directive: =method

Around line 1660:

Unknown directive: =signature

Around line 1664:

Unknown directive: =metadata

Around line 1700:

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

Around line 1720:

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

Around line 1730:

Unknown directive: =method

Around line 1735:

Unknown directive: =signature

Around line 1739:

Unknown directive: =metadata

Around line 1775:

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

Around line 1795:

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

Around line 1805:

Unknown directive: =method

Around line 1810:

Unknown directive: =signature

Around line 1814:

Unknown directive: =metadata

Around line 1838:

Unknown directive: =method

Around line 1842:

Unknown directive: =signature

Around line 1846:

Unknown directive: =metadata

Around line 1890:

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

Around line 1900:

Unknown directive: =method

Around line 1904:

Unknown directive: =signature

Around line 1908:

Unknown directive: =metadata

Around line 1944:

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

Around line 1964:

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

Around line 1974:

Unknown directive: =method

Around line 1978:

Unknown directive: =signature

Around line 1982:

Unknown directive: =metadata

Around line 2018:

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

Around line 2038:

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

Around line 2048:

Unknown directive: =method

Around line 2052:

Unknown directive: =signature

Around line 2056:

Unknown directive: =metadata

Around line 2092:

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

Around line 2112:

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

Around line 2122:

Unknown directive: =method

Around line 2126:

Unknown directive: =signature

Around line 2130:

Unknown directive: =metadata

Around line 2166:

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

Around line 2186:

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

Around line 2196:

Unknown directive: =method

Around line 2200:

Unknown directive: =signature

Around line 2204:

Unknown directive: =metadata

Around line 2240:

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

Around line 2260:

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

Around line 2270:

Unknown directive: =method

Around line 2274:

Unknown directive: =signature

Around line 2278:

Unknown directive: =metadata

Around line 2314:

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

Around line 2334:

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

Around line 2344:

Unknown directive: =method

Around line 2348:

Unknown directive: =signature

Around line 2352:

Unknown directive: =metadata

Around line 2388:

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

Around line 2408:

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

Around line 2418:

Unknown directive: =method

Around line 2422:

Unknown directive: =signature

Around line 2426:

Unknown directive: =metadata

Around line 2462:

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

Around line 2482:

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

Around line 2492:

Unknown directive: =operator

Around line 2508:

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

Around line 2518:

Unknown directive: =operator

Around line 2534:

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

Around line 2544:

Unknown directive: =operator

Around line 2560:

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

Around line 2570:

Unknown directive: =operator

Around line 2586:

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

Around line 2596:

Unknown directive: =operator

Around line 2612:

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

Around line 2622:

Unknown directive: =operator

Around line 2638:

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

Around line 2648:

Unknown directive: =operator

Around line 2664:

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

Around line 2674:

Unknown directive: =operator

Around line 2690:

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

Around line 2700:

Unknown directive: =operator

Around line 2716:

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

Around line 2726:

Unknown directive: =operator

Around line 2742:

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

Around line 2752:

Unknown directive: =operator

Around line 2768:

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

Around line 2778:

Unknown directive: =operator

Around line 2794:

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

Around line 2804:

Unknown directive: =operator

Around line 2820:

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

Around line 2826:

Unknown directive: =partials