<<

DateUtils

Koha::DateUtils - Transitional wrappers to ease use of DateTime

DESCRIPTION

Koha has historically only used dates not datetimes and been content to handle these as strings. It also has confused formatting with actual dates this is a temporary module for wrappers to hide the complexity of switch to DateTime

dt_ftom_string

$dt = dt_from_string($date_string, [$format, $timezone ]);

Passed a date string returns a DateTime object format and timezone default to the system preferences. If the date string is empty DateTime->now is returned

output_pref

$date_string = output_pref($dt, [$date_format], [$time_format] );

Returns a string containing the time & date formatted as per the C4::Context setting, or undef if undef was provided.

A second parameter allows overriding of the syspref value. This is for testing only In usage use the DateTime objects own methods for non standard formatting

A third parameter allows overriding of the TimeFormat syspref value

A fourth parameter allows to specify if the output format contains the hours and minutes. If it is not defined, the default value is 0;

output_pref_due

$date_string = output_pref_due($dt, [$format] );

Returns a string containing the time & date formatted as per the C4::Context setting

A second parameter allows overriding of the syspref value. This is for testing only In usage use the DateTime objects own methods for non standard formatting

This is effectivelyt a wrapper around output_pref for due dates the time portion is stripped if it is '23:59'

format_sqldatetime

$string = format_sqldatetime( $string_as_returned_from_db );

a convenience routine for calling dt_from_string and formatting the result with output_pref as it is a frequent activity in scripts

format_sqlduedatetime

$string = format_sqldatetime( $string_as_returned_from_db );

a convenience routine for calling dt_from_string and formatting the result with output_pref_due as it is a frequent activity in scripts

<<