Difference between revisions of "API:EPrints/Time"

From EPrints Documentation
Jump to: navigation, search
Line 17: Line 17:
 
<!-- Pod2Wiki=head_synopsis -->
 
<!-- Pod2Wiki=head_synopsis -->
 
==SYNOPSIS==
 
==SYNOPSIS==
   EPrints::Time::render_date( $handle, "2001-01-12T00:00:00Z" )  
+
   ($year) = EPrints::Time::utc_datetime()
   # returns XML containing 12 January 2001 00:00
+
  # 2010
 +
 
 +
  ($year,$month) = EPrints::Time::local_datetime()
 +
  # 2010, 6
 +
 
 +
  EPrints::Time::iso_datetime();
 +
   # 2008-05-15T14:40:24Z
 
    
 
    
   EPrints::Time::render_short_date( $handle, "2001-01-12T00:00:00Z" )  
+
   EPrints::Time::iso_date()
   # returns XML containing 12 Jan 2001 00:00
+
   # 2010-06-23
 
    
 
    
   EPrints::Time::get_iso_timestamp( );
+
   EPrints::Time::month_label( $repo, 11 )  
   # returns NOW in the form YYYY-MM-DDTHH:MM:SSZ
+
   # returns "November"
 
    
 
    
   EPrints::Time::human_delay( 28 );
+
   EPrints::Time::short_month_label( $repo, 11 )  
   # returns "1 day"
+
   # returns "Nov"
 
    
 
    
   EPrints::Time::get_month_label( $handle, 11 )  
+
   EPrints::Time::render_date( $repo, "2001-01-12T00:00:00Z" )  
   # returns November
+
   # returns XML containing 12 January 2001 00:00
 
    
 
    
   EPrints::Time::get_month_label_short( $handle, 11 )  
+
   EPrints::Time::render_short_date( $repo, "2001-01-12T00:00:00Z" )  
   # returns Nov
+
   # returns XML containing 12 Jan 2001 00:00
 
    
 
    
 
<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%; '>
Line 53: Line 59:
 
<!-- Pod2Wiki= -->
 
<!-- Pod2Wiki= -->
 
</div>
 
</div>
<!-- Pod2Wiki=head_methods -->
+
<!-- Pod2Wiki=head_formats_used_in_eprints -->
==METHODS==
+
==FORMATS USED IN EPRINTS==
 
<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>
Line 62: Line 68:
 
<!-- Pod2Wiki= -->
 
<!-- Pod2Wiki= -->
 
</div>
 
</div>
<!-- Pod2Wiki=item_render_date -->
+
<!-- Pod2Wiki=head_internal_format -->
===render_date===
+
===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.
  
$xhtml = EPrints::Time::render_date( $handle, $datevalue )
+
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
Render the given date or date and time as a chunk of XHTML.
+
<span style='display:none'>User Comments</span>
 +
<!-- Edit below this comment -->
  
$datevalue is given in a UTC timestamp of the form YYYY-MM-DDTHH:MM:SSZ but it will be rendered in the local offset.
 
  
e.g EPrints::Time::render_date( $handle, "2001-01-12T00:00:00Z" ) #returns XML containing 12 January 2001 00:00
+
<!-- Pod2Wiki= -->
 +
</div>
 +
<!-- Pod2Wiki=head_iso_8601_style_date_times -->
 +
===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.
  
 
<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%; '>
Line 79: Line 98:
 
<!-- Pod2Wiki= -->
 
<!-- Pod2Wiki= -->
 
</div>
 
</div>
<!-- Pod2Wiki=item_render_short_date -->
+
<!-- Pod2Wiki=head_epoch_time -->
===render_short_date===
+
===Epoch time===
 +
Time zone: UTC
 +
 
 +
Format: integer
  
$xhtml = EPrints::Time::render_short_date( $handle, $datevalue )
+
Time in seconds since system epoch. Used in the login tickets table and when performing date calculations.
Renders a short version of the given date or date and time as a chunk of XHTML.
 
  
$datevalue is given in UTC timestamp of the form YYYY-MM-DDTHH:MM:SSZ but it will be rendered in the local offset.
+
<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 -->
  
e.g EPrints::Time::render_short_date( $handle, "2001-01-12T00:00:00Z" ) #returns XML containing 12 Jan 2001 00:00
 
  
 +
<!-- Pod2Wiki= -->
 +
</div>
 +
<!-- Pod2Wiki=head_methods -->
 +
==METHODS==
 
<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>
Line 96: Line 122:
 
<!-- Pod2Wiki= -->
 
<!-- Pod2Wiki= -->
 
</div>
 
</div>
<!-- Pod2Wiki=item_datestring_to_timet -->
+
<!-- Pod2Wiki=head_parsing -->
===datestring_to_timet===
+
===Parsing===
 +
<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 -->
 +
 
  
$xhtml = EPrints::Time::datestring_to_timet( $handle, $datevalue )
+
<!-- Pod2Wiki= -->
Returns an interger number of seconds since 1970-01-01:00:00
+
</div>
 +
<!-- Pod2Wiki=item_split_value -->
 +
====split_value====
  
$datevalue - in the format YYYY-MM-DDTHH:MM:SSZ
+
@t = split_value( $value )
 +
Splits internal or ISO format $value into years, months, days, hours, minutes, seconds.
  
 
<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%; '>
Line 111: Line 144:
 
<!-- Pod2Wiki= -->
 
<!-- Pod2Wiki= -->
 
</div>
 
</div>
<!-- Pod2Wiki=item_gmt_off -->
+
<!-- Pod2Wiki=item_datetime_local -->
===gmt_off===
+
====datetime_local====
  
  $xhtml = EPrints::Time::gmt_off()
+
  $time = datetime_local( @t )
Render the current time offset in seconds. This just diffs gmtime and localtime.
+
Returns local time @t as the number of seconds since epoch, where @t is years, months etc.
  
 
<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%; '>
Line 124: Line 157:
 
<!-- Pod2Wiki= -->
 
<!-- Pod2Wiki= -->
 
</div>
 
</div>
<!-- Pod2Wiki=item_get_month_label -->
+
<!-- Pod2Wiki=item_datetime_utc -->
===get_month_label===
+
====datetime_utc====
  
  $label = EPrints::Time::get_month_label( $handle, $monthid )
+
  $time = datetime_utc( @t )
Return a UTF-8 string describing the month, in the current lanugage.
+
Returns UTC time @t as the number of seconds since epoch, where @t is years, months etc.
  
$monthid is an integer from 1 to 12.
+
<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 -->
  
e.g EPrints::Time::get_month_label( $handle, 11 ) # returns November
 
  
 +
<!-- Pod2Wiki= -->
 +
</div>
 +
<!-- Pod2Wiki=head_formatting -->
 +
===Formatting===
 
<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>
Line 141: Line 179:
 
<!-- Pod2Wiki= -->
 
<!-- Pod2Wiki= -->
 
</div>
 
</div>
<!-- Pod2Wiki=item_get_month_label_short -->
+
<!-- Pod2Wiki=item_join_value -->
===get_month_label_short===
+
====join_value====
 +
 
 +
$datetime = EPrints::Time::join_value( @t )
 +
Return a time @t in internal format.
 +
 
 +
Returns undef if no parts are defined.
 +
 
 +
<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 -->
  
$label = EPrints::Time::get_month_label_short( $handle, $monthid )
 
Return a UTF-8 string of a short representation in  month, in the current lanugage.
 
  
$monthid is an integer from 1 to 12.
+
<!-- Pod2Wiki= -->
 +
</div>
 +
<!-- Pod2Wiki=item_local_datetime -->
 +
====local_datetime====
 +
 
 +
($year,$mon,$day,$hour,$min,$sec) = EPrints::Time::local_datetime( [ $seconds ] )
 +
Returns the local date-time as an array, see {{API:PodLink|file=perlfunc|package_name=perlfunc|section=localtime|text=perlfunc/localtime}}.
  
e.g EPrints::Time::get_month_label_short( $handle, 11 ) # returns Nov
+
$seconds is seconds since epoch or now if not given.
  
 
<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%; '>
Line 158: Line 209:
 
<!-- Pod2Wiki= -->
 
<!-- Pod2Wiki= -->
 
</div>
 
</div>
<!-- Pod2Wiki=item_get_date_array -->
+
<!-- Pod2Wiki=item_utc_datetime -->
===get_date_array===
+
====utc_datetime====
  
  ($year,$month,$day) = EPrints::Time::get_date_array( [$time] )
+
  ($year,$mon,$day,$hour,$min,$sec) = EPrints::Time::utc_datetime( [ $seconds ] )
Static method that returns the given time (in UNIX time, seconds  since 1.1.79) in an array.
+
Returns the UTC date-time as an array, see {{API:PodLink|file=perlfunc|package_name=perlfunc|section=gmtime|text=perlfunc/gmtime}}.
  
This is the local date not the UTC date.
+
$seconds is seconds since epoch or now if not given.
  
 
<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%; '>
Line 173: Line 224:
 
<!-- Pod2Wiki= -->
 
<!-- Pod2Wiki= -->
 
</div>
 
</div>
<!-- Pod2Wiki=item_get_iso_date -->
+
<!-- Pod2Wiki=item_iso_date -->
===get_iso_date===
+
====iso_date====
  
  $datestamp = EPrints::Time::get_iso_date( [$time] )
+
  $date = EPrints::Time::iso_date( [ $seconds ] )
Method that returns the given time (in UNIX time, seconds  since 1.1.79) in the format used by EPrints and MySQL (YYYY-MM-DD).
+
Return a UTC date of the form YYYY-MM-DD.
  
This is the localtime date, not UTC.
+
$seconds is seconds since epoch or now if not given.
  
 
<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%; '>
Line 188: Line 239:
 
<!-- Pod2Wiki= -->
 
<!-- Pod2Wiki= -->
 
</div>
 
</div>
<!-- Pod2Wiki=item_human_time -->
+
<!-- Pod2Wiki=item_iso_datetime -->
===human_time===
+
====iso_datetime====
 +
 
 +
$datetime = EPrints::Time::iso_datetime( [ $seconds ] );
 +
Return a UTC date-time of the form YYYY-MM-DDTHH:MM:SSZ
  
$timestamp = EPrints::Time::human_time( [$time] )
+
$seconds is seconds since epoch or now if not given.
Return a string describing the current local date and time in the current locale's format (see Perl's 'localtime).
 
  
 
<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%; '>
Line 201: Line 254:
 
<!-- Pod2Wiki= -->
 
<!-- Pod2Wiki= -->
 
</div>
 
</div>
<!-- Pod2Wiki=item_get_iso_timestamp -->
+
<!-- Pod2Wiki=item_rfc822_datetime -->
===get_iso_timestamp===
+
====rfc822_datetime====
  
  $timestamp = EPrints::Time::get_iso_timestamp( [$time] );
+
  $datetime = EPrints::Time::rfc822_datetime( [ $seconds ] )
Return a UTC timestamp of the form YYYY-MM-DDTHH:MM:SSZ
+
Return the local date-time in RFC 822 format (used by e.g. RSS).
  
e.g. 2005-02-12T09:23:33Z
+
$seconds is seconds since epoch or now if not given.
 +
 
 +
<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 -->
  
$time in seconds from 1970. If not defined then assume current time.
+
 
 +
<!-- Pod2Wiki= -->
 +
</div>
 +
<!-- Pod2Wiki=item_human_time -->
 +
====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 {{API:PodLink|file=perlfunc|package_name=perlfunc|section=localtime|text=perlfunc/localtime}}.
  
 
<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%; '>
Line 219: Line 283:
 
</div>
 
</div>
 
<!-- Pod2Wiki=item_human_delay -->
 
<!-- Pod2Wiki=item_human_delay -->
===human_delay===
+
====human_delay====
  
 
  $timestamp = EPrints::Time::human_delay( $hours );
 
  $timestamp = EPrints::Time::human_delay( $hours );
Line 226: Line 290:
 
$hours the number of hours representing the time you want to be human readable.
 
$hours the number of hours representing the time you want to be human readable.
  
e.g. EPrints::Time::human_delay( 28 ); # returns "1 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_phrases -->
 +
===Phrases===
 +
<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=item_month_label -->
 +
====month_label====
  
e.g. EPrints::Time::human_delay( 400 ); # returns "2 weeks"
+
$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.
 +
 +
<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=item_short_month_label -->
 +
====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.
 +
 +
<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_rendering -->
 +
===Rendering===
 +
<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=item_render_date -->
 +
====render_date====
 +
 +
$xhtml = EPrints::Time::render_date( $repo, $value )
 +
Renders a [[API:EPrints/MetaField/Date|EPrints::MetaField::Date]] or [[API:EPrints/MetaField/Time|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
 +
 
 +
<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=item_render_short_date -->
 +
====render_short_date====
 +
 +
$xhtml = EPrints::Time::render_short_date( $repo, $value )
 +
Render a shorter form of {{API:PodLink|file=|package_name=|section=render_date|text=/render_date}}.
 +
 +
E.g.
 +
 +
  05 Jun 2010 10:35:12
 +
  12 Dec 1912 # no time
 +
  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%; '>
 
<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 13:05, 17 June 2010

EPrints 3 Reference: Directory Structure - Metadata Fields - Repository Configuration - XML Config Files - XML Export Format - EPrints data structure - Core API - Data Objects


API: Core API

Latest Source Code (3.4, 3.3) | Revision Log | Before editing this page please read Pod2Wiki


NAME

EPrints::Time - Time and Date-related functions

User Comments


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
 

User Comments


DESCRIPTION

This package contains functions related to time/date functionality.

User Comments


FORMATS USED IN EPRINTS

User Comments


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.

User Comments


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.

User Comments


Epoch time

Time zone: UTC

Format: integer

Time in seconds since system epoch. Used in the login tickets table and when performing date calculations.

User Comments


METHODS

User Comments


Parsing

User Comments


split_value

@t = split_value( $value )

Splits internal or ISO format $value into years, months, days, hours, minutes, seconds.

User Comments


datetime_local

$time = datetime_local( @t )

Returns local time @t as the number of seconds since epoch, where @t is years, months etc.

User Comments


datetime_utc

$time = datetime_utc( @t )

Returns UTC time @t as the number of seconds since epoch, where @t is years, months etc.

User Comments


Formatting

User Comments


join_value

$datetime = EPrints::Time::join_value( @t )

Return a time @t in internal format.

Returns undef if no parts are defined.

User Comments


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.

User Comments


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.

User Comments


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.

User Comments


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.

User Comments


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.

User Comments


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.

User Comments


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.

User Comments


Phrases

User Comments


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.

User Comments


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.

User Comments


Rendering

User Comments


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
 

User Comments


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
 

User Comments