[ZF-10089] Zend_Log
[zend.git] / documentation / manual / zh / module_specs / Zend_Date-Overview.xml
blob2f5349b00fc655da6c958f3a9778f8a50368b521
1 <sect1 id="zend.date.overview">
2     <title>Zend_Date API 概述</title>
4     <para>
5         虽然 <code>Zend_Date</code> API 简单并单一,但是通过操作和操作数的丰富组合,它的设计灵活而强大。
6     </para>
8     <sect2 id="zend.date.options">
10         <title>Zend_Date 选项</title>
12         <sect3 id="zend.date.options.formattype">
14             <title>选择日期格式类型</title>
16             <para>
17                 有若干方法使用日期格式串,和 PHP 的 <code>date()</code> 类似。如果你觉得用 PHP 的日期格式指示器( specifier) 比用 ISO 格式指示器舒服,
18                 那么你可以使用 <code>Zend_Date::setOptions(array('format_type' => 'php'))</code> 。
19                 然后,对所有接受 <code>$format</code> 参数的函数使用 PHP 的日期格式指示器。
20                 使用 <code>Zend_Date::setOptions(array('format_type' => 'iso'))</code> 来切换回只支持 ISO 日期格式的缺省模式。
21                 所支持格式代码,参见 <xref linkend="zend.date.constants.phpformats" />
22             </para>
24         </sect3>
26         <sect3 id="zend.date.options.fixdst">
28             <title>DST 和日期数学 </title>
30             <para>
31                 当处理日期时,有时候需要考虑 DST(夏令时)更改的影响,一般是加上或减去一个小时。例如,在DST更改前加
32                 上月份到日期,如果结果是在DST更改之后,那么结果将会多或少一个小时。对于边界日期,如一个月的第一天或
33                 最后一天的午夜,添加足够的月份数来跨国日期边界会导致日期丢失一个小时并变成前面月份的最后一个小时,出现 "off by 1"  错误。
34                 为了避免这个情况发生,通过使用 <code>fix_dst</code> 选项来忽略 DST 更改。当跨过夏天/冬天 DST 边界,一般要加减一个小时。
35                 例如,如果日期的时间部分是 00:00:00, 日期算术跨过春季 DST 会导致日期比预期少一天。
36                 因为 Zend_Date 基于时间戳,而不是带有时间组件的日历日期,时间戳丢失一个小时导致日期在日历天上比预期少一天。
37                 为了防止这样的问题,使用选项 <code>fix_dst</code>,它缺省为 true,这样 DST 在日期“算术”(<code>addMOnth(), subMonth()</code>)里无效。
38                 当执行日期“算术“,使用 <code>Zend_Date::setOptions(array('fix_dst' => false))</code> 使日期加减考虑 DST 的调整。
39             </para>
41             <para>
42                 <emphasis role="strong">如果在<code>Zend_Date</code>实例里的当前时区设置为 UTC 或 GMT, 就不用 <code>'fix_dst'</code> 选项</emphasis>,
43                 这是因为这两个时区和 DST 没有关系。当你又为这个实例的时区修改为不是 UTC 或 GMT 的时区,那么先前设置的 'fix_dst'选项将用于日期“算术”。
44             </para>
45         </sect3>
47         <sect3 id="zend.date.options.extendmonth">
49             <title>月份计算</title>
51             <para>
52                 当从一个日期加减月份时,如果原来的日期接近月末,结果在某月的某天可能不是所期望的。
53                 例如,当 1月31日加上1个月是,熟悉 SQL的人将以为结果是 2月28日。另一方面,熟悉 Excel 和 OpenOffice的人将认为结果是 3月3日。
54                 这种问题只发生在这样的情况下:结果的月份里没有原来的月份的某天。
55                 对于 ZF 的开发者来说,使用 <code>extend_month</code> 选项,当它为 false,就用 SQL 的方式,当它为 true,就用电子表格(如 Excel) 的方式。
56                 <code>extend_month</code> 的缺省值为 false,和 SQL 方式兼容。
57                 缺省地,<code>Zend_Date</code>  通过截取日期的月末部分(如果有必要)来计算月份,当原始日期指定这个月的某天超过结果月的天数时,不需要把它包含到下个月。
58                 使用 <code>Zend_Date::setOptions(array('extend_month' => true));</code> 使月份计算就像流行的电子表格程序(如 Excel)一样。
59             </para>
61         </sect3>
63         <sect3 id="zend.date.options.cache">
65             <title> 用 Zend_Cache 加速日期本地化和标准化 </title>
67             <para>
68                 通过使用 <code>Zend_Cache</code> 适配器,你可以加速 <code>Zend_Date</code> 的运算。当你使用本地化的数据,<code>Zend_Date</code> 的所有方法都会加速。
69                 例如所有接受 <code>Zend_Date::DATE</code> 和 <code>Zend_Date::TIME</code> 常量的方法将会从中受益。
70                 用 <code>Zend_Date::setOptions(array('cache' => $adapter));</code>  就可给 <code>Zend_Date</code> 设置一个 <code>Zend_Cache</code>  适配器。
71             </para>
73         </sect3>
75         <sect3 id="zend.date.options.timesync">
77             <title> 用 Zend_TimeSync 同步时间戳 </title>
79             <para>
80                 一般来说服务器和计算机上的时钟都不相同。<code>Zend_TimeSync</code> 帮助 <code>Zend_Date</code>  来处理这样的问题。
81                 你可以用 <code>Zend_Date::setOptions(array('timesync' => $timeserver));</code>  来设置一个时间服务器,
82                 它将为所有 Zend_Date 的实例设置自己的实际时间戳和真实的实际时间戳之间的偏移量。使用这个选项不修改已存在的实例的时间戳。
83                 最好的用法是在引导(bootstrap)文件里设置它。
84             </para>
86         </sect3>
88     </sect2>
90     <sect2 id="zend.date.values">
92         <title> 使用日期值 </title>
94         <para>
95             一旦通过生成 <code>Zend_Date</code> 对象格式化输入,它就携带一个时区,但在内部用标准的 <ulink url="http://en.wikipedia.org/wiki/Unix_Time">UNIX 时间戳</ulink> 来表示。
96             为了使日期能够本地化解析,必需知道时区。缺省的时区总是 GMT/UTC。用 <code>getTimeZone())</code>  来检查对象的时区。
97             用 <code>setTimeZone())</code>  来修改对象的时区。这些对象的所有处理都假定和这个时区相关。
98         </para>
100         <para>
101             要小心不同时区之间的对象的混合和日期部件的匹配操作,它可能会产生不期望的结果,除非运算只和时间戳相关。
102             除了上述的情况,<code>Zend_Date</code> 对象的操作会处理不同的时区,因为在 <code>Zend_Date</code>  初始化时日期被格式化成时间戳。
103         </para>
105         <para>
106             大部分方法需要一个常量来选择需要的日期的<code>$part</code> ,例如 <code>Zend_Date::HOUR</code> 。
107             这些常量对下面的所有函数有效,常数列表参见这里 <xref linkend="zend.date.constants.list" /> 。
108             如果没有指定 <code>$part</code>,就使用 <code>Zend_Date::TIMESTAMP</code>。另外,也可以对 <code>$part</code> 使用用户指定的格式,
109             和 <link linkend="zend.locale.date.normalize"><code>Zend_Locale_Format::getDate()</code></link> 的基本机制和格式一样。
110             如果日期对象用明显的无效日期(如大于12的月份)来构造,那么 <code>Zend_Date</code>  将抛出异常,除非没有指定日期格式。例如,
111             <code>$part</code> 是 <code>null</code> 或者 <code>Zend_Date::DATES</code> ("宽松" 格式) 。
112         </para>
114         <example id="zend.date.values.example-1">
115             <title> 用户指定的日期输入格式 </title>
116             <programlisting role="php"><![CDATA[
117 $date1 = new Zend_Date('Feb 31, 2007', null, 'en_US');
118 echo $date1, "\n"; // outputs "Mar 3, 2007 12:00:00 AM"
120 $date2 = new Zend_Date('Feb 31, 2007', Zend_Date::DATES, 'en_US');
121 echo $date2, "\n"; // outputs "Mar 3, 2007 12:00:00 AM"
123 // strictly restricts interpretation to specified format
124 $date3 = new Zend_Date('Feb 31, 2007', 'MM.dd.yyyy');
125 echo $date3, "\n"; // outputs "Mar 3, 2007 12:00:00 AM"
127             </programlisting>
128         </example>
130         <para>
131             如果提供了可选的 <code>$locale</code> 参数,那么 <code>$locale</code> 通过给 <code>$date</code> 操作数替换月和星期名来消除它的歧义,
132             即使根据那个地方的约定来解析日期字符串 (参见 <code><link linkend="zend.locale.date.normalize">Zend_Locale_Format::getDate()</link></code>)。
133             当 <code>$part</code>  是 <code>Zend_Date::DATE*</code> 或 <code>Zend_Date::TIME*</code> 常量其中之一,本地化的字符串类型的 <code>$date</code> 就自动格式化。
134             如果 <code>$date</code> 是包含日期的字符串,语言的地方标识符要用来解析月和星期的名字。
135             如果没有 <code>$date</code>  输入参数,那么 <code>$locale</code> 参数指定地方来用于本地化输出(例如,日期格式的字符串表示)。
136             注意 <code>$date</code>  输入参数可能实际有类型名 (例如 <code>$hour</code> 对于 <code>addHour()</code>),尽管它不能防止用 <code>Zend_Date</code> 对象作为参数。
137             如果没有指定 <code>$locale</code> ,那么当前对象的地方用于解释 <code>$date</code>,或选择本地化的格式来输出。
138         </para>
139              <para>
140         从 Zend Framework 1.7.0 开始,<code>Zend_Date</code> 也支持程序范围的地方的用法。你可以简单地如下设置 <code>Zend_Locale</code> 实例到注册表。
141         如果你想多次使用同一地方,用这个符号你不需要记住对每个实例手工设置地方。
142      </para>
144     <programlisting role="php"><![CDATA[
145 // in your bootstrap file
146 $locale = new Zend_Locale('de_AT');
147 Zend_Registry::set('Zend_Locale', $locale);
149 // somewhere in your application
150 $date = new Zend_Date('31.Feb.2007');
152     </programlisting>
154     </sect2>
156     <sect2 id="id.date.basic">
158         <title>Basic <code>Zend_Date</code> Operations Common to Many Date Parts</title>
160         <para>
161             <code>add(), sub(), compare(), get(), and set()</code> 方法一般用来操作日期,就是操作对象里的日期。
162             除了 <code>get()</code>以外,<code>$date</code> 操作数对所有这些方法是必需的,它可能是 <code>Zend_Date</code>  实例对象、数字字符串或一个整数。
163             如果 <code>$date</code> 不是对象,这些方法就假定它是时间戳。然而,<code>$part</code> 操作数控制两个日期的逻辑部分,允许操作对象的日期的部件,如年或分钟,
164             即使 <code>$date</code> 包含一个长格式日期字符串,如 "December 31, 2007 23:59:59" 。
165             除了 <code>compare()</code> 和 <code>get()</code> 外,操作的结果是在对象里修改日期。
166         </para>
168         <example id="zend.date.basic.example-1">
169             <title> 日期部件的操作 </title>
170             <programlisting role="php"><![CDATA[
171 $date = new Zend_Date(); // $date's timestamp === time()
173 // changes $date by adding 12 hours
174 $date->add('12', Zend_Date::HOUR);
175 print $date;
177             </programlisting>
178         </example>
180         <para>
181             下表显示了基本操作的每个组合和若干普通的日期部件的方便方法。当使用上述一般的方法时,这些方便的方法帮助我们懒惰的程序员避免在<link linkend="zend.date.constants.list"> 日期部件常量 </link> 方面的打字。
182             方便地,它们的名称由前缀(基本操作名)和后缀(日期部件类型)的组成,如 <code>addYear()</code> 。
183             在下面列表中,能看到所有“日期部件”和“基本操作”的组合。例如,"add"操作适用于这些日期部件,包括 <code>addDay()</code>、 <code>addYear()</code> 等。
184         </para>
186         <para>
187             这些方便的方法和基本操作方法有相同的功能,但期望字符串和整数的 <code>$date</code> 操作数只包含表示由方便方法的后缀指示的类型的值。
188             这样,当<code>$date</code>是字符串或整数时, 这些方法的名字(如"Year" 或 "Minute")能确定 <code>$date</code>  操作数的单元。
189         </para>
191         <sect3 id="id.date.basic.parts">
193             <title> 日期部件列表 </title>
195             <table id="id.date.basic.parts.table">
196                 <title>日期部件</title>
197                 <tgroup cols="2">
198                     <thead>
199                         <row>
200                             <entry>日期部件</entry>
201                             <entry>解释</entry>
202                         </row>
203                     </thead>
204                     <tbody>
205                         <row>
206                             <entry>
207                                 <ulink url="http://en.wikipedia.org/wiki/Unix_Time">时间戳</ulink>
208                             </entry>
209                             <entry>
210                             UNIX 时间戳,表示从 January 1st, 1970 00:00:00 GMT/UTC 开始的秒数。
211                         </entry>
212                         </row>
213                         <row>
214                             <entry>
215                                 <ulink url="http://en.wikipedia.org/wiki/Gregorian_calendar">年</ulink>
216                             </entry>
217                             <entry> 罗马教皇日历年(如 2006)</entry>
218                         </row>
219                         <row>
220                             <entry>
221                                 <ulink url="http://en.wikipedia.org/wiki/Month#Julian_and_Gregorian_calendars">月</ulink>
222                             </entry>
223                             <entry> 罗马教皇日历月(1-12, 支持本地化名字)</entry>
224                         </row>
225                         <row>
226                             <entry>
227                                 <ulink url="http://en.wikipedia.org/wiki/24-hour_clock">24 小时时钟 </ulink>
228                             </entry>
229                             <entry>一天的小时数(0-23),表示从一天开始算起过去的小时数。</entry>
230                         </row>
231                         <row>
232                             <entry>
233                                 <ulink url="http://en.wikipedia.org/wiki/Minute">分钟</ulink>
234                             </entry>
235                             <entry>一小时的分钟数(0-59),表示从一小时开始算起过去的分钟数。</entry>
236                         </row>
237                         <row>
238                             <entry>
239                                 <ulink url="http://en.wikipedia.org/wiki/Second">秒</ulink>
240                             </entry>
241                             <entry>一分钟的秒数(0-59),表示从一分钟开始算起过去的秒数。</entry>
242                         </row>
243                         <row>
244                             <entry>
245                                 <ulink url="http://en.wikipedia.org/wiki/Millisecond">毫秒</ulink>
246                             </entry>
247                             <entry>
248                                 毫秒表示千分之一秒(0-999)。<code>Zend_Date</code> 支持两个另外的方法来支持小于秒的时间单位。
249                                 缺省地,<code>Zend_Date</code>  实例精确到毫秒,如 <code>getFractionalPrecision()</code> ,我们用 <code>setFractionalPrecision($precision)</code> 来修改精确度。
250                                 然而,因为 <code>Zend_Date</code> 使用 <code><ulink url="http://php.net/microtime">microtime()</ulink></code>,精确度实际上限制到微秒。
251                             </entry>
252                         </row>
253                         <row>
254                             <entry>
255                                 <ulink url="http://en.wikipedia.org/wiki/Day">天</ulink>
256                             </entry>
257                             <entry>
258                                 如果 <code>$date</code>  操作数是 <code>Zend_Date</code> 的实例或一个数字字符串,<code>Zend_Date::DAY_SHORT</code> 是从 <code>$date</code> 里取出。
259                                 否则,根据这些文档 <code>Zend_Date::WEEKDAY_NARROW</code>、
260                                 <code>Zend_Date::WEEKDAY_NAME</code>、 <code>Zend_Date::WEEKDAY_SHORT</code> 和 <code>Zend_Date::WEEKDAY</code> (假定为罗马教皇日历)的惯例尝试从天里取出。
261                             </entry>
262                         </row>
263                         <row>
264                             <entry>
265                                 <ulink url="http://en.wikipedia.org/wiki/Week">星期</ulink>
266                             </entry>
267                             <entry>
268                                 如果 <code>$date</code>  操作数是 <code>Zend_Date</code> 的实例或一个数字字符串,<code>Zend_Date::WEEK</code> 是从 <code>$date</code> 里取出。
269                                 否则产生一个异常。(假定为罗马教皇日历)
270                              </entry>
271                         </row>
272                         <row>
273                             <entry>日期</entry>
274                             <entry>
275                                 如果 <code>$date</code>  操作数是 <code>Zend_Date</code> 的实例或一个数字字符串,<code>Zend_Date::DAY_MEDIUM</code> 是从 <code>$date</code> 里取出。
276                                 否则就尝试格式化 <code>$date</code>  字符串成 Zend_Date::DATE_MEDIUM  日期格式。
277                                 <code>Zend_Date::DAY_MEDIUM</code>  格式根据地方的不同而不同。
278                             </entry>
279                         </row>
280                         <row>
281                             <entry>Weekday</entry>
282                             <entry>
283                                 Weekdays 表示为从 0 (星期日) 到 6 (星期六).
284                                 如果 <code>$date</code>  操作数是 <code>Zend_Date</code> 的实例或一个数字字符串,<code>Zend_Date::WEEKDAY_DIGIT</code> 是从 <code>$date</code> 里取出。
285                                 否则,根据这些文档 <code>Zend_Date::WEEKDAY_NARROW</code>、
286                                 <code>Zend_Date::WEEKDAY_NAME</code>、 <code>Zend_Date::WEEKDAY_SHORT</code> 和 <code>Zend_Date::WEEKDAY</code> (假定为罗马教皇日历)的惯例尝试从天里取出。
287                             </entry>
288                         </row>
289                         <row>
290                             <entry>DayOfYear</entry>
291                             <entry>
292                                 在 <code>Zend_Date</code>,一年中的天表示从一年开始发生的日历天数(0-365)。和其它上述单元一样,小数四舍五入到最近的整数。(假定为罗马教皇日历)
293                             </entry>
294                         </row>
295                         <row>
296                             <entry>
297                                 <ulink url="http://www.faqs.org/rfcs/rfc822.html">Arpa</ulink>
298                             </entry>
299                             <entry>
300                                 我们支持 Arpa 日期(如 RFC 822 格式日期)。输出使用 "GMT"  或 "Local differential hours+min"  格式(见第5节的 RFC 822)。
301                                 在 PHP 5.2.2 以前,一起使用 DATE_RFC822 常量和 PHP 日期函数有时会产生 <ulink url="http://bugs.php.net/bug.php?id=40308">不正确的结果</ulink>。
302                                 Zend_Date 的结果是正确的。例如 <code>Mon, 31 Dec 06 23:59:59 GMT</code> 。
303                             </entry>
304                         </row>
305                         <row>
306                             <entry>
307                                 <ulink url="http://en.wikipedia.org/wiki/ISO_8601">Iso</ulink>
308                             </entry>
309                             <entry>
310                                 对于输出只支持完全的 ISO 8601 日期。例如:<code>2009-02-14T00:31:30+01:00</code>
311                             </entry>
312                         </row>
313                     </tbody>
314                 </tgroup>
315             </table>
317         </sect3>
319         <sect3 id="id.date.basic.operations">
321             <title>List of Date Operations 日期操作列表</title>
323             <para>
324                 如果 <link linkend="zend.date.constants.list"> 合适的常量 </link> 用于 <code>$part</code> 参数,
325                 对特定日期部件,下列基本操作可用来代替方便操作。
326             </para>
328             <table id="id.date.basic.operations.table">
329                 <title>基本操作</title>
330                 <tgroup cols="2">
331                     <thead>
332                         <row>
333                             <entry>基本操作</entry>
334                             <entry>解释</entry>
335                         </row>
336                     </thead>
337                     <tbody>
338                         <row>
339                             <entry>get()</entry>
340                             <entry>
341                                 <para>
342                                     <emphasis role="strong">get($part = null, $locale = null)</emphasis>
343                                 </para>
344                                 <para>
345                                     使用 <code>get($part)</code>  来获取这个对象的本地化到 <code>$locale</code> 为格式的字符串或整数的日期的 <code>$part</code> 。
346                                     当使用 BCMath 扩展,对大的值返回数字字符串而不是整数。
347                                     <emphasis role="strong">注:</emphasis> 不像 <code>get()</code>,其它 get*()  方便方法只返回 <code>Zend_Date</code>  的实例,
348                                     该实例包含一个表示选择的或计算的日期/时间的日期。
349                                 </para>
350                             </entry>
351                         </row>
352                         <row>
353                             <entry>set()</entry>
354                             <entry>
355                                 <para>
356                                     <emphasis role="strong">set($date, $part = null, $locale = null)</emphasis>
357                                 </para>
358                                 <para>
359                                     对从带有 <code>$locale</code> 地方的输入 <code>$date</code> 找到的部件设置当前对象的 <code>$part</code> 一个相应的值。
360                                 </para>
361                             </entry>
362                         </row>
363                         <row>
364                             <entry>add()</entry>
365                             <entry>
366                                 <para>
367                                     <emphasis role="strong">add($date, $part = null, $locale = null)</emphasis>
368                                 </para>
369                                 <para>
370                                     加上带有  <code>$locale</code>  地方的 <code>$date</code> 的 <code>$part</code> 到当前对象的日期。
371                                 </para>
372                             </entry>
373                         </row>
374                         <row>
375                             <entry>sub()</entry>
376                             <entry>
377                                 <para>
378                                     <emphasis role="strong">sub($date, $part = null, $locale = null)</emphasis>
379                                 </para>
380                                 <para>
381                                     从当前对象的日期减去 加上带有  <code>$locale</code>  地方的 <code>$date</code> 的 <code>$part</code> 。
382                                 </para>
383                             </entry>
384                         </row>
385                         <row>
386                             <entry>copyPart()</entry>
387                             <entry>
388                                 <para>
389                                     <emphasis role="strong">copyPart($part, $locale = null)</emphasis>
390                                 </para>
391                                 <para>
392                                     返回一个克隆的对象,只带有拷贝到克隆的对象的日期的 <code>$part</code> ,克隆带有它自己的地方任意地设置为 <code>$locale</code> (如果指定)。
393                                 </para>
394                             </entry>
395                         </row>
396                         <row>
397                             <entry>compare()</entry>
398                             <entry>
399                                 <para>
400                                     <emphasis role="strong">compare($date, $part = null, $locale = null)</emphasis>
401                                 </para>
402                                 <para>
403                                     比较 <code>$date</code> 的 <code>$part</code> 和这个对象的时间戳,如果相等返回 0,如果对象部分更晚,返回1,否则返回 -1。
404                                 </para>
405                             </entry>
406                         </row>
407                     </tbody>
408                 </tgroup>
409             </table>
411         </sect3>
413     </sect2>
415     <sect2 id="zend.date.others.comparison">
417         <title> 比较日期 </title>
419         <para>
420              对于列表在 <xref linkend="zend.date.overview" />的日期部件,下列基本操作没有相应的方便方法。
421         </para>
423         <table id="zend.date.others.comparison.table">
424             <title> 日期比较方法 </title>
425             <tgroup cols="2">
426                 <thead>
427                     <row>
428                         <entry>方法</entry>
429                         <entry>解释</entry>
430                     </row>
431                 </thead>
432                 <tbody>
433                     <row>
434                         <entry>equals()</entry>
435                         <entry>
436                             <para>
437                                 <emphasis role="strong">equals($date, $part = null, $locale = null)</emphasis>
438                             </para>
439                             <para>
440                                 如果有 <code>$locale</code> 地方的 <code>$date</code> 的 <code>$part</code> 和这个对象的 <code>$part</code> 一样,返回 true,否则返回 false。
441                              </para>
442                         </entry>
443                     </row>
444                     <row>
445                         <entry>isEarlier()</entry>
446                         <entry>
447                             <para>
448                                 <emphasis role="strong">isEarlier($date, $part = null, $locale = null)</emphasis>
449                             </para>
450                             <para>
451                                  如果对象的日期的 <code>$part</code> 早于 有 <code>$locale</code> 地方的 <code>$date</code> 的 <code>$part</code> ,返回 true。
452                             </para>
453                         </entry>
454                     </row>
455                     <row>
456                         <entry>isLater()</entry>
457                         <entry>
458                             <para>
459                                 <emphasis role="strong">isLater($date, $part = null, $locale = null)</emphasis>
460                             </para>
461                             <para>
462                                如果对象的日期的 <code>$part</code> 晚于有 <code>$locale</code> 地方的 <code>$date</code> 的 <code>$part</code> ,返回 true。
463                             </para>
464                         </entry>
465                     </row>
466                     <row>
467                         <entry>isToday()</entry>
468                         <entry>
469                             <para>
470                                 <emphasis role="strong">isToday()</emphasis>
471                             </para>
472                             <para>
473                                  测试是否今天的年、月、日匹配这个对象的日期值,使用对象的时区。
474                             </para>
475                         </entry>
476                     </row>
477                     <row>
478                         <entry>isTomorrow()</entry>
479                         <entry>
480                             <para>
481                                 <emphasis role="strong">isTomorrow()</emphasis>
482                             </para>
483                             <para>
484                                 测试是否明天的年、月、日匹配这个对象的日期值,使用对象的时区。
485                             </para>
486                         </entry>
487                     </row>
488                     <row>
489                         <entry>isYesterday()</entry>
490                         <entry>
491                             <para>
492                                 <emphasis role="strong">isYesterday()</emphasis>
493                             </para>
494                             <para>
495                                 测试是否昨天的年、月、日匹配这个对象的日期值,使用对象的时区。
496                             </para>
497                         </entry>
498                     </row>
499                     <row>
500                         <entry>isLeapYear()</entry>
501                         <entry>
502                             <para>
503                                 <emphasis role="strong">isLeapYear()</emphasis>
504                             </para>
505                             <para>
506                                 使用 <code>isLeapYear()</code> 来确定当前对象是否闰年,或使用  Zend_Date::checkLeapYear($year) 来
507                                 检查 $year,它可以是字符串、整数或 <code>Zend_Date</code>  的实例。这个年是闰年吗?
508                             </para>
509                         </entry>
510                     </row>
511                     <row>
512                         <entry>isDate()</entry>
513                         <entry>
514                             <para>
515                                 <emphasis role="strong">isDate($date, $format = null, $locale = null)</emphasis>
516                             </para>
517                             <para>
518                                 这个方法检查给定的日期是否一个真实的日期并且如果所有检查通过返回 true。
519                                 它和 php 的 checkdate() 函数一样但也检查本地化月名和扩展了 checkdate() 范围的日期。
520                             </para>
521                         </entry>
522                     </row>
523                 </tbody>
524             </tgroup>
525         </table>
527     </sect2>
529     <sect2 id="zend.date.others.gettingparts">
531         <title>获取日期和日期部件</title>
533         <para>
534             有若干方法支持获取和 <code>Zend_Date</code> 实例相关的值。
535         </para>
537         <table id="zend.date.others.gettingparts.table">
538             <title>日期输出方法</title>
539             <tgroup cols="2">
540                 <thead>
541                     <row>
542                         <entry>方法</entry>
543                         <entry>解释</entry>
544                     </row>
545                 </thead>
546                 <tbody>
547                     <row>
548                         <entry>toString()</entry>
549                         <entry>
550                             <para>
551                                 <emphasis role="strong">toString($format = null, $locale = null)</emphasis>
552                             </para>
553                             <para>
554                                 直接调用或通过魔术方法 <code>__toString()</code> 。<code>toString()</code> 根据对象地方(或可选地指定 <code>$locale</code>)的约定
555                                 来自动格式化日期对象的值。支持的格式代码列表,参见 <xref linkend="zend.date.constants.selfdefinedformats" /> 。
556                             </para>
557                         </entry>
558                     </row>
559                     <row>
560                         <entry>toArray()</entry>
561                         <entry>
562                             <para>
563                                 <emphasis role="strong">toArray()</emphasis>
564                             </para>
565                             <para>
566                                 根据对象的地方的约定返回选择的日期的表示的数组。返回数组和 PHP 的 <ulink url="http://php.net/getdate">getdate()</ulink>
567                                 函数相同并包括:
568                             </para>
569                             <para>
570                                 <itemizedlist>
571                                     <listitem>
572                                         <para>
573                                             Number of day as '<emphasis role="strong">day</emphasis>'
574                                             (<code>Zend_Date::DAY_SHORT</code>)
575                                         </para>
576                                     </listitem>
577                                     <listitem>
578                                         <para>
579                                             Number of month as '<emphasis role="strong">month</emphasis>'
580                                             (<code>Zend_Date::MONTH_SHORT</code>)
581                                         </para>
582                                     </listitem>
583                                     <listitem>
584                                         <para>
585                                             Year as '<emphasis role="strong">year</emphasis>'
586                                             (<code>Zend_Date::YEAR</code>)
587                                         </para>
588                                     </listitem>
589                                     <listitem>
590                                         <para>
591                                             Hour as '<emphasis role="strong">hour</emphasis>'
592                                             (<code>Zend_Date::HOUR_SHORT</code>)
593                                         </para>
594                                     </listitem>
595                                     <listitem>
596                                         <para>
597                                             Minute as '<emphasis role="strong">minute</emphasis>'
598                                             (<code>Zend_Date::MINUTE_SHORT</code>)
599                                         </para>
600                                     </listitem>
601                                     <listitem>
602                                         <para>
603                                             Second as '<emphasis role="strong">second</emphasis>'
604                                             (<code>Zend_Date::SECOND_SHORT</code>)
605                                         </para>
606                                     </listitem>
607                                     <listitem>
608                                         <para>
609                                             Abbreviated timezone as '<emphasis role="strong">timezone</emphasis>'
610                                             (<code>Zend_Date::TIMEZONE</code>)
611                                         </para>
612                                     </listitem>
613                                     <listitem>
614                                         <para>
615                                             Unix timestamp as '<emphasis role="strong">timestamp</emphasis>'
616                                             (<code>Zend_Date::TIMESTAMP</code>)
617                                         </para>
618                                     </listitem>
619                                     <listitem>
620                                         <para>
621                                             Number of weekday as '<emphasis role="strong">weekday</emphasis>'
622                                             (<code>Zend_Date::WEEKDAY_DIGIT</code>)
623                                         </para>
624                                     </listitem>
625                                     <listitem>
626                                         <para>
627                                             Day of year as '<emphasis role="strong">dayofyear</emphasis>'
628                                             (<code>Zend_Date::DAY_OF_YEAR</code>)
629                                         </para>
630                                     </listitem>
631                                     <listitem>
632                                         <para>
633                                             Week as '<emphasis role="strong">week</emphasis>'
634                                             (<code>Zend_Date::WEEK</code>)
635                                         </para>
636                                     </listitem>
637                                     <listitem>
638                                         <para>
639                                             Delay of timezone to GMT as
640                                             '<emphasis role="strong">gmtsecs</emphasis>'
641                                             (<code>Zend_Date::GMT_SECS</code>)
642                                         </para>
643                                     </listitem>
644                                 </itemizedlist>
645                             </para>
646                         </entry>
647                     </row>
648                     <row>
649                         <entry>toValue()</entry>
650                         <entry>
651                             <para>
652                                 <emphasis role="strong">toValue($part = null)</emphasis>
653                             </para>
654                             <para>
655                                 根据对象的地方的约定返回一个整数的选择的日期 <code>$part</code> 表示。
656                                 当 <code>$part</code>选择非数字值,如 <code>Zend_Date::MONTH_NAME_SHORT</code> ,返回 <code>false</code>。
657                                 <emphasis role="strong">注:</emphasis>这个方法调用 <link linkend="id.date.basic.operations"><code>get()</code></link>
658                                 并把结果做成 PHP 整数,如果  <code>get()</code> 返回一个包含对于你的系统的PHP太大的数的字符串,结果不可预计。
659                                 使用 <code>get()</code> 作为替换。
661                             </para>
662                         </entry>
663                     </row>
664                     <row>
665                         <entry>
666                             <link linkend="id.date.basic.operations">get()</link>
667                         </entry>
668                         <entry>
669                             <para>
670                                 <emphasis role="strong">get($part = null, $locale = null)</emphasis>
671                             </para>
672                             <para>
673                                 这个方法返回对象根据 <code>$locale</code> 本地化的日期的 <code>$part</code>,格式为字符串或整数。
674                                 更多信息参见<xref linkend="id.date.basic.operations" />。
675                             </para>
676                         </entry>
677                     </row>
678                     <row>
679                         <entry>now()</entry>
680                         <entry>
681                             <para>
682                                 <emphasis role="strong">now($locale = null)</emphasis>
683                             </para>
684                             <para>
685                                 这个方便函数和 <code>new Zend_Date()</code> 相同。它以<code>Zend_Date</code>对象返回当前日期,有 <code>$locale</code> 。
686                             </para>
687                         </entry>
688                     </row>
689                 </tbody>
690             </tgroup>
691         </table>
693     </sect2>
695     <sect2 id="zend.date.others.fractions">
697         <title> 使用秒的片段 </title>
699         <para>
700             Several methods support retrieving values related to a <code>Zend_Date</code> instance.
701         </para>
703         <table id="zend.date.others.fractions.table">
704             <title> 日期输出方法 </title>
705             <tgroup cols="2">
706                 <thead>
707                     <row>
708                         <entry>方法</entry>
709                         <entry>解释</entry>
710                     </row>
711                 </thead>
712                 <tbody>
713                     <row>
714                         <entry>
715                             <para>
716                                 <emphasis role="strong">getFractionalPrecision()</emphasis>
717                             </para>
718                         </entry>
719                         <entry> 返回秒的精度 </entry>
720                     </row>
721                     <row>
722                         <entry>
723                             <para>
724                                 <emphasis role="strong">setFractionalPrecision()</emphasis>
725                             </para>
726                         </entry>
727                         <entry> 设置秒的精度 </entry>
728                     </row>
729                 </tbody>
730             </tgroup>
731         </table>
733     </sect2>
735     <sect2 id="zend.date.other.sun">
737         <title> 日出 / 日落 </title>
739         <para>
740             有三个方法提供访问关于太阳的地理本地化信息,包括日出和日落的时间。
741         </para>
743         <table id="zend.date.other.sun.table">
744             <title> 辅助方法 </title>
745             <tgroup cols="2">
746                 <thead>
747                     <row>
748                         <entry>方法</entry>
749                         <entry>解释</entry>
750                     </row>
751                 </thead>
752                 <tbody>
753                     <row>
754                         <entry>
755                             <para>
756                                 <emphasis role="strong">getSunrise($location)</emphasis>
757                             </para>
758                         </entry>
759                         <entry> 返回日期的日出时间 </entry>
760                     </row>
761                     <row>
762                         <entry>
763                             <para>
764                                 <emphasis role="strong">getSunset($location)</emphasis>
765                             </para>
766                         </entry>
767                         <entry> 返回日期的日落时间 </entry>
768                     </row>
769                     <row>
770                         <entry>
771                             <para>
772                                 <emphasis role="strong">getSunInfo($location)</emphasis>
773                             </para>
774                         </entry>
775                         <entry> 返回带有日期的太阳日期的数组 </entry>
776                     </row>
777                 </tbody>
778             </tgroup>
779         </table>
781     </sect2>
783 </sect1>
784 <!--
785 vim:se ts=4 sw=4 et: