Methods summary
public static
DateTime
|
#
cleanTime( number|DateTime|string $time = null )
cleanTime
Parameters
- $time
- An Unix timestamp, DateTime instance or string accepted by strtotime.
Returns
DateTime
|
public static
string
|
#
describeRelativeInterval( DateTime $dateEnd, DateTime|null $dateStart = null, string $width = '', string $locale = '' )
Describe an relative interval from $dateStart to $dateEnd (eg '2 days ago').
Only the largest differing unit is described, and the next smaller unit will be used
for rounding.
Describe an relative interval from $dateStart to $dateEnd (eg '2 days ago').
Only the largest differing unit is described, and the next smaller unit will be used
for rounding.
Parameters
- $dateEnd
- The terminal date
- $dateStart
The anchor date, defaults to now. (if it has a timezone different than
$dateEnd, we'll use the one of $dateEnd)
- $width
- The format name; it can be '', 'short' or 'narrow'
- $locale
- The locale to use. If empty we'll use the default locale set in \Punic\Data
Returns
string
Throws
InvalidArgumentException
|
public static
string
|
#
formatDate( number|DateTime|string $value, string $width = 'short', string|DateTimeZone $toTimezone = '', string $locale = '' )
Format a date.
Parameters
- $value
An Unix timestamp, a \DateTime instance or a string accepted
by strtotime().
- $width
The format name; it can be
'full' (eg 'EEEE, MMMM d, y' - 'Wednesday, August 20, 2014'),
'long' (eg 'MMMM d, y' - 'August 20, 2014'),
'medium' (eg 'MMM d, y' - 'August 20, 2014') or
'short' (eg 'M/d/yy' - '8/20/14').
- $toTimezone
The timezone to set; leave empty to use the default timezone
(or the timezone associated to $value if it's already a \DateTime)
- $locale
- The locale to use. If empty we'll use the default
Returns
string Returns an empty string if $value is empty, the localized textual representation otherwise
|
public static
string
|
#
formatTime( number|DateTime|string $value, string $width = 'short', string|DateTimeZone $toTimezone = '', string $locale = '' )
Format a date.
Parameters
- $value
An Unix timestamp, a \DateTime instance or a string accepted
by strtotime().
- $width
The format name; it can be
'full' (eg 'h:mm:ss a zzzz' - '11:42:13 AM GMT+2:00'),
'long' (eg 'h:mm:ss a z' - '11:42:13 AM GMT+2:00'),
'medium' (eg 'h:mm:ss a' - '11:42:13 AM') or
'short' (eg 'h:mm a' - '11:42 AM')
- $toTimezone
The timezone to set; leave empty to use the default timezone
(or the timezone associated to $value if it's already a \DateTime)
- $locale
- The locale to use. If empty we'll use the default
Returns
string Returns an empty string if $value is empty, the localized textual representation otherwise
Throws
Punic\Exception Throws an exception in case of problems
|
public static
string
|
#
formatDateTime( DateTime $value, string $width, string $locale = '' )
Format a date/time.
Parameters
- $value
- The \DateTime instance for which you want the localized textual representation
- $width
The format name; it can be 'full', 'long', 'medium', 'short' or a combination
for date+time like 'full|short' or a combination for format+date+time like
'full|full|short'
You can also append an asterisk ('*') to the date part of $width. If so,
special day names may be used (like 'Today', 'Yesterday', 'Tomorrow') instead
of the date part.
- $locale
- The locale to use. If empty we'll use the default locale
Returns
string Returns an empty string if $value is empty, the localized textual representation otherwise
Throws
Punic\Exception Throws an exception in case of problems
|
public static
|
#
localizeDatePicker( )
Perform any localization required for date picker used in Form\DateSelect
Perform any localization required for date picker used in Form\DateSelect
|
protected static
array
|
#
utf8StringToChars( string $input )
turn a utf8 string into an array of characters
turn a utf8 string into an array of characters
Parameters
Returns
array
|
protected static
|
#
parseInputDate( DateTime $datetime, string $input, string $locale = '' )
parse a date input according to a locale and apply it to a DateTime object
parse a date input according to a locale and apply it to a DateTime object
Parameters
- $datetime
- datetime to apply date to
- $input
- localized date string
- $locale
- optional locale to use, leave blank to use current
Throws
Punic\Exception\ValueNotInList
|
protected static
|
#
parseInputTime( DateTime $datetime, string $input, string $locale = '' )
parse a time input according to a locale and apply it to a DateTime object
parse a time input according to a locale and apply it to a DateTime object
Parameters
- $datetime
- datetime to apply time to
- $input
- localized time string
- $locale
- optional locale to use, leave blank to use current
Throws
Punic\Exception\BadArgumentType
Punic\Exception\ValueNotInList
|
public static
DateTime
|
#
inputToDateTime( string|string[] $input, string $locale = '' )
Convert a XOOPS DateSelect or DateTime form input into a DateTime object
Convert a XOOPS DateSelect or DateTime form input into a DateTime object
Parameters
- $input
- date string, or array of date and time strings
- $locale
- optional locale to use, leave blank to use current
Returns
DateTime
|