Difference between revisions of "API:EPrints/Time"

From EPrints Documentation
Jump to: navigation, search
Line 1: Line 1:
 
<!-- Pod2Wiki=_preamble_  
 
<!-- Pod2Wiki=_preamble_  
 
This page has been automatically generated from the EPrints 3.2 source. Any wiki changes made between the 'Pod2Wiki=*' and 'Edit below this comment' comments will be lost.
 
This page has been automatically generated from the EPrints 3.2 source. Any wiki changes made between the 'Pod2Wiki=*' and 'Edit below this comment' comments will be lost.
  -->
+
  -->{{API}}{{Pod2Wiki}}{{API:Source|file=EPrints/Time.pm|package_name=EPrints::Time}}[[Category:API|Time]]<div><!-- Edit below this comment -->
__NOTOC__
+
{{API}}{{Pod2Wiki}}{{API:Source|file=EPrints/Time.pm|package_name=EPrints::Time}}[[Category:API|Time]]<div><!-- Edit below this comment -->
+
  
  
<!-- Pod2Wiki=head_name --></div>
+
<!-- Pod2Wiki=_private_ --><!-- Pod2Wiki=head_name -->
 
==NAME==
 
==NAME==
 
'''EPrints::Time''' - Time and Date-related functions  
 
'''EPrints::Time''' - Time and Date-related functions  
  
 
<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%; '>
<h4><span style='display:none'>User Comments</span></h4>
+
<span style='display:none'>User Comments</span>
 
<!-- Edit below this comment -->
 
<!-- Edit below this comment -->
  
  
<!-- Pod2Wiki=head_synopsis --></div>
+
<!-- Pod2Wiki= -->
 +
</div>
 +
<!-- Pod2Wiki=head_synopsis -->
 
==SYNOPSIS==
 
==SYNOPSIS==
 
   EPrints::Time::render_date( $handle, "2001-01-12T00:00:00Z" )  
 
   EPrints::Time::render_date( $handle, "2001-01-12T00:00:00Z" )  
Line 36: Line 36:
 
    
 
    
 
<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%; '>
<h4><span style='display:none'>User Comments</span></h4>
+
<span style='display:none'>User Comments</span>
 
<!-- Edit below this comment -->
 
<!-- Edit below this comment -->
  
  
<!-- Pod2Wiki=head_description --></div>
+
<!-- Pod2Wiki= -->
 +
</div>
 +
<!-- Pod2Wiki=head_description -->
 
==DESCRIPTION==
 
==DESCRIPTION==
 
This package contains functions related to time/date functionality.  
 
This package contains functions related to time/date functionality.  
  
 
<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%; '>
<h4><span style='display:none'>User Comments</span></h4>
+
<span style='display:none'>User Comments</span>
 
<!-- Edit below this comment -->
 
<!-- Edit below this comment -->
  
  
<!-- Pod2Wiki=item_render_date --></div>
+
<!-- Pod2Wiki= -->
 +
</div>
 +
<!-- Pod2Wiki=item_render_date -->
 
===$xhtml = EPrints::Time::render_date( $handle, $datevalue )===
 
===$xhtml = EPrints::Time::render_date( $handle, $datevalue )===
  
Line 59: Line 63:
  
 
<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%; '>
<h4><span style='display:none'>User Comments</span></h4>
+
<span style='display:none'>User Comments</span>
 
<!-- Edit below this comment -->
 
<!-- Edit below this comment -->
  
  
<!-- Pod2Wiki=item_render_short_date --></div>
+
<!-- Pod2Wiki= -->
 +
</div>
 +
<!-- Pod2Wiki=item_render_short_date -->
 
===$xhtml = EPrints::Time::render_short_date( $handle, $datevalue )===
 
===$xhtml = EPrints::Time::render_short_date( $handle, $datevalue )===
  
Line 73: Line 79:
  
 
<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%; '>
<h4><span style='display:none'>User Comments</span></h4>
+
<span style='display:none'>User Comments</span>
 
<!-- Edit below this comment -->
 
<!-- Edit below this comment -->
  
  
<!-- Pod2Wiki=item_datestring_to_timet --></div>
+
<!-- Pod2Wiki= -->
 +
</div>
 +
<!-- Pod2Wiki=item_datestring_to_timet -->
 
===$xhtml = EPrints::Time::datestring_to_timet( $handle, $datevalue )===
 
===$xhtml = EPrints::Time::datestring_to_timet( $handle, $datevalue )===
  
Line 85: Line 93:
  
 
<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%; '>
<h4><span style='display:none'>User Comments</span></h4>
+
<span style='display:none'>User Comments</span>
 
<!-- Edit below this comment -->
 
<!-- Edit below this comment -->
  
  
<!-- Pod2Wiki=item_gmt_off --></div>
+
<!-- Pod2Wiki= -->
 +
</div>
 +
<!-- Pod2Wiki=item_gmt_off -->
 
===$xhtml = EPrints::Time::gmt_off()===
 
===$xhtml = EPrints::Time::gmt_off()===
  
Line 95: Line 105:
  
 
<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%; '>
<h4><span style='display:none'>User Comments</span></h4>
+
<span style='display:none'>User Comments</span>
 
<!-- Edit below this comment -->
 
<!-- Edit below this comment -->
  
  
<!-- Pod2Wiki=item_get_month_label --></div>
+
<!-- Pod2Wiki= -->
 +
</div>
 +
<!-- Pod2Wiki=item_get_month_label -->
 
===$label = EPrints::Time::get_month_label( $handle, $monthid )===
 
===$label = EPrints::Time::get_month_label( $handle, $monthid )===
  
Line 109: Line 121:
  
 
<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%; '>
<h4><span style='display:none'>User Comments</span></h4>
+
<span style='display:none'>User Comments</span>
 
<!-- Edit below this comment -->
 
<!-- Edit below this comment -->
  
  
<!-- Pod2Wiki=item_get_month_label_short --></div>
+
<!-- Pod2Wiki= -->
 +
</div>
 +
<!-- Pod2Wiki=item_get_month_label_short -->
 
===$label = EPrints::Time::get_month_label_short( $handle, $monthid )===
 
===$label = EPrints::Time::get_month_label_short( $handle, $monthid )===
  
Line 123: Line 137:
  
 
<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%; '>
<h4><span style='display:none'>User Comments</span></h4>
+
<span style='display:none'>User Comments</span>
 
<!-- Edit below this comment -->
 
<!-- Edit below this comment -->
  
  
<!-- Pod2Wiki=item_get_date_array --></div>
+
<!-- Pod2Wiki= -->
 +
</div>
 +
<!-- Pod2Wiki=item_get_date_array -->
 
===($year,$month,$day) = EPrints::Time::get_date_array( [$time] )===
 
===($year,$month,$day) = EPrints::Time::get_date_array( [$time] )===
  
Line 135: Line 151:
  
 
<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%; '>
<h4><span style='display:none'>User Comments</span></h4>
+
<span style='display:none'>User Comments</span>
 
<!-- Edit below this comment -->
 
<!-- Edit below this comment -->
  
  
<!-- Pod2Wiki=item_get_iso_date --></div>
+
<!-- Pod2Wiki= -->
 +
</div>
 +
<!-- Pod2Wiki=item_get_iso_date -->
 
===$datestamp = EPrints::Time::get_iso_date( [$time] )===
 
===$datestamp = EPrints::Time::get_iso_date( [$time] )===
  
Line 147: Line 165:
  
 
<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%; '>
<h4><span style='display:none'>User Comments</span></h4>
+
<span style='display:none'>User Comments</span>
 
<!-- Edit below this comment -->
 
<!-- Edit below this comment -->
  
  
<!-- Pod2Wiki=item_human_time --></div>
+
<!-- Pod2Wiki= -->
 +
</div>
 +
<!-- Pod2Wiki=item_human_time -->
 
===$timestamp = EPrints::Time::human_time( [$time] )===
 
===$timestamp = EPrints::Time::human_time( [$time] )===
  
Line 157: Line 177:
  
 
<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%; '>
<h4><span style='display:none'>User Comments</span></h4>
+
<span style='display:none'>User Comments</span>
 
<!-- Edit below this comment -->
 
<!-- Edit below this comment -->
  
  
<!-- Pod2Wiki=item_get_iso_timestamp --></div>
+
<!-- Pod2Wiki= -->
 +
</div>
 +
<!-- Pod2Wiki=item_get_iso_timestamp -->
 
===$timestamp = EPrints::Time::get_iso_timestamp( [$time] );===
 
===$timestamp = EPrints::Time::get_iso_timestamp( [$time] );===
  
Line 171: Line 193:
  
 
<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%; '>
<h4><span style='display:none'>User Comments</span></h4>
+
<span style='display:none'>User Comments</span>
 
<!-- Edit below this comment -->
 
<!-- Edit below this comment -->
  
  
<!-- Pod2Wiki=item_human_delay --></div>
+
<!-- Pod2Wiki= -->
 +
</div>
 +
<!-- Pod2Wiki=item_human_delay -->
 
===$timestamp = EPrints::Time::human_delay( $hours );===
 
===$timestamp = EPrints::Time::human_delay( $hours );===
  
Line 187: Line 211:
  
 
<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%; '>
<h4><span style='display:none'>User Comments</span></h4>
+
<span style='display:none'>User Comments</span>
 
<!-- Edit below this comment -->
 
<!-- Edit below this comment -->
  
  
 +
<!-- Pod2Wiki= -->
 +
</div>
 
<!-- Pod2Wiki=_postamble_ --><!-- Edit below this comment -->
 
<!-- Pod2Wiki=_postamble_ --><!-- Edit below this comment -->

Revision as of 13:20, 25 February 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.3, 3.2) | Revision Log | Before editing this page please read Pod2Wiki


NAME

EPrints::Time - Time and Date-related functions

User Comments


SYNOPSIS

 EPrints::Time::render_date( $handle, "2001-01-12T00:00:00Z" ) 
 # returns XML containing 12 January 2001 00:00
 
 EPrints::Time::render_short_date( $handle, "2001-01-12T00:00:00Z" ) 
 # returns XML containing 12 Jan 2001 00:00
 
 EPrints::Time::get_iso_timestamp( ); 
 # returns NOW in the form YYYY-MM-DDTHH:MM:SSZ
 
 EPrints::Time::human_delay( 28 ); 
 # returns "1 day"
 
 EPrints::Time::get_month_label( $handle, 11 ) 
 # returns November
 
 EPrints::Time::get_month_label_short( $handle, 11 ) 
 # returns Nov
 

User Comments


DESCRIPTION

This package contains functions related to time/date functionality.

User Comments


$xhtml = EPrints::Time::render_date( $handle, $datevalue )

Render the given date or date and time as a chunk of XHTML.

$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

User Comments


$xhtml = EPrints::Time::render_short_date( $handle, $datevalue )

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.

e.g EPrints::Time::render_short_date( $handle, "2001-01-12T00:00:00Z" ) #returns XML containing 12 Jan 2001 00:00

User Comments


$xhtml = EPrints::Time::datestring_to_timet( $handle, $datevalue )

Returns an interger number of seconds since 1970-01-01:00:00

$datevalue - in the format YYYY-MM-DDTHH:MM:SSZ

User Comments


$xhtml = EPrints::Time::gmt_off()

Render the current time offset in seconds. This just diffs gmtime and localtime.

User Comments


$label = EPrints::Time::get_month_label( $handle, $monthid )

Return a UTF-8 string describing the month, in the current lanugage.

$monthid is an integer from 1 to 12.

e.g EPrints::Time::get_month_label( $handle, 11 ) # returns November

User Comments


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

e.g EPrints::Time::get_month_label_short( $handle, 11 ) # returns Nov

User Comments


($year,$month,$day) = EPrints::Time::get_date_array( [$time] )

Static method that returns the given time (in UNIX time, seconds since 1.1.79) in an array.

This is the local date not the UTC date.

User Comments


$datestamp = EPrints::Time::get_iso_date( [$time] )

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

This is the localtime date, not UTC.

User Comments


$timestamp = EPrints::Time::human_time( [$time] )

Return a string describing the current local date and time in the current locale's format (see Perl's 'localtime).

User Comments


$timestamp = EPrints::Time::get_iso_timestamp( [$time] );

Return a UTC timestamp of the form YYYY-MM-DDTHH:MM:SSZ

e.g. 2005-02-12T09:23:33Z

$time in seconds from 1970. If not defined then assume current time.

User Comments


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

e.g. EPrints::Time::human_delay( 28 ); # returns "1 day"

e.g. EPrints::Time::human_delay( 400 ); # returns "2 weeks"

User Comments