NAME

Para::Frame::Time - Parses, calculates and presents dates and times

DESCRIPTION

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

get

  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.

init

  $time->init()
  $time->init($tz);

set_base

  $his->set_base($date)

Setting the base time for parsing relative times, for other than relative to now.

now

  now() # Exportable

Returns a Para::Frame::Time object representing current time.

date

  date($any_string) #exportable

This function calls /get whit the given string.

timespan

  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

  duration( %params ) #exportable

Returns a DateTime::Duration object.

internet_date

  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.

format_datetime

  $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

stamp

  $t->stamp

Same as /format_datetime

desig

  $t->desig

Same as /format_datetime

plain

  $t->plain

Same as /format_datetime

loc

  $t->loc

Same as /format_datetime

TODO: Localize format

sysdesig

  $t->sysdesig

Returns a string representation of the object for debug purposes.

syskey

  $t->syskey

Returns a unique predictable id representing this object

equals

  $t->equals( $t2 )

Returns true if both objects has the same value.

set_stringify

  $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.

set_timezone

  $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.

extract_date

  $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)

_patch_dm_formats

Modify REGEXES from Date::Manip::Date/_other_rx

Added D/M Removed YYYY/M/D

Added mmmYYYY Removed mmmDDYY

SEE ALSO

Para::Frame, DateTime, DateTime::Duration, DateTime::Span