Skip to content

Instantly share code, notes, and snippets.

@heiglandreas
Last active April 19, 2023 18:58
Show Gist options
  • Save heiglandreas/e33c695e9aaaf14d459cf0789318d41e to your computer and use it in GitHub Desktop.
Save heiglandreas/e33c695e9aaaf14d459cf0789318d41e to your computer and use it in GitHub Desktop.
SImple test of Intl-Calendar feature set(month)
Chinese Calendar
int(1)
int(0)
Islamic Calendar
int(8)
int(0)
Gregorian Calendar
int(3)
int(0)
<?php
// The implementation of the chinese calendar seems to be broken
// The months can not be set.
echo 'Chinese Calendar' . PHP_EOL;
$f = IntlCalendar::createInstance('UTC', '@calendar=chinese');
var_dump($f->get(IntlCalendar::FIELD_MONTH));
$f->set(IntlCalendar::FIELD_MONTH, 0);
var_dump($f->get(IntlCalendar::FIELD_MONTH));
echo 'Islamic Calendar' . PHP_EOL;
$f = IntlCalendar::createInstance('UTC', '@calendar=islamic');
var_dump($f->get(IntlCalendar::FIELD_MONTH));
$f->set(IntlCalendar::FIELD_MONTH, 0);
var_dump($f->get(IntlCalendar::FIELD_MONTH));
echo 'Gregorian Calendar' . PHP_EOL;
$f = IntlCalendar::createInstance('UTC');
var_dump($f->get(IntlCalendar::FIELD_MONTH));
$f->set(IntlCalendar::FIELD_MONTH, 0);
var_dump($f->get(IntlCalendar::FIELD_MONTH));
Chinese Calendar
int(1)
int(1)
Islamic Calendar
int(8)
int(0)
Gregorian Calendar
int(3)
int(0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment