.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.40) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "Date::Tiny 3pm" .TH Date::Tiny 3pm "2021-01-07" "perl v5.32.0" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Date::Tiny \- A date object, with as little code as possible .SH "VERSION" .IX Header "VERSION" version 1.07 .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 6 \& # Create a date manually \& $christmas = Date::Tiny\->new( \& year => 2006, \& month => 12, \& day => 25, \& ); \& \& # Show the current date \& $today = Date::Tiny\->now; \& print "Year : " . $today\->year . "\en"; \& print "Month: " . $today\->month . "\en"; \& print "Day : " . $today\->day . "\en"; .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fBDate::Tiny\fR is a member of the DateTime::Tiny suite of time modules. .PP It implements an extremely lightweight object that represents a date, without any time data. .SS "The Tiny Mandate" .IX Subsection "The Tiny Mandate" Many \s-1CPAN\s0 modules which provide the best implementation of a concept can be very large. For some reason, this generally seems to be about 3 megabyte of ram usage to load the module. .PP For a lot of the situations in which these large and comprehensive implementations exist, some people will only need a small fraction of the functionality, or only need this functionality in an ancillary role. .PP The aim of the Tiny modules is to implement an alternative to the large module that implements a subset of the functionality, using as little code as possible. .PP Typically, this means a module that implements between 50% and 80% of the features of the larger module, but using only 100 kilobytes of code, which is about 1/30th of the larger module. .SS "The Concept of Tiny Date and Time" .IX Subsection "The Concept of Tiny Date and Time" Due to the inherent complexity, Date and Time is intrinsically very difficult to implement properly. .PP The arguably \fBonly\fR module to implement it completely correct is DateTime. However, to implement it properly DateTime is quite slow and requires 3\-4 megabytes of memory to load. .PP The challenge in implementing a Tiny equivalent to DateTime is to do so without making the functionality critically flawed, and to carefully select the subset of functionality to implement. .PP If you look at where the main complexity and cost exists, you will find that it is relatively cheap to represent a date or time as an object, but much much more expensive to modify or convert the object. .PP As a result, \fBDate::Tiny\fR provides the functionality required to represent a date as an object, to stringify the date and to parse it back in, but does \fBnot\fR allow you to modify the dates. .PP The purpose of this is to allow for date object representations in situations like log parsing and fast real-time work. .PP The problem with this is that having no ability to modify date limits the usefulness greatly. .PP To make up for this, \fBif\fR you have DateTime installed, any \&\fBDate::Tiny\fR module can be inflated into the equivalent DateTime as needing, loading DateTime on the fly if necessary. .PP For the purposes of date/time logic, all \fBDate::Tiny\fR objects exist in the \*(L"C\*(R" locale, and the \*(L"floating\*(R" time zone (although obviously in a pure date context, the time zone largely doesn't matter). .PP When converting up to full DateTime objects, these local and time zone settings will be applied (although an ability is provided to override this). .PP In addition, the implementation is strictly correct and is intended to be very easily to sub-class for specific purposes of your own. .SH "USAGE" .IX Header "USAGE" In general, the intent is that the \s-1API\s0 be as close as possible to the \&\s-1API\s0 for DateTime. Except, of course, that this module implements less of it. .SH "METHODS" .IX Header "METHODS" .SS "new" .IX Subsection "new" .Vb 5 \& my $date = Date::Tiny\->new( \& year => 2006, \& month => 12, \& day => 31, \& ); .Ve .PP The \f(CW\*(C`new\*(C'\fR constructor creates a new \fBDate::Tiny\fR object. .PP It takes three named parameters. \f(CW\*(C`day\*(C'\fR should be the day of the month (1\-31), \&\f(CW\*(C`month\*(C'\fR should be the month of the year (1\-12), \f(CW\*(C`year\*(C'\fR as a 4 digit year. .PP These are the only parameters accepted. .PP Returns a new \fBDate::Tiny\fR object. .SS "now" .IX Subsection "now" .Vb 1 \& my $current_date = Date::Tiny\->now; .Ve .PP The \f(CW\*(C`now\*(C'\fR method creates a new date object for the current date. .PP The date created will be based on localtime, despite the fact that the date is created in the floating time zone. .PP Returns a new \fBDate::Tiny\fR object. .SS "year" .IX Subsection "year" The \f(CW\*(C`year\*(C'\fR accessor returns the 4\-digit year for the date. .SS "month" .IX Subsection "month" The \f(CW\*(C`month\*(C'\fR accessor returns the 1\-12 month of the year for the date. .SS "day" .IX Subsection "day" The \f(CW\*(C`day\*(C'\fR accessor returns the 1\-31 day of the month for the date. .SS "ymd" .IX Subsection "ymd" The \f(CW\*(C`ymd\*(C'\fR method returns the most common and accurate stringified date format, which returns in the form \*(L"2006\-04\-12\*(R". .SS "as_string" .IX Subsection "as_string" The \f(CW\*(C`as_string\*(C'\fR method converts the date to the default string, which at present is the same as that returned by the \f(CW\*(C`ymd\*(C'\fR method above. .PP This string matches the \s-1ISO 8601\s0 standard for the encoding of a date as a string. .SS "from_string" .IX Subsection "from_string" The \f(CW\*(C`from_string\*(C'\fR method creates a new \fBDate::Tiny\fR object from a string. .PP The string is expected to be a \*(L"yyyy-mm-dd\*(R" \s-1ISO 8601\s0 time string. .PP .Vb 1 \& my $almost_christmas = Date::Tiny\->from_string( \*(Aq2006\-12\-23\*(Aq ); .Ve .PP Returns a new \fBDate::Tiny\fR object, or throws an exception on error. .SS "DateTime" .IX Subsection "DateTime" The \f(CW\*(C`DateTime\*(C'\fR method is used to create a DateTime object that is equivalent to the \fBDate::Tiny\fR object, for use in conversions and calculations. .PP As mentioned earlier, the object will be set to the 'C' locate, and the 'floating' time zone. .PP If installed, the DateTime module will be loaded automatically. .PP Returns a DateTime object, or throws an exception if DateTime is not installed on the current host. .SH "HISTORY" .IX Header "HISTORY" This module was written by Adam Kennedy in 2006. In 2016, David Golden adopted it as a caretaker maintainer. .SH "SEE ALSO" .IX Header "SEE ALSO" DateTime, DateTime::Tiny, Time::Tiny, Config::Tiny, ali.as .SH "SUPPORT" .IX Header "SUPPORT" .SS "Bugs / Feature Requests" .IX Subsection "Bugs / Feature Requests" Please report any bugs or feature requests through the issue tracker at . You will be notified automatically of any progress on your issue. .SS "Source Code" .IX Subsection "Source Code" This is open source software. The code repository is available for public review and contribution under the terms of the license. .PP .PP .Vb 1 \& git clone https://github.com/dagolden/Date\-Tiny.git .Ve .SH "AUTHORS" .IX Header "AUTHORS" .IP "\(bu" 4 Adam Kennedy .IP "\(bu" 4 David Golden .SH "COPYRIGHT AND LICENSE" .IX Header "COPYRIGHT AND LICENSE" This software is copyright (c) 2006 by Adam Kennedy. .PP This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.