示例#1
0
 public function toXul()
 {
     return utils::htmlTag($this->xulTagName, array_merge($this->xul, array('id' => $this->id, 'value' => $this->date->format('date', 'short2'))));
 }
示例#2
0
	/**
	 * Format a date, using helper_date
	 *
	 * @param int|string $date Int to directly set a timestamp or strong for a date to format (compatible with strtotime)
	 * @param string|true $type Format needed or true if you want to use formatDirect
	 * @param string $len Format length needed or date format if using formatDirect
	 * @return string The date formatted
	 * @see helper_date::format
	 */
	public static function formatDate($date, $type = 'date', $len = 'short2', $htmlOut = true) {
		if (is_null(self::$date)) {
			self::$date = factory::getHelper('date');
		}
		self::$date->set($date, is_int($date) ? 'timestamp' : 'date');
		if (is_bool($type)) {
			self::$date->getCfg()->setA(array(
				'htmlOut'=>$htmlOut
			));
			return self::$date->formatDirect($len);
		} else {
			self::$date->getCfg()->setA(array(
				'defaultFormat'=>array(
					'type'=>$type,
					'len'=>$type == 'datetime' && $len == 'short2' ? 'short' : $len
				),
				'htmlOut'=>$htmlOut
			));
			return self::$date->format();
		}
	}