public function createForm($id_hopdong) { $kh = new Model_Hopdong(); $hopdong = $kh->getWhereIdHopDong($id_hopdong); $this->setDisableLoadDefaultDecorators(true); $this->setDecorators(array(array('ViewScript', array('viewScript' => 'formnoindex/hopdong_layout.phtml')), 'Form')); $data = new My_Data(); $opMau = $data->getOptionMau(); $opLoaiVai = $data->getOptionLoaiVai(); $opNCC = $data->getOptionNCC(); $tenhopdong = $this->createElement('text', 'tenhopdong', array('decorators' => array('ViewHelper'))); $mota = $this->createElement('text', 'mota', array('decorators' => array('ViewHelper'))); $ngayky = $this->createElement('text', 'ngayky', array('decorators' => array('ViewHelper'))); $sotansoi = $this->createElement('text', 'sotansoi', array('decorators' => array('ViewHelper'))); $thanhtien = $this->createElement('text', 'thanhtien', array('decorators' => array('ViewHelper'))); $mamau = $this->createElement('select', 'mamau', array('multioptions' => $opMau, 'decorators' => array('ViewHelper'))); $maloaivai = $this->createElement('select', 'maloaivai', array('multioptions' => $opLoaiVai, 'decorators' => array('ViewHelper'))); $manhacungcap = $this->createElement('select', 'manhacungcap', array('multioptions' => $opNCC, 'decorators' => array('ViewHelper'))); $them = $this->createElement('submit', 'them', array('decorators' => array('ViewHelper'), 'label' => 'Chỉnh sửa')); $mydate = Zend_Locale_Format::getDate($hopdong['NgayKy'], array("date_format" => "yyyy.MM.dd")); $date_str = $mydate['day'] . "/" . $mydate['month'] . "/" . $mydate['year']; $tenhopdong->setAttrib('class', 'formEdit')->setValue($hopdong['TenHopDong']); $mota->setAttrib('class', 'formEdit')->setValue($hopdong['MoTa']); $ngayky->setAttrib('class', 'formEdit')->setValue($date_str); $sotansoi->setAttrib('class', 'formEdit')->setValue($hopdong['SoTanSoi']); $thanhtien->setAttrib('class', 'formEdit')->setValue($hopdong['ThanhTien']); $mamau->setAttrib('class', 'formEdit')->setValue($hopdong['MaMau']); $maloaivai->setAttrib('class', 'formEdit')->setValue($hopdong['MaLoaiVai']); $manhacungcap->setAttrib('class', 'formEdit')->setValue($hopdong['MaNhaCungCap']); $this->addElement($tenhopdong)->addElement($mota)->addElement($ngayky)->addElement($sotansoi)->addElement($thanhtien)->addElement($mamau)->addElement($maloaivai)->addElement($manhacungcap)->addElement($them); }
public function LocalizedToNormalized($value) { if (substr(Mage::app()->getLocale()->getLocaleCode(), 0, 2) != 'en') { $dateFormatIso = Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT); } else { $dateFormatIso = Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_LONG); } $_options = array('locale' => Mage::app()->getLocale()->getLocaleCode(), 'date_format' => $dateFormatIso, 'precision' => null); return Zend_Locale_Format::getDate($value, $_options); }
public function createForm($id_cm) { $kh = new Model_Donxuat(); $donxuat = $kh->getWhere($id_cm); $this->setDisableLoadDefaultDecorators(true); $this->setDecorators(array(array('ViewScript', array('viewScript' => 'form/donxuat_layout.phtml')), 'Form')); $tendonxuat = $this->createElement('text', 'tendonxuat', array('decorators' => array('ViewHelper'))); $ngayxuat = $this->createElement('text', 'ngayxuat', array('decorators' => array('ViewHelper'))); $them = $this->createElement('submit', 'them', array('decorators' => array('ViewHelper'), 'label' => 'Chỉnh sửa')); $mydate = Zend_Locale_Format::getDate($donxuat[0]['NgayXuat'], array("date_format" => "yyyy.MM.dd")); $date_str = $mydate['day'] . "/" . $mydate['month'] . "/" . $mydate['year']; $tendonxuat->setAttrib('class', 'formEdit')->setValue($donxuat[0]['TenDonXuat']); $ngayxuat->setAttrib('class', 'formEdit')->setValue($date_str); $this->addElement($tendonxuat)->addElement($ngayxuat)->addElement($them); }
public function createForm($id_donhang) { $kh = new Model_Donhang(); $donhang = $kh->getWhere($id_donhang); $this->setDisableLoadDefaultDecorators(true); $this->setDecorators(array(array('ViewScript', array('viewScript' => 'formnoindex/donhang_layout.phtml')), 'Form')); $tendonhang = $this->createElement('text', 'tendonhang', array('decorators' => array('ViewHelper'))); $ngaydathang = $this->createElement('text', 'ngaydathang', array('decorators' => array('ViewHelper'))); $tiendathang = $this->createElement('text', 'tiendathang', array('decorators' => array('ViewHelper'))); $sometvai = $this->createElement('text', 'sometvai', array('decorators' => array('ViewHelper'))); $them = $this->createElement('submit', 'them', array('decorators' => array('ViewHelper'), 'label' => 'Chỉnh sửa')); $tendonhang->setAttrib('class', 'textmedium')->setValue($donhang['TenDonHang']); $mydate = Zend_Locale_Format::getDate($donhang['NgayDat'], array("date_format" => "yyyy.MM.dd")); $date_str = $mydate['day'] . "/" . $mydate['month'] . "/" . $mydate['year']; $ngaydathang->setAttrib('class', 'textmedium')->setValue($date_str); $tiendathang->setAttrib('class', 'textmedium')->setValue($donhang['TienDatHang']); $sometvai->setAttrib('class', 'textmedium')->setValue($donhang['SoMetVai']); $this->addElement($tendonhang)->addElement($ngaydathang)->addElement($tiendathang)->addElement($sometvai)->addElement($them); }
public function createForm($id_lonhuom) { $kh = new Model_Lonhuom(); $lonhuom = $kh->getWhere($id_lonhuom); $this->setDisableLoadDefaultDecorators(true); $this->setDecorators(array(array('ViewScript', array('viewScript' => 'form/lonhuom_layout.phtml')), 'Form')); $data = new My_Data(); $opMau = $data->getOptionMau(); $tenlonhuom = $this->createElement('text', 'tenlonhuom', array('decorators' => array('ViewHelper'))); $ngaynhuom = $this->createElement('text', 'ngaynhuom', array('decorators' => array('ViewHelper'))); $mamau = $this->createElement('select', 'mamau', array('decorators' => array('ViewHelper'), 'multioptions' => $opMau)); $them = $this->createElement('submit', 'them', array('decorators' => array('ViewHelper'), 'label' => 'Chỉnh sửa')); $mydate = Zend_Locale_Format::getDate($lonhuom[0]['NgayNhuom'], array("date_format" => "yyyy.MM.dd")); $date_str = $mydate['day'] . "/" . $mydate['month'] . "/" . $mydate['year']; $tenlonhuom->setAttrib('class', 'formEdit')->setValue($lonhuom[0]['TenLoNhuom']); $ngaynhuom->setAttrib('class', 'formEdit')->setValue($date_str); $mamau->setAttrib('class', 'formEdit')->setValue($lonhuom[0]['MaMau']); $this->addElement($tenlonhuom)->addElement($ngaynhuom)->addElement($mamau)->addElement($them); }
private function _checkFormat($value) { try { require_once 'Zend/Locale/Format.php'; $parsed = Zend_Locale_Format::getDate($value, array('date_format' => $this->_format, 'format_type' => 'iso', 'fix_date' => false)); if (isset($parsed['year']) and (strpos(strtoupper($this->_format), 'YY') !== false and strpos(strtoupper($this->_format), 'YYYY') === false)) { $parsed['year'] = Zend_Date::getFullYear($parsed['year']); } } catch (Exception $e) { // Date can not be parsed return false; } if ((strpos($this->_format, 'Y') !== false or strpos($this->_format, 'y') !== false) and !isset($parsed['year'])) { // Year expected but not found return false; } if (strpos($this->_format, 'M') !== false and !isset($parsed['month'])) { // Month expected but not found return false; } if (strpos($this->_format, 'd') !== false and !isset($parsed['day'])) { // Day expected but not found return false; } if ((strpos($this->_format, 'H') !== false or strpos($this->_format, 'h') !== false) and !isset($parsed['hour'])) { // Hour expected but not found return false; } if (strpos($this->_format, 'm') !== false and !isset($parsed['minute'])) { // Minute expected but not found return false; } if (strpos($this->_format, 's') !== false and !isset($parsed['second'])) { // Second expected but not found return false; } // Date fits the format return true; }
<?php echo $this->headMeta(); echo $this->headLink(); $dh = new Model_Donhang(); $donhang = $dh->getAll(); $data = new My_Data(); $dh = $donhang; if ($dh) { $title = array("Tên Đơn Hàng", "Ngày Đặt", "Tiền Đặt Hàng", "Số Mét Vải", "Khách Hàng", "Tùy Chỉnh", "Hợp Đồng Đã Tạo", "Tạo Hợp Đồng"); $content = array(); foreach ($dh as $item) { $subcontent = array(); $mydate = Zend_Locale_Format::getDate($item['NgayDat'], array("date_format" => "yyyy.MM.dd")); $date_str = $mydate['day'] . "/" . $mydate['month'] . "/" . $mydate['year']; $kh = new Model_Khachhang(); $khachhang = $kh->getWhere($item['MaKhachHang'])[0]; $subcontent[] = "<a href='" . HOST_PROJECT . "/index/main/khachhang_detail/true/makhachhang/" . $item['MaKhachHang'] . "/'>" . $item['TenDonHang'] . "</a>"; $subcontent[] = $date_str; $subcontent[] = $item['TienDatHang']; $subcontent[] = $item['SoMetVai']; $subcontent[] = $khachhang['TenKhachHang']; $subcontent[] = '<a href="' . HOST_PROJECT . "/index/chinhsua/donhang/true/makhachhang/" . $item['MaKhachHang'] . "/madonhang/" . $item['MaDonHang'] . '/option/donhang">Sửa</a> | ' . '<a href="' . HOST_PROJECT . "/index/xoa/donhang/true/makhachhang/" . $item['MaKhachHang'] . "/madonhang/" . $item["MaDonHang"] . '/option/xem/" onclick="return confirm(' . "'bạn có chắc muốn xóa ?'" . ')">Xóa</a>'; $hopdong = $data->getHopDong($item['MaDonHang']); $hd_old = "chưa tạo"; if ($hopdong) { $hd_old = ""; foreach ($hopdong as $hd_item) { $hd_old .= "<a href='" . HOST_PROJECT . "/index/main/hopdong_detail/true/mahopdong/" . $hd_item['MaHopDong'] . "/'>" . $hd_item['TenHopDong'] . "</a>, <br>"; } }
/** * Returns the calculated date * * @param string $calc Calculation to make * @param string|integer|Zend_Date $date Date to calculate with, if null the actual date is taken * @param string $format Date format for parsing * @param string|Zend_Locale $locale Locale for parsing input * @return integer|Zend_Date new date * @throws Zend_Date_Exception */ private function _date($calc, $date, $format, $locale) { if (is_null($date)) { throw new Zend_Date_Exception('parameter $date must be set, null is not allowed'); } if ($locale === null) { $locale = $this->getLocale(); } if ($date instanceof Zend_Date) { // extract date from object $date = $date->get(Zend_Date::DATE_MEDIUM, $locale); } else { if (self::$_Options['format_type'] == 'php') { $format = Zend_Locale_Format::convertPhpToIsoFormat($format); } try { $parsed = Zend_Locale_Format::getDate($date, array('date_format' => $format, 'locale' => $locale, 'format_type' => 'iso')); } catch (Zend_Locale_Exception $e) { throw new Zend_Date_Exception($e->getMessage()); } $date = new Zend_Date(0, Zend_Date::TIMESTAMP, $locale); $date->set($parsed['year'], Zend_Date::YEAR); $date->set($parsed['month'], Zend_Date::MONTH); $date->set($parsed['day'], Zend_Date::DAY); $date = $date->get(Zend_Date::DATE_MEDIUM, $locale); } $return = $this->_calcdetail($calc, $date, Zend_Date::DATE_MEDIUM, $locale); if ($calc != 'cmp') { return $this; } return $return; }
<?php echo $this->headMeta(); echo $this->headLink(); $hd = new Model_Hopdong(); $hopdongall = $hd->getAll(); $data = new My_Data(); if ($hopdongall) { $maincontent = array(); $data = new My_Data(); $title = array("Mã Hợp Đồng", "Số Tấn Sợi", "Thành Tiền", "Ngày Ký", "Loại Sợi", "Kho Sợi", "Nhà Cung Cấp", "Tùy Chỉnh", "Nhập Kho"); foreach ($hopdongall as $hopdong) { $mydate = Zend_Locale_Format::getDate($hopdong['NgayMua'], array("date_format" => "yyyy.MM.dd")); $date_str = $mydate['day'] . "/" . $mydate['month'] . "/" . $mydate['year']; $op = $data->getOpHopdong($hopdong['MaSoi'], $hopdong['MaKho'], $hopdong['MaNhaCungCap']); $button = "<a class ='thembutton' href='" . HOST_PROJECT . "/index/nhaplieu/nhapsoi/true/mahopdong/" . $hopdong['MaHopDong'] . "'/>Nhập Kho</a>"; $chinhsua = '<a href="' . HOST_PROJECT . "/index/chinhsua/hopdong/true/mahopdong/" . $hopdong['MaHopDong'] . '/option/hopdong/">Sửa</a> | ' . '<a href="' . HOST_PROJECT . "/index/xoa/hopdong/true/mahopdong/" . $hopdong['MaHopDong'] . '/option/xem/" onclick="return confirm(' . "'bạn có chắc muốn xóa ?'" . ')">Xóa</a>'; $nhapkho = ""; if ($hopdong['TrangThai'] == 1) { $nhapkho = "Đã Nhập"; } else { $nhapkho = $button; } $content = array($hopdong['MaHopDong'], $hopdong['SoTanSoi'], $hopdong['ThanhTien'], $date_str, $op['tensoi'], $op['tenkho'], $op['tenncc'], $chinhsua, $nhapkho); $maincontent[] = $content; } $table = $data->createTable($title, $maincontent, "1100px"); echo $table; } else { echo "<div class='message'>"; echo "Chưa tồn tại Hợp Đồng";
/** * Returns the calculated date * * @param string $calc Calculation to make * @param string|integer|Zend_Date $date Date to calculate with, if null the actual date is taken * @param string $format Dateformat for parsing * @param string|Zend_Locale $locale Locale for parsing input * @return integer|Zend_Date new date * @throws Zend_Date_Exception */ private function _date($calc, $date, $format, $locale) { if (is_null($date)) { throw new Zend_Date_Exception('parameter $date must be set, null is not allowed'); } if ($locale === null) { $locale = $this->getLocale(); } if ($calc == 'set' or $calc == 'cmp') { $gmt = $this->setGmt(false); } else { $gmt = $this->setGmt(true); } if ($date instanceof Zend_Date) { // extract date from object $date = $date->get(Zend_Date::DATE_MEDIUM, $locale); } else { $parsed = Zend_Locale_Format::getDate($date, $format, $locale); $date = new Zend_Date(0, Zend_Date::TIMESTAMP, $locale); $date->setGmt(true); $date->set($parsed['year'], Zend_Date::YEAR); $date->set($parsed['month'], Zend_Date::MONTH_SHORT); $date->set($parsed['day'], Zend_Date::DAY); $date = $date->get(Zend_Date::DATE_MEDIUM, $locale); } $return = $this->_calcdetail($calc, $date, Zend_Date::DATE_MEDIUM, $locale); $this->setGmt($gmt); if ($calc != 'cmp') { return $this; } return $return; }
public function toDateTimeInterval($start, $end, $options = array()) { $start = $this->_checkDateTime($start, @$options['timezone']); $end = $this->_checkDateTime($end, @$options['timezone']); if (!$start || !$end) { return false; } unset($options['timezone']); $options = array_merge(array('locale' => $this->getLocale(), 'format' => 'MEd'), $options); $options['locale'] = 'ja'; $format = Zend_Locale_Data::getContent($options['locale'], 'dateinterval', $options['format']); var_dump(Zend_Locale_Format::getDate($start, array('format' => $format))); die; if (preg_match('/^(.+?)(\\s*[–-~]\\s*)(.+?)$/iu', $format, $matches)) { var_dump($matches); die; } else { // Sigh echo 'zzz'; } var_dump($format); var_dump($start->toString($format, $this->getLocale())); die; }
/** * @deprecated Use new Date($string, $format) or new Date($string, $locale) instead! * @param string $string * @param string | \Zend_Locale $format * @return Date The new date */ public static function fromString($string, $format = null) { if ($string == null) { return null; } if (is_null($format) || $format instanceof \Zend_Locale) { $locale = null; if (!is_null($format)) { $locale = $format; } if (is_null($locale)) { if (\Zend_Registry::isRegistered('\\Zend_Locale')) { $locale = \Zend_Registry::get('\\Zend_Locale'); } else { $locale = new \Zend_Locale(); } } $dateParts = \Zend_Locale_Format::getDate($string, array('date_format' => $format, 'locale' => $locale)); return new Date($dateParts); } return new Date($string, $format); }
<?php echo $this->headMeta(); echo $this->headLink(); $ln = new Model_Lonhuom(); $lonhuomall = $ln->getAll(); if ($lonhuomall) { $maincontent = array(); $title = array("Mã Lô", "Ngày Nhuộm", "Màu", "Số Cây Nhuộm", "Tùy Chỉnh", "Trạng Thái"); $data = new My_Data(); foreach ($lonhuomall as $lonhuom) { if (!$lonhuom['TrangThai']) { $mydate = Zend_Locale_Format::getDate($lonhuom['NgayNhuom'], array("date_format" => "yyyy.MM.dd")); $date_str = $mydate['day'] . "/" . $mydate['month'] . "/" . $mydate['year']; $cm = new Model_Caymoc(); $caymoc = $cm->getWhere_lonhuom($lonhuom['MaLoNhuom']); $trangthai = "<a class ='buttontim' href='#'/>Đang Nhuộm</a>"; $content = array($lonhuom['MaLoNhuom'], $date_str, $data->getNameMau($lonhuom['MaMau']), $lonhuom['SoCayNhuom'], '<a href="' . HOST_PROJECT . "/index/chinhsua/lonhuom/true/malonhuom/" . $lonhuom['MaLoNhuom'] . '/option/lonhuom">Sửa</a> | ' . '<a href="' . HOST_PROJECT . "/index/xoa/lonhuom/true/malonhuom/" . $lonhuom['MaLoNhuom'] . '/option/lonhuom" onclick="return confirm(' . "'bạn có chắc muốn xóa ?'" . ')">Xóa</a>', $trangthai); $maincontent[] = $content; } } $table = $data->createTable($title, $maincontent, "730px"); echo $table; } else { echo "<div class='message'>"; echo "Chưa tồn tại Lô Nhuộm"; echo "</div>"; }
/** * Checks if the given date is a real date or datepart. * Returns false is a expected datepart is missing or a datepart exceeds its possible border. * But the check will only be done for the expected dateparts which are given by format. * If no format is given the standard dateformat for the actual locale is used. * f.e. 30.February.2007 will return false if format is 'dd.MMMM.YYYY' * * @param string $date Date to parse for correctness * @param string $format OPTIONAL Format for parsing the date string * @param string|Zend_Locale $locale OPTIONAL Locale for parsing date parts * @return boolean True when all date parts are correct */ public static function isDate($date, $format = null, $locale = null) { if (Zend_Locale::isLocale($format)) { $locale = $format; $format = null; } if ($locale === null) { $locale = new Zend_Locale(); $locale = $locale->toString(); } if ($format === null) { $format = Zend_Locale_Format::getDateFormat($locale); } else { if (self::$_Options['format_type'] == 'php') { $format = Zend_Locale_Format::convertPhpToIsoFormat($format); } } try { $parsed = Zend_Locale_Format::getDate($date, array('locale' => $locale, 'date_format' => $format, 'format_type' => 'iso', 'fix_date' => false)); } catch (Zend_Locale_Exception $e) { // date can not be parsed return false; } if ((strpos($format, 'Y') !== false or strpos($format, 'y') !== false) and !isset($parsed['year'])) { // year expected but not found return false; } if (strpos($format, 'M') !== false and !isset($parsed['month'])) { // month expected but not found return false; } if (strpos($format, 'd') !== false and !isset($parsed['day'])) { // day expected but not found return false; } if ((strpos($format, 'H') !== false or strpos($format, 'h') !== false) and !isset($parsed['hour'])) { // hour expected but not found return false; } if (strpos($format, 'm') !== false and !isset($parsed['minute'])) { // minute expected but not found return false; } if (strpos($format, 's') !== false and !isset($parsed['second'])) { // second expected but not found return false; } // set not given dateparts if (!isset($parsed['hour'])) { $parsed['hour'] = 0; } if (!isset($parsed['minute'])) { $parsed['minute'] = 0; } if (!isset($parsed['second'])) { $parsed['second'] = 0; } if (!isset($parsed['month'])) { $parsed['month'] = 1; } if (!isset($parsed['day'])) { $parsed['day'] = 1; } if (!isset($parsed['year'])) { $parsed['year'] = 1970; } $date = new self($locale); $timestamp = $date->mktime($parsed['hour'], $parsed['minute'], $parsed['second'], $parsed['month'], $parsed['day'], $parsed['year']); if ($parsed['year'] != $date->date('Y', $timestamp)) { // given year differs from parsed year return false; } if ($parsed['month'] != $date->date('n', $timestamp)) { // given month differs from parsed month return false; } if ($parsed['day'] != $date->date('j', $timestamp)) { // given day differs from parsed day return false; } if ($parsed['hour'] != $date->date('G', $timestamp)) { // given hour differs from parsed hour return false; } if ($parsed['minute'] != $date->date('i', $timestamp)) { // given minute differs from parsed minute return false; } if ($parsed['second'] != $date->date('s', $timestamp)) { // given second differs from parsed second return false; } return true; }
/** * Defined by Zend_Filter_Interface * * Normalizes the given input * * @param string $value Value to normalized * @return string|array The normalized value */ public function filter($value) { if (Zend_Locale_Format::isNumber($value, $this->_options)) { return Zend_Locale_Format::getNumber($value, $this->_options); } else { if ($this->_options['date_format'] === null && strpos($value, ':') !== false) { // Special case, no date format specified, detect time input return Zend_Locale_Format::getTime($value, $this->_options); } else { if (Zend_Locale_Format::checkDateFormat($value, $this->_options)) { // Detect date or time input return Zend_Locale_Format::getDate($value, $this->_options); } } } return $value; }
public function getQLKho($makho) { $option = array(); $title = array("Cây Thành Phẩm", "Số Mét Vải", "Số cây nhập kho", "Số cây xuất kho", "Số cây còn lại", "Người đặt hàng", "Đơn xuất", "Ngày Xuất", "Số lượng xuất"); $option['title'] = $title; $content = array(); $ctp = new Model_Caythanhpham(); $cm = new Model_Caymoc(); $dx = new Model_Donxuat(); $caythanhpham = $ctp->getWhere_khohang($makho); $i = 0; foreach ($caythanhpham as $item) { $subcontent = array(); $subcontent[] = $item['TenCTP']; $subcontent[] = $item['SoMetVai']; $caymoc = $cm->getWhere_ctp($item['MaCTP']); $tenkhachhang = $this->getNameKhachHang($caymoc['MaHopDong']); $slnhap = $caymoc['SoLuongCayMoc']; $madonxuat = $item['MaDonXuat']; $subcontent[] = $slnhap; if ($madonxuat == null) { $subcontent[] = "0"; $subcontent[] = $slnhap; $subcontent[] = $tenkhachhang; $subcontent[] = "Chưa xuất"; $subcontent[] = ""; $subcontent[] = ""; } else { $subcontent[] = "0"; $subcontent[] = $slnhap; $subcontent[] = $tenkhachhang; $donxuat = $dx->getWhere($madonxuat)[0]; $mydate = Zend_Locale_Format::getDate($donxuat['NgayXuat'], array("date_format" => "yyyy.MM.dd")); $date_str = $mydate['day'] . "/" . $mydate['month'] . "/" . $mydate['year']; $subcontent[] = $donxuat['TenDonXuat']; $subcontent[] = $date_str; $subcontent[] = "0"; } $content[] = $subcontent; } $option['content'] = $content; return $option; }
/** * test getDate * expected array */ public function testgetDate() { try { $value = Zend_Locale_Format::getDate('no content'); $this->fail("no date expected"); } catch (Zend_Locale_Exception $e) { // success } $this->assertEquals(is_array(Zend_Locale_Format::getDate('10.10.06')), true, "array expected"); $this->assertEquals(count(Zend_Locale_Format::getDate('10.10.06', array('date_format' => 'dd.MM.yy'))), 5, "array with 5 tags expected"); $value = Zend_Locale_Format::getDate('10.11.06', array('date_format' => 'dd.MM.yy')); $this->assertEquals($value['day'], 10, 'Day 10 expected'); $this->assertEquals($value['month'], 11, 'Month 11 expected'); $this->assertEquals($value['year'], 06, 'Year 06 expected'); $value = Zend_Locale_Format::getDate('10.11.2006', array('date_format' => 'dd.MM.yy')); $this->assertSame($value['day'], 10, 'Day 10 expected'); $this->assertSame($value['month'], 11, 'Month 11 expected'); $this->assertSame($value['year'], 2006, 'Year 2006 expected'); try { $value = Zend_Locale_Format::getDate('2006.13.01', array('date_format' => 'dd.MM.yy')); $this->fail("no date expected"); } catch (Zend_Locale_Exception $e) { $this->assertRegexp('/unable.to.parse/i', $e->getMessage()); // success } $value = Zend_Locale_Format::getDate('2006.13.01', array('date_format' => 'dd.MM.yy', 'fix_date' => true)); $this->assertEquals($value['day'], 13, 'Day 13 expected'); $this->assertEquals($value['month'], 1, 'Month 1 expected'); $this->assertEquals($value['year'], 2006, 'Year 2006 expected'); try { $value = Zend_Locale_Format::getDate('2006.01.13', array('date_format' => 'dd.MM.yy')); $this->fail("no date expected"); } catch (Zend_Locale_Exception $e) { $this->assertRegexp('/unable.to.parse/i', $e->getMessage()); // success } $value = Zend_Locale_Format::getDate('2006.01.13', array('date_format' => 'dd.MM.yy', 'fix_date' => true)); $this->assertEquals($value['day'], 13, 'Day 13 expected'); $this->assertEquals($value['month'], 1, 'Month 1 expected'); $this->assertEquals($value['year'], 2006, 'Year 2006 expected'); $value = Zend_Locale_Format::getDate('101106', array('date_format' => 'ddMMyy')); $this->assertEquals($value['day'], 10, 'Day 10 expected'); $this->assertEquals($value['month'], 11, 'Month 11 expected'); $this->assertEquals($value['year'], 6, 'Year 6 expected'); $value = Zend_Locale_Format::getDate('10112006', array('date_format' => 'ddMMyyyy')); $this->assertEquals($value['day'], 10, 'Day 10 expected'); $this->assertEquals($value['month'], 11, 'Month 11 expected'); $this->assertEquals($value['year'], 2006, 'Year 2006 expected'); $value = Zend_Locale_Format::getDate('10 Nov 2006', array('date_format' => 'dd.MMM.yy', 'locale' => 'de_AT')); $this->assertEquals($value['day'], 10, 'Day 10 expected'); $this->assertEquals($value['month'], 11, 'Month 11 expected'); $this->assertEquals($value['year'], 2006, 'Year 2006 expected'); $value = Zend_Locale_Format::getDate('10 November 2006', array('date_format' => 'dd.MMM.yy', 'locale' => 'de_AT')); $this->assertEquals($value['day'], 10, 'Day 10 expected'); $this->assertEquals($value['month'], 11, 'Month 11 expected'); $this->assertEquals($value['year'], 2006, 'Year 2006 expected'); try { $value = Zend_Locale_Format::getDate('November 10 2006', array('date_format' => 'dd.MMM.yy', 'locale' => 'de_AT')); $this->fail("no date expected"); } catch (Zend_Locale_Exception $e) { $this->assertRegexp('/unable.to.parse/i', $e->getMessage()); // success } $value = Zend_Locale_Format::getDate('November 10 2006', array('date_format' => 'dd.MMM.yy', 'locale' => 'de_AT', 'fix_date' => true)); $this->assertEquals($value['day'], 10, 'Day 10 expected'); $this->assertEquals($value['month'], 11, 'Month 11 expected'); $this->assertEquals($value['year'], 2006, 'Year 2006 expected'); try { $value = Zend_Locale_Format::getDate('Nov 10 2006', array('date_format' => 'dd.MMM.yy', 'locale' => 'de_AT')); $this->fail("no date expected"); } catch (Zend_Locale_Exception $e) { $this->assertRegexp('/unable.to.parse/i', $e->getMessage()); // success } $value = Zend_Locale_Format::getDate('Nov 10 2006', array('date_format' => 'dd.MMM.yy', 'locale' => 'de_AT', 'fix_date' => true)); $this->assertEquals($value['day'], 10, 'Day 10 expected'); $this->assertEquals($value['month'], 11, 'Month 11 expected'); $this->assertEquals($value['year'], 2006, 'Year 2006 expected'); try { $value = Zend_Locale_Format::getDate('2006 10 Nov', array('date_format' => 'dd.MMM.yy', 'locale' => 'de_AT')); $this->fail("no date expected"); } catch (Zend_Locale_Exception $e) { $this->assertRegexp('/unable.to.parse/i', $e->getMessage()); // success } $value = Zend_Locale_Format::getDate('2006 10 Nov', array('date_format' => 'dd.MMM.yy', 'locale' => 'de_AT', 'fix_date' => true)); $this->assertEquals($value['day'], 10, 'Day 10 expected'); $this->assertEquals($value['month'], 11, 'Month 11 expected'); $this->assertEquals($value['year'], 2006, 'Year 2006 expected'); // @todo failed test, auto completion doesnt work for this case // $value = Zend_Locale_Format::getDate('2006 Nov 10','dd.MMM.yy', 'de_AT'); // $this->assertEquals($value['day'], 10, 'Day 10 expected'); // $this->assertEquals($value['month'], 11, 'Month 11 expected'); // $this->assertEquals($value['year'], 2006, 'Year 2006 expected'); $value = Zend_Locale_Format::getDate('10.11.06', array('date_format' => 'yy.dd.MM')); $this->assertEquals($value['day'], 11, 'Day 11 expected'); $this->assertEquals($value['month'], 6, 'Month 6 expected'); $this->assertEquals($value['year'], 10, 'Year 10 expected'); $value = Zend_Locale_Format::getDate('10.11.06', array('date_format' => 'dd.yy.MM')); $this->assertEquals($value['day'], 10, 'Day 10 expected'); $this->assertEquals($value['month'], 6, 'Month 6 expected'); $this->assertEquals($value['year'], 11, 'Year 11 expected'); $value = Zend_Locale_Format::getDate('10.11.06', array('locale' => 'de_AT')); $this->assertEquals($value['day'], 10, 'Day 10 expected'); $this->assertEquals($value['month'], 11, 'Month 11 expected'); $this->assertEquals($value['year'], 6, 'Year 6 expected'); $value = Zend_Locale_Format::getDate('10.11.2006', array('locale' => 'de_AT')); $this->assertEquals($value['day'], 10, 'Day 10 expected'); $this->assertEquals($value['month'], 11, 'Month 11 expected'); $this->assertEquals($value['year'], 2006, 'Year 2006 expected'); try { $value = Zend_Locale_Format::getDate('2006.13.01', array('locale' => 'de_AT')); $this->fail("no date expected"); } catch (Zend_Locale_Exception $e) { $this->assertRegexp('/unable.to.parse/i', $e->getMessage()); // success } $value = Zend_Locale_Format::getDate('2006.13.01', array('locale' => 'de_AT', 'fix_date' => true)); $this->assertEquals($value['day'], 13, 'Day 13 expected'); $this->assertEquals($value['month'], 1, 'Month 1 expected'); $this->assertEquals($value['year'], 2006, 'Year 2006 expected'); try { $value = Zend_Locale_Format::getDate('2006.01.13', array('locale' => 'de_AT')); $this->fail("no date expected"); } catch (Zend_Locale_Exception $e) { $this->assertRegexp('/unable.to.parse/i', $e->getMessage()); // success } $value = Zend_Locale_Format::getDate('2006.01.13', array('locale' => 'de_AT', 'fix_date' => true)); $this->assertEquals($value['day'], 13, 'Day 13 expected'); $this->assertEquals($value['month'], 1, 'Month 1 expected'); $this->assertEquals($value['year'], 2006, 'Year 2006 expected'); $value = Zend_Locale_Format::getDate('101106', array('locale' => 'de_AT')); $this->assertEquals($value['day'], 10, 'Day 10 expected'); $this->assertEquals($value['month'], 11, 'Month 11 expected'); $this->assertEquals($value['year'], 6, 'Year 6 expected'); $value = Zend_Locale_Format::getDate('10112006', array('locale' => 'de_AT')); $this->assertEquals($value['day'], 10, 'Day 10 expected'); $this->assertEquals($value['month'], 11, 'Month 11 expected'); $this->assertEquals($value['year'], 2006, 'Year 2006 expected'); $value = Zend_Locale_Format::getDate('10 Nov 2006', array('locale' => 'de_AT')); $this->assertEquals($value['day'], 10, 'Day 10 expected'); $this->assertEquals($value['month'], 11, 'Month 11 expected'); $this->assertEquals($value['year'], 2006, 'Year 2006 expected'); $value = Zend_Locale_Format::getDate('10 November 2006', array('locale' => 'de_AT')); $this->assertEquals($value['day'], 10, 'Day 10 expected'); $this->assertEquals($value['month'], 11, 'Month 11 expected'); $this->assertEquals($value['year'], 2006, 'Year 2006 expected'); try { $value = Zend_Locale_Format::getDate('November 10 2006', array('locale' => 'de_AT')); $this->fail("no date expected"); } catch (Zend_Locale_Exception $e) { $this->assertRegexp('/unable.to.parse/i', $e->getMessage()); // success } $value = Zend_Locale_Format::getDate('November 10 2006', array('locale' => 'de_AT', 'fix_date' => true)); $this->assertEquals($value['day'], 10, 'Day 10 expected'); $this->assertEquals($value['month'], 11, 'Month 11 expected'); $this->assertEquals($value['year'], 2006, 'Year 2006 expected'); try { $value = Zend_Locale_Format::getDate('April 10 2006', array('locale' => 'de_AT')); $this->fail("no date expected"); } catch (Zend_Locale_Exception $e) { $this->assertRegexp('/unable.to.parse/i', $e->getMessage()); // success } $value = Zend_Locale_Format::getDate('April 10 2006', array('locale' => 'de_AT', 'fix_date' => true)); $this->assertEquals($value['day'], 10, 'Day 10 expected'); $this->assertEquals($value['month'], 4, 'Month 4 expected'); $this->assertEquals($value['year'], 2006, 'Year 2006 expected'); try { $value = Zend_Locale_Format::getDate('Nov 10 2006', array('locale' => 'de_AT')); $this->fail("no date expected"); } catch (Zend_Locale_Exception $e) { $this->assertRegexp('/unable.to.parse/i', $e->getMessage()); // success } $value = Zend_Locale_Format::getDate('Nov 10 2006', array('locale' => 'de_AT', 'fix_date' => true)); $this->assertEquals($value['day'], 10, 'Day 10 expected'); $this->assertEquals($value['month'], 11, 'Month 11 expected'); $this->assertEquals($value['year'], 2006, 'Year 2006 expected'); try { $value = Zend_Locale_Format::getDate('Nov 10 2006', array('locale' => 'de_AT')); $this->fail("no date expected"); } catch (Zend_Locale_Exception $e) { $this->assertRegexp('/unable.to.parse/i', $e->getMessage()); // success } $value = Zend_Locale_Format::getDate('2006 10 Nov', array('locale' => 'de_AT', 'fix_date' => true)); $this->assertEquals($value['day'], 10, 'Day 10 expected'); $this->assertEquals($value['month'], 11, 'Month 11 expected'); $this->assertEquals($value['year'], 2006, 'Year 2006 expected'); $value = Zend_Locale_Format::getDate('01.April.2006', array('date_format' => 'dd.MMMM.yy', 'locale' => 'de_AT')); $this->assertEquals($value['day'], 1, 'Day 1 expected'); $this->assertEquals($value['month'], 4, 'Month 4 expected'); $this->assertEquals($value['year'], 2006, 'Year 2006 expected'); $value = Zend_Locale_Format::getDate('Montag, 01.April.2006', array('date_format' => 'EEEE, dd.MMMM.yy', 'locale' => 'de_AT')); $this->assertEquals($value['day'], 1, 'Day 1 expected'); $this->assertEquals($value['month'], 4, 'Month 4 expected'); $this->assertEquals($value['year'], 2006, 'Year 2006 expected'); try { $value = Zend_Locale_Format::getDate('13.2006.11', array('date_format' => 'dd.MM.yy')); $this->fail(); } catch (Zend_Locale_Exception $e) { // success } Zend_Locale_Format::setOptions(array('format_type' => 'php')); $value = Zend_Locale_Format::getDate('10.11.06', array('date_format' => 'd.m.Y')); $this->assertEquals($value['day'], 10, 'Day 10 expected'); $this->assertEquals($value['month'], 11, 'Month 11 expected'); $this->assertEquals($value['year'], 6, 'Year 6 expected'); $value = Zend_Locale_Format::getDate('10.11.06', array('date_format' => 'd.m.Y', 'fix_date' => true)); $this->assertEquals($value['day'], 10, 'Day 10 expected'); $this->assertEquals($value['month'], 11, 'Month 11 expected'); $this->assertEquals($value['year'], 6, 'Year 6 expected'); $this->assertEquals(is_array(Zend_Locale_Format::getTime('13:14:55', array('date_format' => 'HH:mm:ss'))), true, "array expected"); Zend_Locale_Format::setOptions(array('format_type' => 'iso')); // @todo failed test, auto completion doesnt work for this case // $value = Zend_Locale_Format::getDate('2006 Nov 10', false, 'de_AT'); // $this->assertEquals($value['day'], 10, 'Day 10 expected'); // $this->assertEquals($value['month'], 11, 'Month 11 expected'); // $this->assertEquals($value['year'], 2006, 'Year 2006 expected'); }
/** * Reads a localized value, normalizes and returns it. * Returns an empty string if no value is passed. * @param mixed $value * @param string $type (boolean|date|time|integer|float|decimal|currency) * @return mixed */ private function _normalize($value, $type, $num_of_decimals) { if (strlen($value) == 0) { return ''; } switch ($type) { case 'boolean': $yes_no = Zend_Locale_Data::getContent($this->_locale_engine, 'questionstrings'); $yes_regexp = '/^(' . str_replace(':', '|', $yes_no['yes']) . ')$/i'; if (preg_match($yes_regexp, $value)) { return 1; } return 0; case 'date': $date = Zend_Locale_Format::getDate($value, array('locale' => $this->_locale_engine, 'fix_date' => true)); $date['month'] = str_pad($date['month'], 2, 0, STR_PAD_LEFT); $date['day'] = str_pad($date['day'], 2, 0, STR_PAD_LEFT); return "{$date['year']}-{$date['month']}-{$date['day']}"; case 'time': $date_format = Zend_Locale_Format::getTimeFormat($this->_locale_engine); $date = Zend_Locale_Format::getDate($value, array('date_format' => $date_format, 'locale' => $this->_locale_engine)); if (!isset($date['hour'])) { $date['hour'] = '00'; } if (!isset($date['minute'])) { $date['minute'] = '00'; } if (!isset($date['second'])) { $date['second'] = '00'; } return "{$date['hour']}:{$date['minute']}:{$date['second']}"; case 'datetime': $date = Zend_Locale_Format::getDateTime($value, array('locale' => $this->_locale_engine, 'fix_date' => true)); $date['month'] = str_pad($date['month'], 2, 0, STR_PAD_LEFT); $date['day'] = str_pad($date['day'], 2, 0, STR_PAD_LEFT); $date['hour'] = str_pad($date['hour'], 2, 0, STR_PAD_LEFT); $date['minute'] = str_pad($date['minute'], 2, 0, STR_PAD_LEFT); $date['second'] = str_pad($date['second'], 2, 0, STR_PAD_LEFT); return "{$date['year']}-{$date['month']}-{$date['day']} {$date['hour']}:{$date['minute']}:{$date['second']}"; break; case 'integer': return Zend_Locale_Format::getInteger($value, array('locale' => $this->_locale_engine)); case 'float': if ($num_of_decimals === null) { $num_of_decimals = 3; } return Zend_Locale_Format::getFloat($value, array('precision' => $num_of_decimals, 'locale' => $this->_locale_engine)); case 'decimal': if ($num_of_decimals === null) { $num_of_decimals = 2; } return Zend_Locale_Format::getFloat($value, array('precision' => $num_of_decimals, 'locale' => $this->_locale_engine)); } return $value; }
<?php echo $this->headMeta(); echo $this->headLink(); $hd = new Model_Hoadon(); $hoadonall = $hd->getAll(); if ($hoadonall) { $maincontent = array(); $title = array("Tên Hóa Đơn", "Tiền Thanh Toán", "Ngày Thanh Toán", "Hình Thức", "Nhà Cung Cấp", "Tùy Chỉnh"); $data = new My_Data(); foreach ($hoadonall as $hoadon) { $mydate = Zend_Locale_Format::getDate($hoadon['NgayThanhToan'], array("date_format" => "yyyy.MM.dd")); $date_str = $mydate['day'] . "/" . $mydate['month'] . "/" . $mydate['year']; $ht = new Model_Hinhthuc(); $hinhthuc = $ht->getWhere($hoadon['HinhThuc'])['TenHinhThuc']; $ncc = new Model_Nhacungcap(); $nhacungcap = $ncc->getWhere($hoadon['MaNhaCungCap']); $content = array($hoadon['TenHoaDon'], $hoadon['SoTien'], $date_str, $hinhthuc, $nhacungcap['TenNhaCungCap'], '<a href="' . HOST_PROJECT . "/index/chinhsua/hoadon/true/mahoadon/" . $hoadon['MaHoaDon'] . '/option/hoadon/">Sửa</a> | ' . '<a href="' . HOST_PROJECT . "/index/xoa/hoadon/true/mahoadon/" . $hoadon['MaHoaDon'] . '/option/hoadon/" onclick="return confirm(' . "'bạn có chắc muốn xóa ?'" . ')">Xóa</a>'); $maincontent[] = $content; } $table = $data->createTable($title, $maincontent, "800px"); echo $table; } else { echo "<div class='message'>"; echo "Chưa tồn tại Hóa Đơn!"; echo "</div>"; }
/** * Defined by Zend_Filter_Interface * * Normalizes the given input * * @param string $value Value to normalized * @return string|array The normalized value */ public function filter($value) { if (Zend_Locale_Format::isNumber($value, $this->_options)) { return Zend_Locale_Format::getNumber($value, $this->_options); // if (($this->_options['precision'] === 0) && Zend_Locale_Format::isInteger($value, $this->_options)) { // Detect integer // return Zend_Locale_Format::getInteger($value, $this->_options); // } else if (($this->_options['precision'] === null) && Zend_Locale_Format::isFloat($value, $this->_options)) { // Detect float // return Zend_Locale_Format::getFloat($value, $this->_options); // } else if (Zend_Locale_Format::isNumber($value, $this->_options)) { // Detect all other numbers // return Zend_Locale_Format::getNumber($value, $this->_options); } else { if ($this->_options['date_format'] === null && strpos($value, ':') !== false) { // Special case, no date format specified, detect time input return Zend_Locale_Format::getTime($value, $this->_options); } else { if (Zend_Locale_Format::checkDateFormat($value, $this->_options)) { // Detect date or time input return Zend_Locale_Format::getDate($value, $this->_options); } } } return $value; }
if (!is_numeric($data['activityID'])) { $errors['activityID'] = $kga['lang']['errorMessages']['noActivitySelected']; } if (!is_numeric($data['projectID'])) { $errors['projectID'] = $kga['lang']['errorMessages']['noProjectSelected']; } if (count($errors) > 0) { echo json_encode(array('errors' => $errors)); return; } $edit_in_day = Zend_Locale_Format::getDate($_REQUEST['start_day'], array('date_format' => 'dd.MM.yyyy')); $edit_in_time = Zend_Locale_Format::getTime($_REQUEST['start_time'], array('date_format' => 'HH:mm:ss')); $edit_in = array_merge($edit_in_day, $edit_in_time); $inDate = new Zend_Date($edit_in); if ($_REQUEST['end_day'] != '' || $_REQUEST['end_time'] != '') { $edit_out_day = Zend_Locale_Format::getDate($_REQUEST['end_day'], array('date_format' => 'dd.MM.yyyy')); $edit_out_time = Zend_Locale_Format::getTime($_REQUEST['end_time'], array('date_format' => 'HH:mm:ss')); $edit_out = array_merge($edit_out_day, $edit_out_time); $outDate = new Zend_Date($edit_out); } else { $outDate = null; } $data['start'] = $inDate->getTimestamp(); if ($outDate != null) { $data['end'] = $outDate->getTimestamp(); $data['duration'] = $data['end'] - $data['start']; } if ($id) { // TIME RIGHT - NEW OR EDIT ? if (!timesheetAccessAllowed($data, $action, $errors)) { echo json_encode(array('errors' => $errors));
/** * Checks if the given date is a real date or datepart. * Returns false if a expected datepart is missing or a datepart exceeds its possible border. * But the check will only be done for the expected dateparts which are given by format. * If no format is given the standard dateformat for the actual locale is used. * f.e. 30.February.2007 will return false if format is 'dd.MMMM.YYYY' * * @param string|array|Zend_Date $date Date to parse for correctness * @param string $format (Optional) Format for parsing the date string * @param string|Zend_Locale $locale (Optional) Locale for parsing date parts * @return boolean True when all date parts are correct */ public static function isDate($date, $format = null, $locale = null) { if (!is_string($date) && !is_numeric($date) && !$date instanceof Zend_Date && !is_array($date)) { return false; } if ($format !== null && $format != 'ee' && $format != 'ss' && $format != 'GG' && $format != 'MM' && $format != 'EE' && $format != 'TT' && Zend_Locale::isLocale($format, null, false)) { $locale = $format; $format = null; } $locale = Zend_Locale::findLocale($locale); if ($format === null) { $format = Zend_Locale_Format::getDateFormat($locale); } else { if (self::$_options['format_type'] == 'php' && !defined($format)) { $format = Zend_Locale_Format::convertPhpToIsoFormat($format); } } $format = self::_getLocalizedToken($format, $locale); if (!is_array($date)) { try { $parsed = Zend_Locale_Format::getDate($date, array('locale' => $locale, 'date_format' => $format, 'format_type' => 'iso', 'fix_date' => false)); } catch (Zend_Locale_Exception $e) { // Date can not be parsed return false; } } else { $parsed = $date; } if ((strpos($format, 'Y') !== false or strpos($format, 'y') !== false) and !isset($parsed['year'])) { // Year expected but not found return false; } if (strpos($format, 'M') !== false and !isset($parsed['month'])) { // Month expected but not found return false; } if (strpos($format, 'd') !== false and !isset($parsed['day'])) { // Day expected but not found return false; } if ((strpos($format, 'H') !== false or strpos($format, 'h') !== false) and !isset($parsed['hour'])) { // Hour expected but not found return false; } if (strpos($format, 'm') !== false and !isset($parsed['minute'])) { // Minute expected but not found return false; } if (strpos($format, 's') !== false and !isset($parsed['second'])) { // Second expected but not found return false; } // Set not given dateparts if (isset($parsed['hour']) === false) { $parsed['hour'] = 12; } if (isset($parsed['minute']) === false) { $parsed['minute'] = 0; } if (isset($parsed['second']) === false) { $parsed['second'] = 0; } if (isset($parsed['month']) === false) { $parsed['month'] = 1; } if (isset($parsed['day']) === false) { $parsed['day'] = 1; } if (isset($parsed['year']) === false) { $parsed['year'] = 1970; } if (self::isYearLeapYear($parsed['year'])) { $parsed['year'] = 1972; } else { $parsed['year'] = 1971; } $date = new self($parsed, null, $locale); $timestamp = $date->mktime($parsed['hour'], $parsed['minute'], $parsed['second'], $parsed['month'], $parsed['day'], $parsed['year']); if ($parsed['year'] != $date->date('Y', $timestamp)) { // Given year differs from parsed year return false; } if ($parsed['month'] != $date->date('n', $timestamp)) { // Given month differs from parsed month return false; } if ($parsed['day'] != $date->date('j', $timestamp)) { // Given day differs from parsed day return false; } if ($parsed['hour'] != $date->date('G', $timestamp)) { // Given hour differs from parsed hour return false; } if ($parsed['minute'] != $date->date('i', $timestamp)) { // Given minute differs from parsed minute return false; } if ($parsed['second'] != $date->date('s', $timestamp)) { // Given second differs from parsed second return false; } return true; }
/** * test setOption * expected boolean */ public function testSetOption() { $this->assertEquals(7, count(Zend_Locale_Format::setOptions(array('format_type' => 'php')))); $this->assertTrue(is_array(Zend_Locale_Format::setOptions())); try { $this->assertTrue(Zend_Locale_Format::setOptions(array('format_type' => 'xxx'))); $this->fail("exception expected"); } catch (Zend_Locale_Exception $e) { // success } try { $this->assertTrue(Zend_Locale_Format::setOptions(array('myformat' => 'xxx'))); $this->fail("exception expected"); } catch (Zend_Locale_Exception $e) { // success } $format = Zend_Locale_Format::setOptions(array('locale' => 'de', 'number_format' => Zend_Locale_Format::STANDARD)); $test = Zend_Locale_Data::getContent('de', 'decimalnumberformat'); $this->assertEquals($test['default'], $format['number_format']); try { $this->assertFalse(Zend_Locale_Format::setOptions(array('number_format' => array('x' => 'x')))); $this->fail("exception expected"); } catch (Zend_Locale_Exception $e) { // success } $format = Zend_Locale_Format::setOptions(array('locale' => 'de', 'date_format' => Zend_Locale_Format::STANDARD)); $test = Zend_Locale_Format::getDateFormat('de'); $this->assertEquals($test, $format['date_format']); try { $this->assertFalse(Zend_Locale_Format::setOptions(array('date_format' => array('x' => 'x')))); $this->fail("exception expected"); } catch (Zend_Locale_Exception $e) { // success } try { $this->assertFalse(is_array(Zend_Locale_Format::setOptions(array('fix_date' => 'no')))); $this->fail("exception expected"); } catch (Zend_Locale_Exception $e) { // success } $format = Zend_Locale_Format::setOptions(array('locale' => Zend_Locale_Format::STANDARD)); $locale = new Zend_Locale(); $this->assertEquals($locale, $format['locale']); try { $this->assertFalse(is_array(Zend_Locale_Format::setOptions(array('locale' => 'nolocale')))); $this->fail("exception expected"); } catch (Zend_Locale_Exception $e) { // success } try { $this->assertFalse(is_array(Zend_Locale_Format::setOptions(array('precision' => 50)))); $this->fail("exception expected"); } catch (Zend_Locale_Exception $e) { // success } // test interaction between class-wide default date format and using locale's default format try { $result = array('date_format' => 'MMM d, yyyy', 'locale' => 'en_US', 'month' => '07', 'day' => '4', 'year' => '2007'); Zend_Locale_Format::setOptions(array('format_type' => 'iso', 'date_format' => 'MMM d, yyyy', 'locale' => 'en_US')); // test setUp } catch (Zend_Locale_Exception $e) { $this->fail("exception expected"); } try { // uses global date_format with global locale $this->assertSame($result, Zend_Locale_Format::getDate('July 4, 2007')); } catch (Zend_Locale_Exception $e) { $this->fail("exception expected"); } try { // uses global date_format with given locale $this->assertSame($result, Zend_Locale_Format::getDate('July 4, 2007', array('locale' => 'en_US'))); } catch (Zend_Locale_Exception $e) { $this->fail("exception expected"); } try { // sets a new global date format Zend_Locale_Format::setOptions(array('date_format' => 'M-d-y')); } catch (Zend_Locale_Exception $e) { $this->fail("exception expected"); } try { // uses global date format with given locale // but this date format differs from the original set... (MMMM d, yyyy != M-d-y) $expected = Zend_Locale_Format::getDate('July 4, 2007', array('locale' => 'en_US')); $this->assertSame($expected['year'], $result['year'] ); $this->assertSame($expected['month'], $result['month']); $this->assertSame($expected['day'], $result['day'] ); } catch (Zend_Locale_Exception $e) { $this->fail("exception expected"); } try { // the following should not be used... instead of null, Zend_Locale_Format::STANDARD should be used // uses given local with standard format from this locale $this->assertSame($result, Zend_Locale_Format::getDate('July 4, 2007', array('locale' => 'en_US', 'date_format' => null))); } catch (Zend_Locale_Exception $e) { $this->fail("exception expected"); } try { // uses given locale with standard format from this locale $this->assertSame($result, Zend_Locale_Format::getDate('July 4, 2007', array('locale' => 'en_US', 'date_format' => Zend_Locale_Format::STANDARD))); } catch (Zend_Locale_Exception $e) { $this->fail("exception expected"); } try { // uses standard locale with standard format from this locale $expect = Zend_Locale_Format::getDate('July 4, 2007', array('locale' => Zend_Locale_Format::STANDARD)); $testlocale = new Zend_Locale(); $this->assertEquals($testlocale, $expect['locale']); } catch (Zend_Locale_Exception $e) { $this->fail("exception expected"); } Zend_Locale_Format::setOptions(array('date_format' => null, 'locale' => null)); // test tearDown }
/** * Calculates the date or object * * @param string $calc Calculation to make, one of: 'add'|'sub'|'cmp'|'copy'|'set' * @param string|integer|Zend_Date $date Date or datepart to calculate with * @param string $part Part of the date to calculate, if null the timestamp is used * @param string|Zend_Locale $locale Locale for parsing input * @return integer|string|Zend_Date new timestamp * @throws Zend_Date_Exception */ private function _calculate($calc, $date, $part, $locale) { if (is_null($date)) { throw new Zend_Date_Exception('parameter $date must be set, null is not allowed'); } if (Zend_Locale::isLocale($part)) { $locale = $part; $part = null; } if ($locale === null) { $locale = $this->getLocale(); } if ($locale instanceof Zend_Locale) { $locale = $locale->toString(); } // create date parts $year = $this->get(Zend_Date::YEAR); $month = $this->get(Zend_Date::MONTH_SHORT); $day = $this->get(Zend_Date::DAY_SHORT); $hour = $this->get(Zend_Date::HOUR_SHORT); $minute = $this->get(Zend_Date::MINUTE_SHORT); $second = $this->get(Zend_Date::SECOND_SHORT); // if object extract value if ($date instanceof Zend_Date) { $date = $date->get($part, $locale); } // $date as object, part of foreign date as own date switch ($part) { // day formats case Zend_Date::DAY: if (is_numeric($date)) { return $this->_assign($calc, $this->mktime(0, 0, 0, 1, 1 + intval($date), 1970, true), $this->mktime(0, 0, 0, 1, 1 + intval($day), 1970, true)); } throw new Zend_Date_Exception("invalid date ({$date}) operand, day expected", $date); break; case Zend_Date::WEEKDAY_SHORT: $daylist = Zend_Locale_Data::getContent($locale, 'daylist', array('gregorian', 'wide')); $weekday = (int) $this->get(Zend_Date::WEEKDAY_DIGIT, $locale); $cnt = 0; foreach ($daylist as $key => $value) { if (strtoupper(substr($value, 0, 3)) == strtoupper($date)) { $found = $cnt; break; } ++$cnt; } // Weekday found if ($cnt < 7) { return $this->_assign($calc, $this->mktime(0, 0, 0, 1, 1 + $found, 1970, true), $this->mktime(0, 0, 0, 1, 1 + $weekday, 1970, true)); } // Weekday not found throw new Zend_Date_Exception("invalid date ({$date}) operand, weekday expected", $date); break; case Zend_Date::DAY_SHORT: if (is_numeric($date)) { return $this->_assign($calc, $this->mktime(0, 0, 0, 1, 1 + intval($date), 1970, true), $this->mktime(0, 0, 0, 1, 1 + intval($day), 1970, true)); } throw new Zend_Date_Exception("invalid date ({$date}) operand, day expected", $date); break; case Zend_Date::WEEKDAY: $daylist = Zend_Locale_Data::getContent($locale, 'daylist', array('gregorian', 'wide')); $weekday = (int) $this->get(Zend_Date::WEEKDAY_DIGIT, $locale); $cnt = 0; foreach ($daylist as $key => $value) { if (strtoupper($value) == strtoupper($date)) { $found = $cnt; break; } ++$cnt; } // Weekday found if ($cnt < 7) { return $this->_assign($calc, $this->mktime(0, 0, 0, 1, 1 + $found, 1970, true), $this->mktime(0, 0, 0, 1, 1 + $weekday, 1970, true)); } // Weekday not found throw new Zend_Date_Exception("invalid date ({$date}) operand, weekday expected", $date); break; case Zend_Date::WEEKDAY_8601: $weekday = (int) $this->get(Zend_Date::WEEKDAY_DIGIT, $locale); if (intval($date) > 0 and intval($date) < 8) { return $this->_assign($calc, $this->mktime(0, 0, 0, 1, 1 + intval($date), 1970, true), $this->mktime(0, 0, 0, 1, 1 + $weekday, 1970, true)); } // Weekday not found throw new Zend_Date_Exception("invalid date ({$date}) operand, weekday expected", $date); break; case Zend_Date::DAY_SUFFIX: throw new Zend_Date_Exception('day suffix not supported', $date); break; case Zend_Date::WEEKDAY_DIGIT: $weekday = (int) $this->get(Zend_Date::WEEKDAY_DIGIT, $locale); if (intval($date) > 0 and intval($date) < 8) { return $this->_assign($calc, $this->mktime(0, 0, 0, 1, 2 + $date, 1970, true), $this->mktime(0, 0, 0, 1, 1 + $weekday, 1970, true)); } // Weekday not found throw new Zend_Date_Exception("invalid date ({$date}) operand, weekday expected", $date); break; case Zend_Date::DAY_OF_YEAR: if (is_numeric($date)) { return $this->_assign($calc, $this->mktime(0, 0, 0, 1, 1 + $date, 1970, true), $this->mktime(0, 0, 0, $month, 1 + $day, 1970, true)); } throw new Zend_Date_Exception("invalid date ({$date}) operand, day expected", $date); break; case Zend_Date::WEEKDAY_NARROW: $daylist = Zend_Locale_Data::getContent($locale, 'daylist', array('gregorian', 'abbreviated')); $weekday = (int) $this->get(Zend_Date::WEEKDAY_DIGIT, $locale); $cnt = 0; foreach ($daylist as $key => $value) { if (strtoupper(substr($value, 0, 1)) == strtoupper($date)) { $found = $cnt; break; } ++$cnt; } // Weekday found if ($cnt < 7) { return $this->_assign($calc, $this->mktime(0, 0, 0, 1, 1 + $found, 1970, true), $this->mktime(0, 0, 0, 1, 1 + $weekday, 1970, true)); } // Weekday not found throw new Zend_Date_Exception("invalid date ({$date}) operand, weekday expected", $date); break; case Zend_Date::WEEKDAY_NAME: $daylist = Zend_Locale_Data::getContent($locale, 'daylist', array('gregorian', 'abbreviated')); $weekday = (int) $this->get(Zend_Date::WEEKDAY_DIGIT, $locale); $cnt = 0; foreach ($daylist as $key => $value) { if (strtoupper($value) == strtoupper($date)) { $found = $cnt; break; } ++$cnt; } // Weekday found if ($cnt < 7) { return $this->_assign($calc, $this->mktime(0, 0, 0, 1, 1 + $found, 1970, true), $this->mktime(0, 0, 0, 1, 1 + $weekday, 1970, true)); } // Weekday not found throw new Zend_Date_Exception("invalid date ({$date}) operand, weekday expected", $date); break; // week formats // week formats case Zend_Date::WEEK: if (is_numeric($date)) { $week = (int) $this->get(Zend_Date::WEEK, $locale); return $this->_assign($calc, parent::mktime(0, 0, 0, 1, 1 + $date * 7, 1970, true), parent::mktime(0, 0, 0, 1, 1 + $week * 7, 1970, true)); } throw new Zend_Date_Exception("invalid date ({$date}) operand, week expected", $date); break; // month formats // month formats case Zend_Date::MONTH_NAME: $monthlist = Zend_Locale_Data::getContent($locale, 'monthlist', array('gregorian', 'wide')); $monthnr = (int) $this->get(Zend_Date::MONTH_SHORT, $locale); $cnt = 0; foreach ($monthlist as $key => $value) { if (strtoupper($value) == strtoupper($date)) { $found = $key; break; } ++$cnt; } // Monthname found if ($cnt < 12) { if ($calc == 'set') { --$found; --$monthnr; } else { $year = 1970; } return $this->_assign($calc, $this->mktime(0, 0, 0, 1 + $found, 1, $year, true), $this->mktime(0, 0, 0, 1 + $monthnr, 1, $year, true)); } // Monthname not found throw new Zend_Date_Exception("invalid date ({$date}) operand, month expected", $date); break; case Zend_Date::MONTH: if (is_numeric($date)) { if ($calc == 'set') { --$date; --$month; } else { $year = 1970; } return $this->_assign($calc, $this->mktime(0, 0, 0, 1 + intval($date), 1, $year, true), $this->mktime(0, 0, 0, 1 + $month, 1, $year, true)); } throw new Zend_Date_Exception("invalid date ({$date}) operand, month expected", $date); break; case Zend_Date::MONTH_NAME_SHORT: $monthlist = Zend_Locale_Data::getContent($locale, 'monthlist', array('gregorian', 'abbreviated')); $monthnr = (int) $this->get(Zend_Date::MONTH_SHORT, $locale); $cnt = 0; foreach ($monthlist as $key => $value) { if (strtoupper($value) == strtoupper($date)) { $found = $key; break; } ++$cnt; } // Monthname found if ($cnt < 12) { if ($calc == 'set') { --$found; --$monthnr; } else { $year = 1970; } return $this->_assign($calc, $this->mktime(0, 0, 0, 1 + $found, 1, $year, true), $this->mktime(0, 0, 0, 1 + $monthnr, 1, $year, true)); } // Monthname not found throw new Zend_Date_Exception("invalid date ({$date}) operand, month expected", $date); break; case Zend_Date::MONTH_SHORT: if (is_numeric($date)) { if ($calc == 'set') { --$date; --$month; } else { $year = 1970; } return $this->_assign($calc, $this->mktime(0, 0, 0, 1 + intval($date), 1, $year, true), $this->mktime(0, 0, 0, 1 + $month, 1, $year, true)); } throw new Zend_Date_Exception("invalid date ({$date}) operand, month expected", $date); break; case Zend_Date::MONTH_DAYS: throw new Zend_Date_Exception('month days not supported', $date); break; case Zend_Date::MONTH_NAME_NARROW: $monthlist = Zend_Locale_Data::getContent($locale, 'monthlist', array('gregorian', 'abbreviated')); $monthnr = (int) $this->get(Zend_Date::MONTH_SHORT, $locale); $cnt = 0; foreach ($monthlist as $key => $value) { if (strtoupper(substr($value, 0, 1)) == strtoupper($date)) { $found = $key; break; } ++$cnt; } // Monthname found if ($cnt < 12) { if ($calc == 'set') { --$found; --$monthnr; } else { $year = 1970; } return $this->_assign($calc, $this->mktime(0, 0, 0, 1 + $found, 1, $year, true), $this->mktime(0, 0, 0, 1 + $monthnr, 1, $year, true)); } // Monthname not found throw new Zend_Date_Exception("invalid date ({$date}) operand, month expected", $date); break; // year formats // year formats case Zend_Date::LEAPYEAR: throw new Zend_Date_Exception('leap year not supported', $date); break; case Zend_Date::YEAR_8601: if (is_numeric($date)) { if ($calc == 'add') { $date += $year; $calc = 'set'; } else { if ($calc == 'sub') { $date = $year - $date; $calc = 'set'; } } return $this->_assign($calc, $this->mktime(0, 0, 0, $month, $day, intval($date), true), $this->mktime(0, 0, 0, $month, $day, $year, true)); } throw new Zend_Date_Exception("invalid date ({$date}) operand, year expected", $date); break; case Zend_Date::YEAR: if (is_numeric($date)) { if ($calc == 'add') { $date += $year; $calc = 'set'; } else { if ($calc == 'sub') { $date = $year - $date; $calc = 'set'; } } return $this->_assign($calc, $this->mktime(0, 0, 0, $month, $day, intval($date), true), $this->mktime(0, 0, 0, $month, $day, $year, true)); } throw new Zend_Date_Exception("invalid date ({$date}) operand, year expected", $date); break; case Zend_Date::YEAR_SHORT: if (is_numeric($date)) { $date = intval($date); if ($date >= 0 and $date <= 100 and $calc == 'set') { $date += 1900; if ($date < 1970) { $date += 100; } } if ($calc == 'add') { $date += $year; $calc = 'set'; } else { if ($calc == 'sub') { $date = $year - $date; $calc = 'set'; } } return $this->_assign($calc, $this->mktime(0, 0, 0, $month, $day, $date, true), $this->mktime(0, 0, 0, $month, $day, $year, true)); } throw new Zend_Date_Exception("invalid date ({$date}) operand, year expected", $date); break; case Zend_Date::YEAR_SHORT_8601: if (is_numeric($date)) { $date = intval($date); if ($date >= 0 and $date <= 100 and $calc == 'set') { $date += 1900; if ($date < 1970) { $date += 100; } } if ($calc == 'add') { $date += $year; $calc = 'set'; } else { if ($calc == 'sub') { $date = $year - $date; $calc = 'set'; } } return $this->_assign($calc, $this->mktime(0, 0, 0, $month, $day, $date, true), $this->mktime(0, 0, 0, $month, $day, $year, true)); } throw new Zend_Date_Exception("invalid date ({$date}) operand, year expected", $date); break; // time formats // time formats case Zend_Date::MERIDIEM: throw new Zend_Date_Exception('meridiem not supported', $date); break; case Zend_Date::SWATCH: if (is_numeric($date)) { $rest = intval($date); $hours = floor($rest * 24 / 1000); $rest = $rest - $hours * 1000 / 24; $minutes = floor($rest * 1440 / 1000); $rest = $rest - $minutes * 1000 / 1440; $seconds = floor($rest * 86400 / 1000); return $this->_assign($calc, $this->mktime($hours, $minutes, $seconds, 1, 1, 1970, true), $this->mktime($hour, $minute, $second, 1, 1, 1970, true)); } throw new Zend_Date_Exception("invalid date ({$date}) operand, swatchstamp expected", $date); break; case Zend_Date::HOUR_SHORT_AM: if (is_numeric($date)) { return $this->_assign($calc, $this->mktime(intval($date), 0, 0, 1, 1, 1970, true), $this->mktime($hour, 0, 0, 1, 1, 1970, true)); } throw new Zend_Date_Exception("invalid date ({$date}) operand, hour expected", $date); break; case Zend_Date::HOUR_SHORT: if (is_numeric($date)) { return $this->_assign($calc, $this->mktime(intval($date), 0, 0, 1, 1, 1970, true), $this->mktime($hour, 0, 0, 1, 1, 1970, true)); } throw new Zend_Date_Exception("invalid date ({$date}) operand, hour expected", $date); break; case Zend_Date::HOUR_AM: if (is_numeric($date)) { return $this->_assign($calc, $this->mktime(intval($date), 0, 0, 1, 1, 1970, true), $this->mktime($hour, 0, 0, 1, 1, 1970, true)); } throw new Zend_Date_Exception("invalid date ({$date}) operand, hour expected", $date); break; case Zend_Date::HOUR: if (is_numeric($date)) { return $this->_assign($calc, $this->mktime(intval($date), 0, 0, 1, 1, 1970, true), $this->mktime($hour, 0, 0, 1, 1, 1970, true)); } throw new Zend_Date_Exception("invalid date ({$date}) operand, hour expected", $date); break; case Zend_Date::MINUTE: if (is_numeric($date)) { return $this->_assign($calc, $this->mktime(0, intval($date), 0, 1, 1, 1970, true), $this->mktime(0, $minute, 0, 1, 1, 1970, true)); } throw new Zend_Date_Exception("invalid date ({$date}) operand, minute expected", $date); break; case Zend_Date::SECOND: if (is_numeric($date)) { return $this->_assign($calc, $this->mktime(0, 0, intval($date), 1, 1, 1970, true), $this->mktime(0, 0, $second, 1, 1, 1970, true)); } throw new Zend_Date_Exception("invalid date ({$date}) operand, second expected", $date); break; case Zend_Date::MILLISECOND: if (is_numeric($date)) { switch ($calc) { case 'set': return $this->setMillisecond($date); break; case 'add': return $this->addMillisecond($date); break; case 'sub': return $this->subMillisecond($date); break; } return $this->compareMillisecond($date); } throw new Zend_Date_Exception("invalid date ({$date}) operand, milliseconds expected", $date); break; case Zend_Date::MINUTE_SHORT: if (is_numeric($date)) { return $this->_assign($calc, $this->mktime(0, intval($date), 0, 1, 1, 1970, true), $this->mktime(0, $minute, 0, 1, 1, 1970, true)); } throw new Zend_Date_Exception("invalid date ({$date}) operand, minute expected", $date); break; case Zend_Date::SECOND_SHORT: if (is_numeric($date)) { return $this->_assign($calc, $this->mktime(0, 0, intval($date), 1, 1, 1970, true), $this->mktime(0, 0, $second, 1, 1, 1970, true)); } throw new Zend_Date_Exception("invalid date ({$date}) operand, second expected", $date); break; // timezone formats // break intentionally omitted // timezone formats // break intentionally omitted case Zend_Date::TIMEZONE_NAME: case Zend_Date::TIMEZONE: case Zend_Date::TIMEZONE_SECS: throw new Zend_Date_Exception('timezone not supported', $date); break; case Zend_Date::DAYLIGHT: throw new Zend_Date_Exception('daylight not supported', $date); break; case Zend_Date::GMT_DIFF: case Zend_Date::GMT_DIFF_SEP: throw new Zend_Date_Exception('gmtdiff not supported', $date); break; // date strings // date strings case Zend_Date::ISO_8601: $next = 0; if (preg_match('/-\\d{4}-\\d{2}-\\d{2}/', $date, $datematch)) { // -yyyy-mm-dd $minus = true; $result = array('Y' => 1, 'M' => 6, 'd' => 9); $next = 11; } else { if (preg_match('/\\d{4}-\\d{2}-\\d{2}/', $date, $datematch)) { // yyyy-mm-dd $result = array('Y' => 0, 'M' => 5, 'd' => 8); $next = 10; } else { if (preg_match('/-\\d{2}-\\d{2}-\\d{2}/', $date, $datematch)) { // -yy-mm-dd $minus = true; $result = array('y' => 1, 'M' => 4, 'd' => 7); $next = 9; } else { if (preg_match('/\\d{2}-\\d{2}-\\d{2}/', $date, $datematch)) { // yy-mm-dd $result = array('y' => 0, 'M' => 3, 'd' => 6); $next = 8; } else { if (preg_match('/-\\d{8}/', $date, $datematch)) { // -yyyymmdd $minus = true; $result = array('Y' => 1, 'M' => 5, 'd' => 7); $next = 9; } else { if (preg_match('/\\d{8}/', $date, $datematch)) { // yyyymmdd $result = array('Y' => 0, 'M' => 4, 'd' => 6); $next = 8; } else { if (preg_match('/-\\d{6}/', $date, $datematch)) { // -yymmdd $minus = true; $result = array('y' => 1, 'M' => 3, 'd' => 5); $next = 7; } else { if (preg_match('/\\d{6}/', $date, $datematch)) { // yymmdd $result = array('y' => 0, 'M' => 2, 'd' => 4); $next = 6; } } } } } } } } if (strlen($date) > $next) { $date = substr($date, $next); // Thh:mm:ss if (preg_match('/[T,\\s]{1}\\d{2}:\\d{2}:\\d{2}/', $date, $timematch)) { // Thh:mm:ss | _hh:mm:ss $result['h'] = 1; $result['m'] = 4; $result['s'] = 7; $next += 9; } else { if (preg_match('/\\d{2}:\\d{2}:\\d{2}/', $date, $timematch)) { // hh:mm:ss $result['h'] = 0; $result['m'] = 3; $result['s'] = 6; $next += 8; } else { if (preg_match('/[T,\\s]{1}\\d{2}\\d{2}\\d{2}/', $date, $timematch)) { // Thhmmss | _hhmmss $result['h'] = 1; $result['m'] = 3; $result['s'] = 5; $next += 7; } else { if (preg_match('/\\d{2}\\d{2}\\d{2}/', $date, $timematch)) { // hhmmss | hhmmss $result['h'] = 0; $result['m'] = 2; $result['s'] = 4; $next += 6; } } } } } if (!isset($result)) { throw new Zend_Date_Exception("unsupported ISO8601 format ({$date})", $date); } if (isset($result['M'])) { if (isset($result['Y'])) { $years = substr($datematch[0], $result['Y'], 4); if (isset($minus)) { $years = 0 - $years; } } else { $years = substr($datematch[0], $result['y'], 2); if (isset($minus)) { $years = 0 - $years; } if ($years >= 0) { $years += 1900; if ($years < 1970) { $years += 100; } } } $months = substr($datematch[0], $result['M'], 2); $days = substr($datematch[0], $result['d'], 2); } else { $years = 1970; $months = 1; $days = 1; } if (isset($result['h'])) { $hours = substr($timematch[0], $result['h'], 2); $minutes = substr($timematch[0], $result['m'], 2); $seconds = substr($timematch[0], $result['s'], 2); } else { $hours = 0; $minutes = 0; $seconds = 0; } if ($calc == 'set') { --$months; --$month; --$days; --$day; $years -= 1970; $year -= 1970; } return $this->_assign($calc, $this->mktime($hours, $minutes, $seconds, 1 + $months, 1 + $days, 1970 + $years, false), $this->mktime($hour, $minute, $second, 1 + $month, 1 + $day, 1970 + $year, false)); break; case Zend_Date::RFC_2822: $result = preg_match('/\\w{3},\\s\\d{2}\\s\\w{3}\\s\\d{4}\\s\\d{2}:\\d{2}:\\d{2}\\s\\+\\d{4}/', $date, $match); if (!$result) { throw new Zend_Date_Exception("no RFC 2822 format ({$date})", $date); } $days = substr($match[0], 5, 2); $months = $this->getDigitFromName(substr($match[0], 8, 3)); $years = substr($match[0], 12, 4); $hours = substr($match[0], 17, 2); $minutes = substr($match[0], 20, 2); $seconds = substr($match[0], 23, 2); if ($calc == 'set') { --$months; --$month; --$days; --$day; $years -= 1970; $year -= 1970; } return $this->_assign($calc, $this->mktime($hours, $minutes, $seconds, 1 + $months, 1 + $days, 1970 + $years, false), $this->mktime($hour, $minute, $second, 1 + $month, 1 + $day, 1970 + $year, false)); break; case Zend_Date::TIMESTAMP: if (is_numeric($date)) { return $this->_assign($calc, $date, $this->getUnixTimestamp()); } throw new Zend_Date_Exception("invalid date ({$date}) operand, timestamp expected", $date); break; // additional formats // break intentionally omitted // additional formats // break intentionally omitted case Zend_Date::ERA: case Zend_Date::ERA_NAME: throw new Zend_Date_Exception('era not supported', $date); break; case Zend_Date::DATES: try { $parsed = Zend_Locale_Format::getCorrectableDate($date, null, $locale); if ($calc == 'set') { --$parsed['month']; --$month; --$parsed['day']; --$day; $parsed['year'] -= 1970; $year -= 1970; } return $this->_assign($calc, $this->mktime(0, 0, 0, 1 + $parsed['month'], 1 + $parsed['day'], 1970 + $parsed['year'], true), $this->mktime(0, 0, 0, 1 + $month, 1 + $day, 1970 + $year, true)); } catch (Zend_Locale_Exception $e) { throw new Zend_Date_Exception($e->getMessage(), $date); } break; case Zend_Date::DATE_FULL: try { $format = Zend_Locale_Data::getContent($locale, 'dateformat', array('gregorian', 'full')); $parsed = Zend_Locale_Format::getDate($date, $format['pattern'], $locale); if ($calc == 'set') { --$parsed['month']; --$month; --$parsed['day']; --$day; $parsed['year'] -= 1970; $year -= 1970; } return $this->_assign($calc, $this->mktime(0, 0, 0, 1 + $parsed['month'], 1 + $parsed['day'], 1970 + $parsed['year'], true), $this->mktime(0, 0, 0, 1 + $month, 1 + $day, 1970 + $year, true)); } catch (Zend_Locale_Exception $e) { throw new Zend_Date_Exception($e->getMessage(), $date); } break; case Zend_Date::DATE_LONG: try { $format = Zend_Locale_Data::getContent($locale, 'dateformat', array('gregorian', 'long')); $parsed = Zend_Locale_Format::getDate($date, $format['pattern'], $locale); if ($calc == 'set') { --$parsed['month']; --$month; --$parsed['day']; --$day; $parsed['year'] -= 1970; $year -= 1970; } return $this->_assign($calc, $this->mktime(0, 0, 0, 1 + $parsed['month'], 1 + $parsed['day'], 1970 + $parsed['year'], true), $this->mktime(0, 0, 0, 1 + $month, 1 + $day, 1970 + $year, true)); } catch (Zend_Locale_Exception $e) { throw new Zend_Date_Exception($e->getMessage(), $date); } break; case Zend_Date::DATE_MEDIUM: try { $format = Zend_Locale_Data::getContent($locale, 'dateformat', array('gregorian', 'medium')); $parsed = Zend_Locale_Format::getDate($date, $format['pattern'], $locale); if ($calc == 'set') { --$parsed['month']; --$month; --$parsed['day']; --$day; $parsed['year'] -= 1970; $year -= 1970; } return $this->_assign($calc, $this->mktime(0, 0, 0, 1 + $parsed['month'], 1 + $parsed['day'], 1970 + $parsed['year'], true), $this->mktime(0, 0, 0, 1 + $month, 1 + $day, 1970 + $year, true)); } catch (Zend_Locale_Exception $e) { throw new Zend_Date_Exception($e->getMessage(), $date); } break; case Zend_Date::DATE_SHORT: try { $format = Zend_Locale_Data::getContent($locale, 'dateformat', array('gregorian', 'short')); $parsed = Zend_Locale_Format::getDate($date, $format['pattern'], $locale); if ($parsed['year'] < 100) { $parsed['year'] += 1900; if ($parsed['year'] < 1970) { $parsed['year'] += 100; } } if ($calc == 'set') { --$parsed['month']; --$month; --$parsed['day']; --$day; $parsed['year'] -= 1970; $year -= 1970; } return $this->_assign($calc, $this->mktime(0, 0, 0, 1 + $parsed['month'], 1 + $parsed['day'], 1970 + $parsed['year'], true), $this->mktime(0, 0, 0, 1 + $month, 1 + $day, 1970 + $year, true)); } catch (Zend_Locale_Exception $e) { throw new Zend_Date_Exception($e->getMessage(), $date); } break; case Zend_Date::TIMES: try { $parsed = Zend_Locale_Format::getTime($date, false, $locale); return $this->_assign($calc, $this->mktime($parsed['hour'], $parsed['minute'], $parsed['second'], 1, 1, 1970, true), $this->mktime($hour, $minute, $second, 1, 1, 1970, true)); } catch (Zend_Locale_Exception $e) { throw new Zend_Date_Exception($e->getMessage(), $date); } break; case Zend_Date::TIME_FULL: try { $format = Zend_Locale_Data::getContent($locale, 'timeformat', array('gregorian', 'full')); $parsed = Zend_Locale_Format::getTime($date, $format['pattern'], $locale); return $this->_assign($calc, $this->mktime($parsed['hour'], $parsed['minute'], 0, 1, 1, 1970, true), $this->mktime($hour, $minute, $second, 1, 1, 1970, true)); } catch (Zend_Locale_Exception $e) { throw new Zend_Date_Exception($e->getMessage(), $date); } break; case Zend_Date::TIME_LONG: try { $format = Zend_Locale_Data::getContent($locale, 'timeformat', array('gregorian', 'long')); $parsed = Zend_Locale_Format::getTime($date, $format['pattern'], $locale); return $this->_assign($calc, $this->mktime($parsed['hour'], $parsed['minute'], $parsed['second'], 1, 1, 1970, true), $this->mktime($hour, $minute, $second, 1, 1, 1970, true)); } catch (Zend_Locale_Exception $e) { throw new Zend_Date_Exception($e->getMessage(), $date); } break; case Zend_Date::TIME_MEDIUM: try { $format = Zend_Locale_Data::getContent($locale, 'timeformat', array('gregorian', 'medium')); $parsed = Zend_Locale_Format::getTime($date, $format['pattern'], $locale); return $this->_assign($calc, $this->mktime($parsed['hour'], $parsed['minute'], $parsed['second'], 1, 1, 1970, true), $this->mktime($hour, $minute, $second, 1, 1, 1970, true)); } catch (Zend_Locale_Exception $e) { throw new Zend_Date_Exception($e->getMessage(), $date); } break; case Zend_Date::TIME_SHORT: try { $format = Zend_Locale_Data::getContent($locale, 'timeformat', array('gregorian', 'short')); $parsed = Zend_Locale_Format::getTime($date, $format['pattern'], $locale); return $this->_assign($calc, $this->mktime($parsed['hour'], $parsed['minute'], 0, 1, 1, 1970, true), $this->mktime($hour, $minute, $second, 1, 1, 1970, true)); } catch (Zend_Locale_Exception $e) { throw new Zend_Date_Exception($e->getMessage(), $date); } break; // ATOM and RFC_3339 are identical // ATOM and RFC_3339 are identical case Zend_Date::ATOM: case Zend_Date::RFC_3339: $result = preg_match('/\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\+\\d{2}:\\d{2}/', $date, $match); if (!$result) { throw new Zend_Date_Exception("invalid date ({$date}) operand, ATOM format expected", $date); } $years = substr($match[0], 0, 4); $months = substr($match[0], 5, 2); $days = substr($match[0], 8, 2); $hours = substr($match[0], 11, 2); $minutes = substr($match[0], 14, 2); $seconds = substr($match[0], 17, 2); if ($calc == 'set') { --$months; --$month; --$days; --$day; $years -= 1970; $year -= 1970; } return $this->_assign($calc, $this->mktime($hours, $minutes, $seconds, 1 + $months, 1 + $days, 1970 + $years, true), $this->mktime($hour, $minute, $second, 1 + $month, 1 + $day, 1970 + $year, true)); break; case Zend_Date::COOKIE: $result = preg_match('/\\w{6,9},\\s\\d{2}-\\w{3}-\\d{2}\\s\\d{2}:\\d{2}:\\d{2}\\s\\w{3}/', $date, $match); if (!$result) { throw new Zend_Date_Exception("invalid date ({$date}) operand, COOKIE format expected", $date); } $match[0] = substr($match[0], strpos($match[0], ' ') + 1); $days = substr($match[0], 0, 2); $months = $this->getDigitFromName(substr($match[0], 3, 3)); $years = substr($match[0], 7, 4); $years += 2000; $hours = substr($match[0], 10, 2); $minutes = substr($match[0], 13, 2); $seconds = substr($match[0], 16, 2); if ($calc == 'set') { --$months; --$month; --$days; --$day; $years -= 1970; $year -= 1970; } return $this->_assign($calc, $this->mktime($hours, $minutes, $seconds, 1 + $months, 1 + $days, 1970 + $years, true), $this->mktime($hour, $minute, $second, 1 + $month, 1 + $day, 1970 + $year, true)); break; case Zend_Date::RFC_822: // new RFC 822 format $result = preg_match('/\\w{3},\\s\\d{2}\\s\\w{3}\\s\\d{2}\\s\\d{2}:\\d{2}:\\d{2}\\s\\+\\d{4}/', $date, $match); if (!$result) { // old RFC 822 format $result = preg_match('/\\w{3},\\s\\d{2}\\s\\w{3}\\s\\d{2}\\s\\d{2}:\\d{2}:\\d{2}\\s\\w{1,3}/', $date, $match); } if (!$result) { throw new Zend_Date_Exception("invalid date ({$date}) operand, RFC 822 date format expected", $date); } $days = substr($match[0], 5, 2); $months = $this->getDigitFromName(substr($match[0], 8, 3)); $years = substr($match[0], 12, 4); $years += 2000; $hours = substr($match[0], 15, 2); $minutes = substr($match[0], 18, 2); $seconds = substr($match[0], 21, 2); if ($calc == 'set') { --$months; --$month; --$days; --$day; $years -= 1970; $year -= 1970; } return $this->_assign($calc, $this->mktime($hours, $minutes, $seconds, 1 + $months, 1 + $days, 1970 + $years, false), $this->mktime($hour, $minute, $second, 1 + $month, 1 + $day, 1970 + $year, false)); break; case Zend_Date::RFC_850: $result = preg_match('/\\w{6,9},\\s\\d{2}-\\w{3}-\\d{2}\\s\\d{2}:\\d{2}:\\d{2}\\s\\w{3}/', $date, $match); if (!$result) { throw new Zend_Date_Exception("invalid date ({$date}) operand, RFC 850 date format expected", $date); } $match[0] = substr($match[0], strpos($match[0], ' ') + 1); $days = substr($match[0], 0, 2); $months = $this->getDigitFromName(substr($match[0], 3, 3)); $years = substr($match[0], 7, 4); $years += 2000; $hours = substr($match[0], 10, 2); $minutes = substr($match[0], 13, 2); $seconds = substr($match[0], 16, 2); if ($calc == 'set') { --$months; --$month; --$days; --$day; $years -= 1970; $year -= 1970; } return $this->_assign($calc, $this->mktime($hours, $minutes, $seconds, 1 + $months, 1 + $days, 1970 + $years, true), $this->mktime($hour, $minute, $second, 1 + $month, 1 + $day, 1970 + $year, true)); break; case Zend_Date::RFC_1036: $result = preg_match('/\\w{3},\\s\\d{2}\\s\\w{3}\\s\\d{2}\\s\\d{2}:\\d{2}:\\d{2}\\s\\+\\d{4}/', $date, $match); if (!$result) { throw new Zend_Date_Exception("invalid date ({$date}) operand, RFC 1036 date format expected", $date); } $days = substr($match[0], 5, 2); $months = $this->getDigitFromName(substr($match[0], 8, 3)); $years = substr($match[0], 12, 4); $years += 2000; $hours = substr($match[0], 15, 2); $minutes = substr($match[0], 18, 2); $seconds = substr($match[0], 21, 2); if ($calc == 'set') { --$months; --$month; --$days; --$day; $years -= 1970; $year -= 1970; } return $this->_assign($calc, $this->mktime($hours, $minutes, $seconds, 1 + $months, 1 + $days, 1970 + $years, true), $this->mktime($hour, $minute, $second, 1 + $month, 1 + $day, 1970 + $year, true)); break; case Zend_Date::RFC_1123: $result = preg_match('/\\w{3},\\s\\d{2}\\s\\w{3}\\s\\d{4}\\s\\d{2}:\\d{2}:\\d{2}\\s\\+\\d{4}/', $date, $match); if (!$result) { throw new Zend_Date_Exception("invalid date ({$date}) operand, RFC 1123 date format expected", $date); } $days = substr($match[0], 5, 2); $months = $this->getDigitFromName(substr($match[0], 8, 3)); $years = substr($match[0], 12, 4); $hours = substr($match[0], 17, 2); $minutes = substr($match[0], 20, 2); $seconds = substr($match[0], 23, 2); if ($calc == 'set') { --$months; --$month; --$days; --$day; $years -= 1970; $year -= 1970; } return $this->_assign($calc, $this->mktime($hours, $minutes, $seconds, 1 + $months, 1 + $days, 1970 + $years, true), $this->mktime($hour, $minute, $second, 1 + $month, 1 + $day, 1970 + $year, true)); break; case Zend_Date::RSS: $result = preg_match('/\\w{3},\\s\\d{2}\\s\\w{3}\\s\\d{4}\\s\\d{2}:\\d{2}:\\d{2}\\s\\+\\d{4}/', $date, $match); if (!$result) { throw new Zend_Date_Exception("invalid date ({$date}) operand, RSS date format expected", $date); } $days = substr($match[0], 5, 2); $months = $this->getDigitFromName(substr($match[0], 8, 3)); $years = substr($match[0], 12, 4); $hours = substr($match[0], 17, 2); $minutes = substr($match[0], 20, 2); $seconds = substr($match[0], 23, 2); if ($calc == 'set') { --$months; --$month; --$days; --$day; $years -= 1970; $year -= 1970; } return $this->_assign($calc, $this->mktime($hours, $minutes, $seconds, 1 + $months, 1 + $days, 1970 + $years, true), $this->mktime($hour, $minute, $second, 1 + $month, 1 + $day, 1970 + $year, true)); break; case Zend_Date::W3C: $result = preg_match('/\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\+\\d{2}:\\d{2}/', $date, $match); if (!$result) { throw new Zend_Date_Exception("invalid date ({$date}) operand, W3C date format expected", $date); } $years = substr($match[0], 0, 4); $months = substr($match[0], 5, 2); $days = substr($match[0], 8, 2); $hours = substr($match[0], 11, 2); $minutes = substr($match[0], 14, 2); $seconds = substr($match[0], 17, 2); if ($calc == 'set') { --$months; --$month; --$days; --$day; $years -= 1970; $year -= 1970; } return $this->_assign($calc, $this->mktime($hours, $minutes, $seconds, 1 + $months, 1 + $days, 1970 + $years, true), $this->mktime($hour, $minute, $second, 1 + $month, 1 + $day, 1970 + $year, true)); break; default: if (!is_numeric($date)) { try { $parsed = Zend_Locale_Format::getCorrectableDate($date, $part, $locale); if ($calc == 'set') { if (isset($parsed['month'])) { --$parsed['month']; } else { $parsed['month'] = 0; } if (isset($parsed['day'])) { --$parsed['day']; } else { $parsed['day'] = 0; } if (isset($parsed['year'])) { $parsed['year'] -= 1970; } else { $parsed['year'] = 0; } } return $this->_assign($calc, $this->mktime(isset($parsed['hour']) ? $parsed['hour'] : 0, isset($parsed['minute']) ? $parsed['minute'] : 0, isset($parsed['second']) ? $parsed['second'] : 0, 1 + $parsed['month'], 1 + $parsed['day'], 1970 + $parsed['year'], false), $this->getUnixTimestamp()); } catch (Zend_Locale_Exception $e) { throw new Zend_Date_Exception($e->getMessage(), $date); } } return $this->_assign($calc, $date, $this->getUnixTimestamp()); // throw new Zend_Date_Exception("invalid date ($date) operand, timestamp expected", $date); break; } }
<?php echo $this->headMeta(); echo $this->headLink(); $id_hopdong = $this->param->getParam('mahopdong'); $fupdate = new Form_Update_Hopdong(); $fupdate->createForm($id_hopdong); if ($this->param->isPost()) { $param = $this->param->getPost(); $check = new Form_Valid_Hopdong($param); if ($check->valid($param)) { $mydate = Zend_Locale_Format::getDate($this->param->getParam("ngayky"), array("date_format" => "dd.MM.yyyy")); $date_str = $mydate['year'] . "-" . $mydate['month'] . "-" . $mydate['day']; $data = array("MaHopDong" => $id_hopdong, "TenHopDong" => $this->param->getParam("tenhopdong"), "MoTa" => $this->param->getParam("mota"), "NgayKy" => $date_str, "SoTanSoi" => $this->param->getParam("sotansoi"), "ThanhTien" => $this->param->getParam("thanhtien"), "MaMau" => $this->param->getParam("mamau"), "MaLoaiVai" => $this->param->getParam("maloaivai"), "MaNhaCungCap" => $this->param->getParam("manhacungcap")); $dh = new Model_Hopdong(); $dh->update_data($id_hopdong, $data); if (array_key_exists('option', $this->param->getParams())) { echo "<script>window.location.href='" . HOST_PROJECT . "/index/xem/hopdong/true';</script>"; } else { echo "<script>window.location.href='" . HOST_PROJECT . "/index/main/hopdong_detail/true/mahopdong/" . $this->param->getParam('mahopdong') . "/';</script>"; } } else { echo $fupdate; echo "<div class='message'>"; foreach ($check->messages as $item) { echo $item . "<br/>"; } echo "</div>"; } } else { echo $fupdate;
/** * test if getDate parses a date with fixed format * expected array */ public function testgetDateParsing27() { $value = Zend_Locale_Format::getDate('2006 10 Nov', false, 'de_AT'); $this->assertEquals($value['day'], 10, 'Day 10 expected'); $this->assertEquals($value['month'], 11, 'Month 11 expected'); $this->assertEquals($value['year'], 2006, 'Year 2006 expected'); }
/** * Checks if the given date is a real date or datepart. * Returns false if a expected datepart is missing or a datepart exceeds its possible border. * But the check will only be done for the expected dateparts which are given by format. * If no format is given the standard dateformat for the actual locale is used. * f.e. 30.February.2007 will return false if format is 'dd.MMMM.YYYY' * * @param string $date Date to parse for correctness * @param string $format (Optional) Format for parsing the date string * @param string|Zend_Locale $locale (Optional) Locale for parsing date parts * @return boolean True when all date parts are correct */ public static function isDate($date, $format = null, $locale = null) { if (!is_string($date) and !is_numeric($date) and !$date instanceof Zend_Date) { return false; } if ($format !== null and Zend_Locale::isLocale($format, null, false)) { $locale = $format; $format = null; } if (empty($locale)) { require_once 'Zend/Registry.php'; if (Zend_Registry::isRegistered('Zend_Locale') === true) { $locale = Zend_Registry::get('Zend_Locale'); } } if (!Zend_Locale::isLocale($locale, true, false)) { if (!Zend_Locale::isLocale($locale, false, false)) { require_once 'Zend/Date/Exception.php'; throw new Zend_Date_Exception("Given locale ({$locale}) does not exist", (string) $locale); } $locale = new Zend_Locale($locale); } $locale = (string) $locale; if ($format === null) { $format = Zend_Locale_Format::getDateFormat($locale); } else { if (self::$_options['format_type'] == 'php') { $format = Zend_Locale_Format::convertPhpToIsoFormat($format); } } try { $parsed = Zend_Locale_Format::getDate($date, array('locale' => $locale, 'date_format' => $format, 'format_type' => 'iso', 'fix_date' => false)); if (isset($parsed['year']) and (strpos(strtoupper($format), 'YY') !== false and strpos(strtoupper($format), 'YYYY') === false)) { $parsed['year'] = self::getFullYear($parsed['year']); } } catch (Zend_Locale_Exception $e) { // Date can not be parsed return false; } if ((strpos($format, 'Y') !== false or strpos($format, 'y') !== false) and !isset($parsed['year'])) { // Year expected but not found return false; } if (strpos($format, 'M') !== false and !isset($parsed['month'])) { // Month expected but not found return false; } if (strpos($format, 'd') !== false and !isset($parsed['day'])) { // Day expected but not found return false; } if ((strpos($format, 'H') !== false or strpos($format, 'h') !== false) and !isset($parsed['hour'])) { // Hour expected but not found return false; } if (strpos($format, 'm') !== false and !isset($parsed['minute'])) { // Minute expected but not found return false; } if (strpos($format, 's') !== false and !isset($parsed['second'])) { // Second expected but not found return false; } // Set not given dateparts if (isset($parsed['hour']) === false) { $parsed['hour'] = 0; } if (isset($parsed['minute']) === false) { $parsed['minute'] = 0; } if (isset($parsed['second']) === false) { $parsed['second'] = 0; } if (isset($parsed['month']) === false) { $parsed['month'] = 1; } if (isset($parsed['day']) === false) { $parsed['day'] = 1; } if (isset($parsed['year']) === false) { $parsed['year'] = 1970; } $date = new self($parsed, null, $locale); $timestamp = $date->mktime($parsed['hour'], $parsed['minute'], $parsed['second'], $parsed['month'], $parsed['day'], $parsed['year']); if ($parsed['year'] != $date->date('Y', $timestamp)) { // Given year differs from parsed year return false; } if ($parsed['month'] != $date->date('n', $timestamp)) { // Given month differs from parsed month return false; } if ($parsed['day'] != $date->date('j', $timestamp)) { // Given day differs from parsed day return false; } if ($parsed['hour'] != $date->date('G', $timestamp)) { // Given hour differs from parsed hour return false; } if ($parsed['minute'] != $date->date('i', $timestamp)) { // Given minute differs from parsed minute return false; } if ($parsed['second'] != $date->date('s', $timestamp)) { // Given second differs from parsed second return false; } return true; }
/** * Verifica se é uma string de data válida e retorna o array dela * * @param string $date * @param string $format OPCIONAL * @return array|NULL */ static function getData($date, $format = 'dd/MM/yyyy') { if (!empty($date) && parent::isDate($date, $format)) { return Zend_Locale_Format::getDate($date, array('date_format' => $format)); } return null; }
<?php echo $this->headMeta(); echo $this->headLink(); $dx = new Model_Donxuat(); $donxuatall = $dx->getAll(); if ($donxuatall) { $maincontent = array(); $title = array("Tên Đơn Xuất", "Ngày Xuất", "Thuộc Hợp Đồng", "Tùy Chỉnh"); $data = new My_Data(); foreach ($donxuatall as $donxuat) { $mydate = Zend_Locale_Format::getDate($donxuat['NgayXuat'], array("date_format" => "yyyy.MM.dd")); $date_str = $mydate['day'] . "/" . $mydate['month'] . "/" . $mydate['year']; $hd = new Model_Hopdong(); $myhopdong = $hd->getWhereIdHopDong($donxuat['MaHopDong']); $tendonxuat = "<a href='" . HOST_PROJECT . "/index/main/hopdong_detail/true/mahopdong/" . $myhopdong['MaHopDong'] . "/right/donxuat/madonxuat/" . $donxuat['MaDonXuat'] . "/'>" . $donxuat['TenDonXuat'] . "</a>"; $content = array($tendonxuat, $date_str, $myhopdong['TenHopDong'], '<a href="' . HOST_PROJECT . "/index/chinhsua/donxuat/true/madonxuat/" . $donxuat['MaDonXuat'] . '/option/donxuat/">Sửa</a> | ' . '<a href="' . HOST_PROJECT . "/index/xoa/donxuat/true/mahopdong/" . $myhopdong['TenHopDong'] . "/madonxuat/" . $donxuat['MaDonXuat'] . '/option/donxuat/" onclick="return confirm(' . "'bạn có chắc muốn xóa ?'" . ')">Xóa</a>'); $maincontent[] = $content; } $table = $data->createTable($title, $maincontent, "600px"); echo $table; } else { echo "<div class='message'>"; echo "Chưa tồn tại Đơn Xuất"; echo "</div>"; }
/** * @group GH-363 */ public function testZendLocaleDisableCacheShouldNotOverwritten() { Zend_Locale::disableCache(true); $value = Zend_Locale_Format::getDate('2014-01-01'); $this->assertFalse(Zend_Locale_Data::hasCache()); }