summaryrefslogtreecommitdiffstats
path: root/core/vendor/easyrdf/easyrdf/lib/EasyRdf/Literal/Date.php
diff options
context:
space:
mode:
Diffstat (limited to 'core/vendor/easyrdf/easyrdf/lib/EasyRdf/Literal/Date.php')
-rw-r--r--core/vendor/easyrdf/easyrdf/lib/EasyRdf/Literal/Date.php17
1 files changed, 10 insertions, 7 deletions
diff --git a/core/vendor/easyrdf/easyrdf/lib/EasyRdf/Literal/Date.php b/core/vendor/easyrdf/easyrdf/lib/EasyRdf/Literal/Date.php
index fb1a687..0e05acf 100644
--- a/core/vendor/easyrdf/easyrdf/lib/EasyRdf/Literal/Date.php
+++ b/core/vendor/easyrdf/easyrdf/lib/EasyRdf/Literal/Date.php
@@ -5,7 +5,7 @@
*
* LICENSE
*
- * Copyright (c) 2009-2012 Nicholas J Humfrey. All rights reserved.
+ * Copyright (c) 2009-2013 Nicholas J Humfrey. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -31,9 +31,8 @@
* POSSIBILITY OF SUCH DAMAGE.
*
* @package EasyRdf
- * @copyright Copyright (c) 2009-2012 Nicholas J Humfrey
+ * @copyright Copyright (c) 2009-2013 Nicholas J Humfrey
* @license http://www.opensource.org/licenses/bsd-license.php
- * @version $Id$
*/
/**
@@ -41,7 +40,7 @@
*
* @package EasyRdf
* @link http://www.w3.org/TR/xmlschema-2/#date
- * @copyright Copyright (c) 2009-2012 Nicholas J Humfrey
+ * @copyright Copyright (c) 2009-2013 Nicholas J Humfrey
* @license http://www.opensource.org/licenses/bsd-license.php
*/
class EasyRdf_Literal_Date extends EasyRdf_Literal
@@ -49,6 +48,7 @@ class EasyRdf_Literal_Date extends EasyRdf_Literal
/** Constructor for creating a new date literal
*
* If the value is a DateTime object, then it will be converted to the xsd:date format.
+ * If no value is given or is is null, then the current date is used.
*
* @see DateTime
*
@@ -57,8 +57,13 @@ class EasyRdf_Literal_Date extends EasyRdf_Literal
* @param string $datatype Optional datatype (default 'xsd:date')
* @return object EasyRdf_Literal_Date
*/
- public function __construct($value, $lang = null, $datatype = null)
+ public function __construct($value = null, $lang = null, $datatype = null)
{
+ // If $value is null, use today's date
+ if (is_null($value)) {
+ $value = new DateTime('today');
+ }
+
// Convert DateTime object into string
if ($value instanceof DateTime) {
$value = $value->format('Y-m-d');
@@ -130,5 +135,3 @@ class EasyRdf_Literal_Date extends EasyRdf_Literal
return (int)$this->format('d');
}
}
-
-EasyRdf_Literal::setDatatypeMapping('xsd:date', 'EasyRdf_Literal_Date');