2012-06-03 20:19:28 +02:00
|
|
|
<?php
|
|
|
|
|
2017-11-07 00:55:24 +01:00
|
|
|
use Friendica\Core\PConfig;
|
|
|
|
|
2012-06-03 20:19:28 +02:00
|
|
|
abstract class wdcal_local
|
|
|
|
{
|
|
|
|
|
|
|
|
const LOCAL_US = 0;
|
|
|
|
const LOCAL_DE = 1;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @static
|
|
|
|
* @return array|wdcal_local[]
|
|
|
|
*/
|
|
|
|
static function getInstanceClasses() {
|
|
|
|
return array(
|
|
|
|
self::LOCAL_US => "wdcal_local_us",
|
|
|
|
self::LOCAL_DE => "wdcal_local_de",
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @static
|
|
|
|
* @param int $config
|
|
|
|
* @return null|wdcal_local
|
|
|
|
*/
|
|
|
|
static function getInstance($config = 0) {
|
|
|
|
$classes = self::getInstanceClasses();
|
|
|
|
if (isset($classes[$config])) return new $classes[$config];
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @static
|
|
|
|
* @param int $uid
|
|
|
|
* @return wdcal_local
|
|
|
|
*/
|
|
|
|
static function getInstanceByUser($uid = 0) {
|
2017-11-07 00:55:24 +01:00
|
|
|
$dateformat = PConfig::get($uid, "dav", "dateformat");
|
2012-06-03 20:19:28 +02:00
|
|
|
$format = self::getInstance($dateformat);
|
|
|
|
if ($format == null) $format = self::getInstance(self::LOCAL_US);
|
|
|
|
return $format;
|
|
|
|
}
|
|
|
|
|
2012-07-08 19:12:58 +02:00
|
|
|
/**
|
|
|
|
* @static
|
|
|
|
* @abstract
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
abstract static function getLanguageCode();
|
|
|
|
|
2012-06-03 20:19:28 +02:00
|
|
|
/**
|
|
|
|
* @abstract
|
|
|
|
* @static
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
abstract static function getName();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @static
|
|
|
|
* @abstract
|
|
|
|
* @return int
|
|
|
|
*/
|
|
|
|
abstract static function getID();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param string $str
|
|
|
|
* @return int
|
|
|
|
*/
|
|
|
|
function date_local2timestamp($str) {
|
|
|
|
$x = $this->date_parseLocal($str);
|
|
|
|
return mktime($x["hour"], $x["minute"], $x["second"], $x["month"], $x["day"], $x["year"]);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @abstract
|
|
|
|
* @param string $str
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
abstract function date_parseLocal($str);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @abstract
|
|
|
|
* @param int $ts
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
abstract function date_timestamp2local($ts);
|
|
|
|
|
2012-07-08 19:12:58 +02:00
|
|
|
/**
|
|
|
|
* @abstract
|
|
|
|
* @param int $ts
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
abstract function date_timestamp2localDate($ts);
|
|
|
|
|
2012-06-03 20:19:28 +02:00
|
|
|
/**
|
|
|
|
* @abstract
|
|
|
|
* @return int
|
|
|
|
*/
|
|
|
|
abstract function getFirstDayOfWeek();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @abstract
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
abstract function dateformat_js_dm1();
|
|
|
|
/**
|
|
|
|
* @abstract
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
abstract function dateformat_js_dm2();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @abstract
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
abstract function dateformat_js_dm3();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @abstract
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
abstract function dateformat_datepicker_js();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @abstract
|
|
|
|
* @param int $ts
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
abstract function dateformat_datepicker_php($ts = 0);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class wdcal_local_us extends wdcal_local {
|
|
|
|
|
2012-07-08 19:12:58 +02:00
|
|
|
/**
|
|
|
|
* @static
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
static function getLanguageCode() {
|
|
|
|
return "en";
|
|
|
|
}
|
|
|
|
|
2012-06-03 20:19:28 +02:00
|
|
|
/**
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
static function getName() {
|
|
|
|
return t("U.S. Time Format (mm/dd/YYYY)");
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @static
|
|
|
|
* @return int
|
|
|
|
*/
|
|
|
|
static function getID() {
|
|
|
|
return wdcal_local::LOCAL_US;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param string $str
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
function date_parseLocal($str) {
|
|
|
|
return date_parse_from_format("m/d/Y H:i", $str);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param int $ts
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
function date_timestamp2local($ts)
|
|
|
|
{
|
|
|
|
return date("m/d/Y H:i", $ts);
|
|
|
|
}
|
|
|
|
|
2012-07-08 19:12:58 +02:00
|
|
|
/**
|
|
|
|
* @param int $ts
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
function date_timestamp2localDate($ts) {
|
|
|
|
return date("l, F jS Y", $ts);
|
|
|
|
}
|
|
|
|
|
2012-06-03 20:19:28 +02:00
|
|
|
/**
|
|
|
|
* @return int
|
|
|
|
*/
|
|
|
|
function getFirstDayOfWeek() {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
function dateformat_js_dm1() {
|
|
|
|
return "W, M/d";
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
function dateformat_js_dm2() {
|
|
|
|
return "d. L";
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
function dateformat_js_dm3() {
|
|
|
|
return "d L yyyy";
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
function dateformat_datepicker_js() {
|
|
|
|
return "mm/dd/yy";
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param int $ts
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
function dateformat_datepicker_php($ts = 0) {
|
|
|
|
return date("m/d/Y", $ts);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class wdcal_local_de extends wdcal_local {
|
|
|
|
|
2012-07-08 19:12:58 +02:00
|
|
|
/**
|
|
|
|
* @static
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
static function getLanguageCode() {
|
|
|
|
return "de";
|
|
|
|
}
|
|
|
|
|
2012-06-03 20:19:28 +02:00
|
|
|
/**
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
static function getName() {
|
|
|
|
return t("German Time Format (dd.mm.YYYY)");
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @static
|
|
|
|
* @return int
|
|
|
|
*/
|
|
|
|
static function getID() {
|
|
|
|
return wdcal_local::LOCAL_DE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param string $str
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
function date_parseLocal($str)
|
|
|
|
{
|
|
|
|
return date_parse_from_format("d.m.Y H:i", $str);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param int $ts
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
function date_timestamp2local($ts)
|
|
|
|
{
|
|
|
|
return date("d.m.Y H:i", $ts);
|
|
|
|
}
|
|
|
|
|
2012-07-08 19:12:58 +02:00
|
|
|
/**
|
|
|
|
* @param int $ts
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
function date_timestamp2localDate($ts) {
|
|
|
|
return date("l, j. F Y", $ts);
|
|
|
|
}
|
|
|
|
|
2012-06-03 20:19:28 +02:00
|
|
|
/**
|
|
|
|
* @return int
|
|
|
|
*/
|
|
|
|
function getFirstDayOfWeek() {
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
function dateformat_js_dm1() {
|
|
|
|
return "W, d.M";
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
function dateformat_js_dm2() {
|
|
|
|
return "d. L";
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
function dateformat_js_dm3() {
|
|
|
|
return "d L yyyy";
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
function dateformat_datepicker_js() {
|
|
|
|
return "dd.mm.yy";
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param int $ts
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
function dateformat_datepicker_php($ts = 0) {
|
|
|
|
return date("d.m.Y", $ts);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|