YaBB3::DateTime - A DateTime class


Name

YaBB3::DateTime - A DateTime class


Synopsis

  use YaBB3::DateTime;
  my $datetime  = new YaBB3::DateTime;                          # get a datetime object with the current time
  my $datetime2 = new YaBB3::DateTime( $seconds);
  my $datetime3 = new YaBB3::DateTime( $year, $month, $day, $hour, $minute, $second);
  
  print $datetime;      # print invokes the overloaded "stringify"-operator which means we get the text representation with a predefined format
  print $datetime + $datetime2; # prints $datetime increased by the seconds represented by datetime2


Overview

Class provides the usual methods for date and time operations.


Description

This class' objects represent a complete date with time if required. If useful operators were overloaded.


Reference

Object Super Classes

  YaBB3::Base

Use Packages

Time::Local

Exports

  Default   $VERSION
  Optional
  Tags

Package Fields

  $VERSION  The package version number as a float.

Class Methods

new $args [OPT] Can be an array or a timestamp (seconds from the OS dependant epoch to a date) representing a date. Array: @(year,month,day,hour,minute,second) OR Timestamp: $ as we get it from time() Returns \$ The new object reference.


Create a datetime object from the given date or if not specified from time().

Object Methods

dateToSeconds

  $year    [Opt] The year    The year (4 digit, or offset from 1900)
  $month   [Opt] The month   1 .. 12  Default 1
  $day     [Opt] The day     1 .. 31  Default 1
  $hour    [Opt] The hour    0 .. 23  Default 0
  $min     [Opt] The minute  0 .. 60  Default 0
  $sec     [Opt] The second  0 .. 60  Default 0
  Returns
  $        The number of seconds since the OS epoch.

Return the number of seconds from the OS dependant epoch to the given date. If no arguments are given, the current time() is returned. The year argument should normally be a 4-digit year value, but can also be the year value returned from the localtime() function (an offset from 1900).

toString Returns $ The text representation of this object

Returns the text representation of this datetime object as a string by using the formatstring.

refreshFormat Returns $ 1

Reloads the format from the settings (user or global). See private class method ``_loadFormat''. After changing the settings this method should be executed to actualisize the format string.


=head3 formatTime
  $format  [Opt] A string in which the following keywords will be replaced by
           calendar units.
             <Year>          4-digit year (2004)
             <YearSmall>     2-digit year (04)
             <Month>         Month full name
             <MonthSmall>    Month abbreviation
             <MonthNum>      Month number
             <Weekday>       Weekday full name
             <WeekdaySmall>  Weekday abbreviation
             <WeekdayNum>    Weekday number
             <MonthDay>      Day of the month
             <Suffix>        Day suffix
             <Hour>          24-hour hour
             <HourAmPm>      12-hour hour
             <Minute>        Minutes
             <Second>        Seconds
             <AmPm>          Upper-case AM/PM
             <AmPmLc>        Lower-case am/pm
  Returns
  $        The formatted time

Format and return the given time using the given format string.

Instance Variables

$timestamp
The number of seconds since the OS epoch. get_timestamp

$format
The formatstring for the text representation. get_format set_format( $format)


Operators

The following operators were overloaded to provide intuitive work with the objects. =over


Author

Torsten Mrotz (tmrotz@yabbforum.com)

Copyright ©2000-2005, YaBB 3 Development Team. All Rights Reserved.
You may distribute this module under the terms of YaBB 3.
 YaBB3::DateTime - A DateTime class