class PARSEMONTH in Bibliography Module 7
Same name and namespace in other branches
- 5 bibtexParse/PARSEMONTH.php \PARSEMONTH
- 6.2 modules/bibtexParse/PARSEMONTH.php \PARSEMONTH
- 6 bibtexParse/PARSEMONTH.php \PARSEMONTH
- 7.3 plugins/biblio_style/bibtex/PARSEMONTH.php \PARSEMONTH
- 7.2 modules/bibtexParse/PARSEMONTH.php \PARSEMONTH
17/June/2005 - Mark Grimshaw: month fields that have multiple dates (e.g. dec # " 5--9," or nov # " 29" # "--" # dec # " 2") are correctly parsed.
Hierarchy
- class \PARSEMONTH
Expanded class hierarchy of PARSEMONTH
File
- modules/
bibtexParse/ PARSEMONTH.php, line 29
View source
class PARSEMONTH {
/**
* Constructor.
*/
public function __construct() {
}
/**
*
*/
public function init($monthField) {
$startMonth = $this->startDay = $endMonth = $this->endDay = FALSE;
$date = preg_split("#", $monthField);
foreach ($date as $field) {
$field = ucfirst(strtolower(trim($field)));
if ($month = array_search($field, $this
->monthToLongName())) {
if (!$startMonth) {
$startMonth = $month;
}
else {
$endMonth = $month;
}
continue;
}
elseif ($month = array_search($field, $this
->monthToShortName())) {
if (!$startMonth) {
$startMonth = $month;
}
else {
$endMonth = $month;
}
continue;
}
$this
->parseDay($field);
}
if ($this->endDay && !$endMonth) {
$endMonth = $startMonth;
}
return array(
$startMonth,
$this->startDay,
$endMonth,
$this->endDay,
);
}
/**
* Extract day of month from field.
*/
public function parseDay($dayField) {
preg_match("/([0-9]+).*([0-9]+)|([0-9]+)/", $dayField, $array);
if (array_key_exists(3, $array)) {
if (!$this->startDay) {
$this->startDay = $array[3];
}
elseif (!$this->endDay) {
$this->endDay = $array[3];
}
}
else {
if (array_key_exists(1, $array)) {
$this->startDay = $array[1];
}
if (array_key_exists(2, $array)) {
$this->endDay = $array[2];
}
}
}
/**
* Convert month to long name.
*/
public function monthToLongName() {
return array(
1 => 'January',
2 => 'February',
3 => 'March',
4 => 'April',
5 => 'May',
6 => 'June',
7 => 'July',
8 => 'August',
9 => 'September',
10 => 'October',
11 => 'November',
12 => 'December',
);
}
/**
* Convert month to short name.
*/
public function monthToShortName() {
return array(
1 => 'Jan',
2 => 'Feb',
3 => 'Mar',
4 => 'Apr',
5 => 'May',
6 => 'Jun',
7 => 'Jul',
8 => 'Aug',
9 => 'Sep',
10 => 'Oct',
11 => 'Nov',
12 => 'Dec',
);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
PARSEMONTH:: |
public | function | ||
PARSEMONTH:: |
public | function | Convert month to long name. | |
PARSEMONTH:: |
public | function | Convert month to short name. | |
PARSEMONTH:: |
public | function | Extract day of month from field. | |
PARSEMONTH:: |
public | function | Constructor. |