X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=vendor%2Feasyrdf%2Feasyrdf%2Flib%2FEasyRdf%2FLiteral%2FDate.php;fp=vendor%2Feasyrdf%2Feasyrdf%2Flib%2FEasyRdf%2FLiteral%2FDate.php;h=0e05acf2bf80d08fbdac812e8c1c4ee9c5b48d68;hp=0000000000000000000000000000000000000000;hb=a2bd1bf0c2c1f1a17d188f4dc0726a45494cefae;hpb=57c063afa3f66b07c4bbddc2d6129a96d90f0aad diff --git a/vendor/easyrdf/easyrdf/lib/EasyRdf/Literal/Date.php b/vendor/easyrdf/easyrdf/lib/EasyRdf/Literal/Date.php new file mode 100644 index 000000000..0e05acf2b --- /dev/null +++ b/vendor/easyrdf/easyrdf/lib/EasyRdf/Literal/Date.php @@ -0,0 +1,137 @@ +format('Y-m-d'); + } + + parent::__construct($value, null, $datatype); + } + + /** Parses a string using DateTime and creates a new literal + * + * Example: + * $date = EasyRdf_Literal_Date::parse('1 January 2011'); + * + * @see DateTime + * @param string $value The date to parse + * @return object EasyRdf_Literal_Date + */ + public static function parse($value) + { + $value = new DateTime($value); + return new EasyRdf_Literal_Date($value); + } + + /** Returns the date as a PHP DateTime object + * + * @see DateTime::format + * @return string + */ + public function getValue() + { + return new DateTime($this->value); + } + + /** Returns date formatted according to given format + * + * @see DateTime::format + * @param string $format + * @return string + */ + public function format($format) + { + return $this->getValue()->format($format); + } + + /** A full integer representation of the year, 4 digits + * + * @return integer + */ + public function year() + { + return (int)$this->format('Y'); + } + + /** Integer representation of the month + * + * @return integer + */ + public function month() + { + return (int)$this->format('m'); + } + + /** Integer representation of the day of the month + * + * @return integer + */ + public function day() + { + return (int)$this->format('d'); + } +}