Para::Frame::Time - Parses, calculates and presents dates and times
Parses with Date::Manip and returns a modified DateTime object Also supports returning DateTime objects
This is a subclass to DateTime, it automaticly strinigifies using /format_datetime (?).
TODO: Check what it uses for stringification...
Para::Frame::Time->get( $any_type_of_date )
Parses $any_type_of_date
and returns a Para::Frame::Time
object.
This handles among other things, swedish and english dates, as recognized by Date::Manip/ParseDateString.
The object is set to use the current locale and current timezone for display.
Make sure that the $any_type_of_date
has the timezone defined.
Dates with an unspecified timezone will be asumed to be in the local
timezone (and not in UTC). This means that dates and times parsed from
HTML forms will be taken to be the local time.
If you parse dates from a SQL database, make sure it has a defiend timezone, or is in the local timezone, or set the timezone yourself BEFORE you call this method.
$time->init() $time->init($tz);
$his->set_base($date)
Setting the base time for parsing relative times, for other than relative to now.
now() # Exportable
Returns a Para::Frame::Time
object representing current time.
date($any_string) #exportable
This function calls /get whit the given string.
timespan($from, $to) #exportable
Returns a DateTime::Span object.
Use undef value for setting either $from or $to to infinity
This returns a closed span, including its end-dates.
For other options, use DateTime::Span directly
duration( %params ) #exportable
Returns a DateTime::Duration object.
internet_date( $time_in_any_format ) # exportable $t->internet_date()
Returns a date string in a format suitable for use in SMTP or HTTP headers.
Can be called as a function or mehtod.
$t->format_datetime( \%args )
Using the DateTime::Format object given by Para::Frame/configure.
If format
are given, its used with DateTime/strftime instead.
Supported args are
format
Returns a string representing the datetime
$t->stamp
Same as /format_datetime
$t->desig
Same as /format_datetime
$t->plain
Same as /format_datetime
$t->loc
Same as /format_datetime
TODO: Localize format
$t->sysdesig
Returns a string representation of the object for debug purposes.
$t->syskey
Returns a unique predictable id representing this object
$t->equals( $t2 )
Returns true if both objects has the same value.
$class->set_stringify( 1 ) $class->set_stringify( $format )
Sets the format for autostringification of all new dates.
$format
can be a format for DateTime::Format::Strptime or a
DateTime formatter as explained in DateTime/Formatters And
Stringification. If you call it with '1', it will use time_format
from Para::Frame/configure.
$class->set_timezone( ... )
Calls DateTime::TimeZone/new with the first param as the name
.
Sets up the environment with the given timezone.
Returns the DateTime::TimeZone object.
$this->extract_date( $text, $base )
Looked at DateTime::Format::Natural and Date::Extract. No support for swedish dates...
Should handle different degrees of precision, from month to day. In English or Swedish. (Sweden uses it's own variants of english dates)
Modify REGEXES from Date::Manip::Date/_other_rx
Added D/M Removed YYYY/M/D
Added mmmYYYY Removed mmmDDYY