Difference between revisions of "API:EPrints/Time"
Line 370: | Line 370: | ||
$xhtml = EPrints::Time::render_short_date( $repo, $value ) | $xhtml = EPrints::Time::render_short_date( $repo, $value ) | ||
− | Render a shorter form of | + | Render a shorter form of [[API:EPrints/Time#render_date|render_date]]. |
E.g. | E.g. | ||
Line 378: | Line 378: | ||
1954 # no month/day | 1954 # no month/day | ||
+ | <div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> | ||
+ | <span style='display:none'>User Comments</span> | ||
+ | <!-- Edit below this comment --> | ||
+ | |||
+ | |||
+ | <!-- Pod2Wiki= --> | ||
+ | </div> | ||
+ | <!-- Pod2Wiki=head_copyright --> | ||
+ | ==COPYRIGHT== | ||
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> | <div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> | ||
<span style='display:none'>User Comments</span> | <span style='display:none'>User Comments</span> |
Revision as of 10:46, 25 August 2011
EPrints 3 Reference: Directory Structure - Metadata Fields - Repository Configuration - XML Config Files - XML Export Format - EPrints data structure - Core API - Data Objects
Latest Source Code (3.4, 3.3) | Revision Log | Before editing this page please read Pod2Wiki
Contents
NAME
EPrints::Time - Time and Date-related functions
SYNOPSIS
($year) = EPrints::Time::utc_datetime() # 2010 ($year,$month) = EPrints::Time::local_datetime() # 2010, 6 EPrints::Time::iso_datetime(); # 2008-05-15T14:40:24Z EPrints::Time::iso_date() # 2010-06-23 EPrints::Time::month_label( $repo, 11 ) # returns "November" EPrints::Time::short_month_label( $repo, 11 ) # returns "Nov" EPrints::Time::render_date( $repo, "2001-01-12T00:00:00Z" ) # returns XML containing 12 January 2001 00:00 EPrints::Time::render_short_date( $repo, "2001-01-12T00:00:00Z" ) # returns XML containing 12 Jan 2001 00:00
DESCRIPTION
This package contains functions related to time/date functionality.
FORMATS USED IN EPRINTS
Internal format
Time zone: UTC (database), server local time (embargoes)
Format: YYYY or YYYY-MM or YYYY-MM-DD or "YYYY-MM-DD hh" or "YYYY-MM-DD hh:mm" or "YYYY-MM-DD hh:mm:ss"
These are used in the database and when setting and getting values. They can contain any fractional part of a date time.
ISO 8601-style date/times
Time zone: UTC
Format: YYYY-MM-DD or YYYY-MM-DDThh:mm:ssZ
These are primarily used in XML output where times that conform to the standard XSD date/time are required.
Epoch time
Time zone: UTC
Format: integer
Time in seconds since system epoch. Used in the login tickets table and when performing date calculations.
METHODS
Parsing
split_value
@t = split_value( $value )
Splits internal or ISO format $value into years, months, days, hours, minutes, seconds.
datetime_local
$time = datetime_local( @t )
Returns local time @t as the number of seconds since epoch, where @t is years, months etc.
datetime_utc
$time = datetime_utc( @t )
Returns UTC time @t as the number of seconds since epoch, where @t is years, months etc.
Formatting
join_value
$datetime = EPrints::Time::join_value( @t )
Return a time @t in internal format.
Returns undef if no parts are defined.
local_datetime
($year,$mon,$day,$hour,$min,$sec) = EPrints::Time::local_datetime( [ $seconds ] )
Returns the local date-time as an array, see perlfunc/localtime.
$seconds is seconds since epoch or now if not given.
utc_datetime
($year,$mon,$day,$hour,$min,$sec) = EPrints::Time::utc_datetime( [ $seconds ] )
Returns the UTC date-time as an array, see perlfunc/gmtime.
$seconds is seconds since epoch or now if not given.
iso_date
$date = EPrints::Time::iso_date( [ $seconds ] )
Return a UTC date of the form YYYY-MM-DD.
$seconds is seconds since epoch or now if not given.
iso_datetime
$datetime = EPrints::Time::iso_datetime( [ $seconds ] );
Return a UTC date-time of the form YYYY-MM-DDTHH:MM:SSZ
$seconds is seconds since epoch or now if not given.
rfc822_datetime
$datetime = EPrints::Time::rfc822_datetime( [ $seconds ] )
Return the local date-time in RFC 822 format (used by e.g. RSS).
$seconds is seconds since epoch or now if not given.
human_time
$timestamp = EPrints::Time::human_time( [$time] )
Return a string describing the current local date and time in the current locale's format, see perlfunc/localtime.
human_delay
$timestamp = EPrints::Time::human_delay( $hours );
Returns a human readable amount of time.
$hours the number of hours representing the time you want to be human readable.
Phrases
month_label
$label = EPrints::Time::month_label( $repo, $monthid )
Return a UTF-8 string describing the month, in the current lanugage.
$monthid is an integer from 1 to 12.
short_month_label
$label = EPrints::Time::short_month_label( $repo, $monthid )
Return a UTF-8 string of a short representation in month, in the current lanugage.
$monthid is an integer from 1 to 12.
Rendering
render_date
$xhtml = EPrints::Time::render_date( $repo, $value )
Renders a EPrints::MetaField::Date or EPrints::MetaField::Time value in a human-friendly form in the current locale's time zone.
Month names are taken from the current repository language.
E.g.
5 June 2010 10:35:12 +02:00 12 December 1912 # no time 1954 # no month/day
render_short_date
$xhtml = EPrints::Time::render_short_date( $repo, $value )
Render a shorter form of render_date.
E.g.
05 Jun 2010 10:35:12 12 Dec 1912 # no time 1954 # no month/day
COPYRIGHT