You appear to be a bot. Output may be restricted
Description
Formats a range of years$yearfrom | $yearto | result |
---|---|---|
x | x | x |
x | y | x,y |
x | z | x-z |
- if $atts['sep'] is set we use that
- else we use the translation of the chosen separator
Usage
bw_year_range( $yearfrom, $yearto, $atts );
Parameters
- $yearfrom
- ( string ) required – the starting year
- $yearto
- ( string ) required – the ending year
- $atts
- ( array ) optional – which may contain a value for 'sep'
Returns
voidSource
File name: oik/includes/bobbcomp.phpLines:
1 to 27 of 27
function bw_year_range( $yearfrom, $yearto, $atts=NULL ) { if ( !$yearfrom ) { $yearfrom = $yearto; } $diff = $yearto - $yearfrom; switch ( $diff ) { case 0: $years = $yearfrom; break; case 1: $sep = bw_array_get( $atts, "sep", null); if ( null === $sep ) { /* translators: "Separator between two adjacent years e.g. 2017,2018 " */ $sep = __( ',', "oik" ); } $years = "$yearfrom$sep$yearto"; break; default: /* more than one OR negative - which is a bit of a boo boo */ $sep = bw_array_get( $atts, "sep", null ); if ( null === $sep ) { /* translators: "Separator for a year range e.g. 2011-2017 " */ $sep = __( '-', "oik" ); } $years = "$yearfrom$sep$yearto"; } return $years ; }View on GitHub View on Trac