Format

Format

Format values based on locale and system settings.

Methods

Inherited from FormatResolver

setup

Sets the internal formatting options from an array.

static Format::setup( array $settings )

setupFromSession

Sets the formatting options from session i18n and database settings.

static Format::setupFromSession( \Gibbon\Session $session )

date

Formats a YYYY-MM-DD date with the language-specific format. Optionally provide a format string to use instead.

static Format::date( string $dateString, string $format = false ): string

Return Value: string


dateConvert

Converts a date in the language-specific format to YYYY-MM-DD.

static Format::dateConvert( string $dateString ): string

Return Value: string


dateTime

Formats a YYYY-MM-DD H:I:S MySQL timestamp as a readable string. Optionally provide a format string to use.

static Format::dateTime( string $dateString, string $format = false ): string

Return Value: string


dateReadable

Formats a YYYY-MM-DD date as a readable string with month names.

static Format::dateReadable( string $dateString ): string

Return Value: string


dateRange

Formats two YYYY-MM-DD dates with the language-specific format. Optionally provide a format string to use instead.

static Format::dateRange( string $dateFrom, string $dateTo, $format = false ): string

Return Value: string


dateRangeReadable

Formats two YYYY-MM-DD dates as a readable string, collapsing same months and same years.

static Format::dateRangeReadable( string $dateFrom, string $dateTo ): string

Return Value: string


dateFromTimestamp

Formats a Unix timestamp as the language-specific format. Optionally provide a format string to use instead.

static Format::dateFromTimestamp( string|integer $timestamp, string $format = false ): string

Return Value: string


timestamp

Converts a YYYY-MM-DD date to a Unix timestamp.

static Format::timestamp( $dateString ): string

Return Value: string


time

Formats a time from a given MySQL time or timestamp value.

static Format::time( string $timeString, string|boolean $format = false ): string

Return Value: string


timeRange

Formats a range of times from two given MySQL time or timestamp values.

static Format::timeRange( string $timeFrom, string $timeTo, string|boolean $format = false ): string

Return Value: string


number

Formats a number to an optional decimal points.

static Format::number( integer|string $value, integer $decimals ): string

Return Value: string


currency

Formats a currency with a symbol and two decimals, optionally displaying the currency name in brackets.

static Format::currency( string|integer $value, boolean $includeName = false ): string

Return Value: string


yesNo

Formats a Y/N value as Yes or No in the current language.

static Format::yesNo( string $value, boolean $translate = true ): string

Return Value: string


Formats a link from a url. Automatically adds target _blank to external links.

static Format::link( string $url, string $text = '', string $title = '' ): string

Return Value: string


age

Formats a YYYY-MM-DD date as a relative age with years and months.

static Format::age( string $dateString, boolean $short = false ): string

Return Value: string


phone

Formats phone numbers, optionally including countrt code and types.

static Format::phone( string|integer $number, boolean $countryCode = false, boolean $type = false ): string

Adds spaces to 7-10 digit numbers based on the most common global formats.

Return Value: string


address

Formats an address including optional district and country.

static Format::address( string $address, string $addressDistrict, string $addressCountry ): string

Return Value: string


name

Formats a name based on the provided Role Category. Optionally reverses the name (surname first) or uses an informal format (no title).

static Format::name( string $title, string $preferredName, string $surname, string $roleCategory = 'Staff', boolean $reverse = false, boolean $informal = false ): string

Return Value: string


nameList

Formats a list of names from an array containing standard title, preferredName & surname fields.

static Format::nameList( array $list, string $roleCategory = 'Staff', boolean $reverse = false, boolean $informal = false ): string

Return Value: string


userPhoto

Returns an HTML based on the supplied photo path, using a placeholder image if none exists. Size may be either 75 or 240 at this time.

static Format::userPhoto( string $path, integer $size = 75 ): string

Return Value: string


userStatusInfo

static Format::userStatusInfo( $person = array() )

courseClassName

Returns the course and class name concatenated with a . (dot). The separator could become a setting at some point?

static Format::courseClassName( string $courseName, string $className ): string

Return Value: string