/** * 指定された年月にメッセージを送受信した日のリストを返す */ function db_message_is_message_list4date($u, $year, $month, $box) { include_once 'Date/Calc.php'; if ($box == 'inbox' || !$box) { $where = "c_member_id_to = ?" . " AND is_deleted_to = 0" . " AND is_send = 1"; } elseif ($box == 'outbox') { $where = "c_member_id_from = ?" . " AND is_deleted_from = 0" . " AND is_send = 1"; } else { return null; } if ($GLOBALS['_OPENPNE_DSN_LIST']['main']['dsn']['phptype'] == 'pgsql') { $sql = "SELECT DISTINCT date_part('day', r_datetime) FROM c_message" . " WHERE {$where}" . ' AND is_send=1 AND r_datetime >= ? AND r_datetime < ?'; } else { $sql = 'SELECT DISTINCT DAYOFMONTH(r_datetime) FROM c_message' . " WHERE {$where}" . ' AND is_send=1 AND r_datetime >= ? AND r_datetime < ?'; } $date_format = '%Y-%m-%d 00:00:00'; $thismonth = Date_Calc::beginOfMonth($month, $year, $date_format); $nextmonth = Date_Calc::beginOfNextMonth(0, $month, $year, $date_format); $params = array(intval($u), $thismonth, $nextmonth); return db_get_col($sql, $params); }
/** * A private method that returns the start and end dates * that bound the span, based based on a pre-defined 'friendly' * value. * * See the {@link OA_Admin_DaySpan::setSpanPresetValue()} method * for the pre-defined values. * * @param string $presetValue The preset value string. * @return array An array of two elements, "start" and "end", * representing the start and end dates of * the span, respectively. */ function _getSpanDates($presetValue) { switch ($presetValue) { case 'today': $oDateStart = new Date($this->oNowDate->format('%Y-%m-%d')); $oDateEnd = new Date($this->oNowDate->format('%Y-%m-%d')); break; case 'yesterday': $oDateStart = new Date(Date_Calc::prevDay($this->oNowDate->format('%d'), $this->oNowDate->format('%m'), $this->oNowDate->format('%Y'))); $oDateEnd = new Date(Date_Calc::prevDay($this->oNowDate->format('%d'), $this->oNowDate->format('%m'), $this->oNowDate->format('%Y'))); break; case 'this_week': $oDateStart = new Date(Date_Calc::beginOfWeek($this->oNowDate->format('%d'), $this->oNowDate->format('%m'), $this->oNowDate->format('%Y'))); $oSixDaySpan = new Date_Span(); $oSixDaySpan->setFromDays(6); $oSevenDaySpan = new Date_Span(); $oSevenDaySpan->setFromDays(7); // Now have week start and end when week starts on Sunday // Does the user want to start on a different day? $beginOfWeek = OA_Admin_DaySpan::getBeginOfWeek(); if ($beginOfWeek > 0) { $oRequiredDaysSpan = new Date_Span(); $oRequiredDaysSpan->setFromDays($beginOfWeek); $oDateStart->addSpan($oRequiredDaysSpan); $oDateToday = new Date($this->oNowDate->format('%Y-%m-%d')); if ($oDateToday->getDayOfWeek() < $beginOfWeek) { $oDateStart->subtractSpan($oSevenDaySpan); } } $oDateEnd = new Date($this->oNowDate->format('%Y-%m-%d')); break; case 'last_week': $oDateStart = new Date(Date_Calc::beginOfPrevWeek($this->oNowDate->format('%d'), $this->oNowDate->format('%m'), $this->oNowDate->format('%Y'))); $oSixDaySpan = new Date_Span(); $oSixDaySpan->setFromDays(6); $oSevenDaySpan = new Date_Span(); $oSevenDaySpan->setFromDays(7); // Now have week start and end when week starts on Sunday // Does the user want to start on a different day? $beginOfWeek = OA_Admin_DaySpan::getBeginOfWeek(); if ($beginOfWeek > 0) { $oRequiredDaysSpan = new Date_Span(); $oRequiredDaysSpan->setFromDays($beginOfWeek); $oDateStart->addSpan($oRequiredDaysSpan); $oDateToday = new Date($this->oNowDate->format('%Y-%m-%d')); if ($oDateToday->getDayOfWeek() < $beginOfWeek) { $oDateStart->subtractSpan($oSevenDaySpan); } } $oDateEnd = new Date($this->oNowDate->format('%Y-%m-%d')); $oDateEnd->copy($oDateStart); $oDateEnd->addSpan($oSixDaySpan); break; case 'last_7_days': $oDateStart = new Date($this->oNowDate->format('%Y-%m-%d')); $oDateEnd = new Date($this->oNowDate->format('%Y-%m-%d')); $oOneDaySpan = new Date_Span(); $oOneDaySpan->setFromDays(1); $oSevenDaySpan = new Date_Span(); $oSevenDaySpan->setFromDays(7); $oDateStart->subtractSpan($oSevenDaySpan); $oDateEnd->subtractSpan($oOneDaySpan); break; case 'this_month': $oDateStart = new Date(Date_Calc::beginOfMonth($this->oNowDate->format('%m'), $this->oNowDate->format('%Y'))); $oDateEnd = new Date($this->oNowDate->format('%Y-%m-%d')); break; case 'this_month_full': $oDateStart = new Date(Date_Calc::beginOfMonth($this->oNowDate->format('%m'), $this->oNowDate->format('%Y'))); $oDateEnd = new Date(Date_Calc::beginOfNextMonth($this->oNowDate->format('%d'), $this->oNowDate->format('%m'), $this->oNowDate->format('%Y'))); $oOneDaySpan = new Date_Span(); $oOneDaySpan->setFromDays(1); $oDateEnd->subtractSpan($oOneDaySpan); break; case 'this_month_remainder': $oDateStart = new Date($this->oNowDate->format('%Y-%m-%d')); $oDateEnd = new Date(Date_Calc::beginOfNextMonth($this->oNowDate->format('%d'), $this->oNowDate->format('%m'), $this->oNowDate->format('%Y'))); $oOneDaySpan = new Date_Span(); $oOneDaySpan->setFromDays(1); $oDateEnd->subtractSpan($oOneDaySpan); break; case 'next_month': $oDateStart = new Date(Date_Calc::beginOfNextMonth($this->oNowDate->format('%d'), $this->oNowDate->format('%m'), $this->oNowDate->format('%Y'))); $oDateEnd = new Date(Date_Calc::endOfNextMonth($this->oNowDate->format('%d'), $this->oNowDate->format('%m'), $this->oNowDate->format('%Y'))); break; case 'last_month': $oDateStart = new Date(Date_Calc::beginOfPrevMonth($this->oNowDate->format('%d'), $this->oNowDate->format('%m'), $this->oNowDate->format('%Y'))); $oDateEnd = new Date(Date_Calc::beginOfMonth($this->oNowDate->format('%m'), $this->oNowDate->format('%Y'))); $oOneDaySpan = new Date_Span(); $oOneDaySpan->setFromDays(1); $oDateEnd->subtractSpan($oOneDaySpan); break; case 'all_stats': $oDateStart = null; $oDateEnd = null; break; case 'specific': $startDate = MAX_getStoredValue('startDate', date('Y-m-d')); $oDateStart = new Date($startDate); $endDate = MAX_getStoredValue('endDate', date('Y-m-d')); $oDateEnd = new Date($endDate); break; } $this->_setStartDate($oDateStart); $this->_setEndDate($oDateEnd); $aDates = array('start' => $oDateStart, 'end' => $oDateEnd); return $aDates; }
/** * Draw the calendar's title bar * * @param day * @param month * @param year * * @access public * @return string of the rendered HTML */ function drawTitle($day, $month, $year) { $rv = ''; if ($this->_navLinks) { $path = $this->_path; if (!strchr($path, '?') && !strchr($this->_query, '?')) { $path .= '?'; } $rv .= sprintf("<a href='%s'\n><<</a> ", $path . Date_Calc::beginOfMonth($month, $year - 1, $this->_query)); $rv .= sprintf("<a href='%s'\n><</a> ", $path . Date_Calc::beginOfPrevMonth($day, $month, $year, $this->_query)); } $rv .= Date_Calc::dateFormat($day, $month, $year, $this->_options['title_format']); if ($this->_navLinks) { $rv .= sprintf(" <a href='%s'\n>></a>", $path . Date_Calc::beginOfNextMonth($day, $month, $year, $this->_query)); $rv .= sprintf(" <a href='%s'\n>>></a>", $path . Date_Calc::beginOfMonth($month, $year + 1, $this->_query)); } return $rv; }
/** * 指定された年月に日記を書いている日のリストを返す */ function p_h_diary_is_diary_written_list4date($year, $month, $c_member_id, $u = null) { include_once 'Date/Calc.php'; $pf_cond = db_diary_public_flag_condition($c_member_id, $u); if ($GLOBALS['_OPENPNE_DSN_LIST']['main']['dsn']['phptype'] == 'pgsql') { $sql = "SELECT DISTINCT date_part('day', r_datetime) FROM c_diary" . " WHERE c_member_id = ? AND r_datetime >= ? AND r_datetime < ?" . $pf_cond; } else { $sql = 'SELECT DISTINCT DAYOFMONTH(r_datetime) FROM c_diary' . ' WHERE c_member_id = ? AND r_datetime >= ? AND r_datetime < ?' . $pf_cond; } $date_format = '%Y-%m-%d 00:00:00'; $thismonth = Date_Calc::beginOfMonth($month, $year, $date_format); $nextmonth = Date_Calc::beginOfNextMonth(0, $month, $year, $date_format); $params = array(intval($c_member_id), $thismonth, $nextmonth); return db_get_col($sql, $params); }
$currentAccount->setFilter($filter); $currentAccount->setOrder($order); while ($currentTransaction = $currentAccount->getNextTransaction()) { $date = $currentTransaction->getValutaDate(); if (is_null($date)) { continue; } switch ($type) { case 'w': $dateKey = $date->getYear() . '-' . sprintf('%02d', $date->getWeekOfYear()); $beginDate = new Date(Date_Calc::beginOfWeek($date->getDay(), $date->getMonth(), $date->getYear(), '%Y-%m-%d')); $endDate = new Date(Date_Calc::endOfWeek($date->getDay(), $date->getMonth(), $date->getYear(), '%Y-%m-%d')); break; case 'm': $dateKey = $date->getYear() . '-' . sprintf('%02d', $date->getMonth()); $beginDate = new Date(Date_Calc::beginOfMonth($date->getMonth(), $date->getYear(), '%Y-%m-%d')); $endDate = new Date(Date_Calc::endOfMonthBySpan(0, $date->getMonth(), $date->getYear(), '%Y-%m-%d')); break; case 'q': $dateKey = $date->getYear() . '-' . $date->getQuarterOfYear(); switch ($date->getQuarterOfYear()) { case 1: $beginDate = new Date($date->getYear() . '-01-01'); $endDate = new Date($date->getYear() . '-03-31'); break; case 2: $beginDate = new Date($date->getYear() . '-04-01'); $endDate = new Date($date->getYear() . '-06-30'); break; case 3: $beginDate = new Date($date->getYear() . '-07-01');
compare('20001121', Date_Calc::prevDayOfWeekOnOrBefore('2', '22', '11', '2000'), 'prevDayOfWeekOnOrBefore 1 str'); compare('20001121', Date_Calc::prevDayOfWeekOnOrBefore(2, 22, 11, 2000), 'prevDayOfWeekOnOrBefore 1'); compare('20001122', Date_Calc::prevDayOfWeekOnOrBefore(3, 22, 11, 2000), 'prevDayOfWeekOnOrBefore 2'); compare('20001122', Date_Calc::nextDayOfWeekOnOrAfter(3, 22, 11, 2000), 'nextDayOfWeekOnOrAfter 1'); compare('20001123', Date_Calc::nextDayOfWeekOnOrAfter(4, 22, 11, 2000), 'nextDayOfWeekOnOrAfter 2'); compare('20001123', Date_Calc::nextDayOfWeekOnOrAfter('4', '22', '11', '2000'), 'nextDayOfWeekOnOrAfter 2 str'); compare('20001120', Date_Calc::beginOfWeek('22', '11', '2000'), 'beginOfWeek str'); compare('20001120', Date_Calc::beginOfWeek(22, 11, 2000), 'beginOfWeek'); compare('20001126', Date_Calc::endOfWeek(22, 11, 2000), 'endOfWeek'); compare('20001126', Date_Calc::endOfWeek('22', '11', '2000'), 'endOfWeek str'); compare('20001113', Date_Calc::beginOfPrevWeek(22, 11, 2000), 'beginOfPrevWeek'); compare('20001127', Date_Calc::beginOfNextWeek(22, 11, 2000), 'beginOfNextWeek'); compare('20001113', Date_Calc::beginOfPrevWeek('22', '11', '2000'), 'beginOfPrevWeek str'); compare('20001127', Date_Calc::beginOfNextWeek('22', '11', '2000'), 'beginOfNextWeek str'); compare('20001101', Date_Calc::beginOfMonth(11, 2000), 'beginOfMonth'); compare('20001101', Date_Calc::beginOfMonth('11', '2000'), 'beginOfMonth str'); compare('20001001', Date_Calc::beginOfPrevMonth(22, 11, 2000), 'beginOfPrevMonth'); compare('20001031', Date_Calc::endOfPrevMonth(22, 11, 2000), 'endOfPrevMonth'); compare('20001001', Date_Calc::beginOfPrevMonth('22', '11', '2000'), 'beginOfPrevMonth str'); compare('20001031', Date_Calc::endOfPrevMonth('22', '11', '2000'), 'endOfPrevMonth str'); compare('20001201', Date_Calc::beginOfNextMonth(22, 11, 2000), 'beginOfNextMonth'); compare('20001231', Date_Calc::endOfNextMonth(22, 11, 2000), 'endOfNextMonth'); compare('20001201', Date_Calc::beginOfNextMonth('22', '11', '2000'), 'beginOfNextMonth str'); compare('20001231', Date_Calc::endOfNextMonth('22', '11', '2000'), 'endOfNextMonth str'); compare('19991001', Date_Calc::beginOfMonthBySpan(-13, 11, 2000), 'beginOfMonthBySpan 1'); compare('20001001', Date_Calc::beginOfMonthBySpan(-1, 11, 2000), 'beginOfMonthBySpan 2'); compare('20001101', Date_Calc::beginOfMonthBySpan(0, 11, 2000), 'beginOfMonthBySpan 3'); compare('20001201', Date_Calc::beginOfMonthBySpan(1, 11, 2000), 'beginOfMonthBySpan 4'); compare('20011201', Date_Calc::beginOfMonthBySpan(13, 11, 2000), 'beginOfMonthBySpan 5'); compare('19990101', Date_Calc::beginOfMonthBySpan('-13', '02', '2000'), 'beginOfMonthBySpan 6 str'); compare('19990101', Date_Calc::beginOfMonthBySpan(-13, 2, 2000), 'beginOfMonthBySpan 6');