cvs: peardoc / global.ent /en/package/datetime date.xml /en/package/datetime/date basics.xml examples.xml

From: Date: Tue, 03 Jul 2007 06:54:15 +0000
Subject: cvs: peardoc / global.ent /en/package/datetime date.xml /en/package/datetime/date basics.xml examples.xml
Groups: php.pear.doc 
Request: Send a blank email to pear-doc+get-9866@lists.php.net to get a copy of this message
cweiske Tue Jul 3 06:54:15 2007 UTC Added files: /peardoc/en/package/datetime/date basics.xml Modified files: /peardoc global.ent /peardoc/en/package/datetime date.xml /peardoc/en/package/datetime/date examples.xml Log: Finish date docs

http://cvs.php.net/viewvc.cgi/peardoc/global.ent?r1=1.78&r2=1.79&diff_format=u Index: peardoc/global.ent diff -u peardoc/global.ent:1.78 peardoc/global.ent:1.79 --- peardoc/global.ent:1.78 Sat Dec 16 15:02:15 2006 +++ peardoc/global.ent Tue Jul 3 06:54:14 2007 @@ -1,6 +1,6 @@ <!-- -*- SGML -*- - $Id: global.ent,v 1.78 2006/12/16 15:02:15 mj Exp $ + $Id: global.ent,v 1.79 2007/07/03 06:54:14 cweiske Exp $ Contains global "macros" for all the XML documents. @@ -236,3 +236,7 @@ <!ENTITY phpdocbase.html-page2 "http://pear.php.net/package/HTML_Page2/docs/latest/HTML_Page2/HTML_Page2.html#method"> <!ENTITY phpdocbase.console-progressbar "http://pear.php.net/package/Console_ProgressBar/docs/latest/Console_ProgressBar/Console_ProgressBar.html#method"> <!ENTITY phpdocbase.games-chess "http://pear.php.net/package/Games_Chess/docs/latest/Games_Chess/"> +<!ENTITY phpdocbase.datetime-date "http://pear.php.net/package/Date/docs/latest/apidoc/Date/Date.html"> +<!ENTITY phpdocbase.datetime-date.method "http://pear.php.net/package/Date/docs/latest/apidoc/Date/Date.html#method"> +<!ENTITY phpdocbase.datetime-date_span.method "http://pear.php.net/package/Date/docs/latest/apidoc/Date/Date_Span.html#method"> +<!ENTITY phpdocbase.datetime-date_timezone.method "http://pear.php.net/package/Date/docs/latest/apidoc/Date/Date_TimeZone.html#method"> http://cvs.php.net/viewvc.cgi/peardoc/en/package/datetime/date.xml?r1=1.1&r2=1.2&diff_format=u Index: peardoc/en/package/datetime/date.xml diff -u peardoc/en/package/datetime/date.xml:1.1 peardoc/en/package/datetime/date.xml:1.2 --- peardoc/en/package/datetime/date.xml:1.1 Fri Jun 29 05:37:02 2007 +++ peardoc/en/package/datetime/date.xml Tue Jul 3 06:54:14 2007 @@ -1,4 +1,4 @@ -<!-- $Revision: 1.1 $ --> +<!-- $Revision: 1.2 $ --> <sect1 id="package.datetime.date"> <title>Date</title> @@ -12,6 +12,7 @@ </para> &package.datetime.date.examples; + &package.datetime.date.basics; </sect1> <!-- Keep this comment at the end of the file Local variables: http://cvs.php.net/viewvc.cgi/peardoc/en/package/datetime/date/examples.xml?r1=1.1&r2=1.2&diff_format=u Index: peardoc/en/package/datetime/date/examples.xml diff -u peardoc/en/package/datetime/date/examples.xml:1.1 peardoc/en/package/datetime/date/examples.xml:1.2 --- peardoc/en/package/datetime/date/examples.xml:1.1 Fri Jun 29 05:37:02 2007 +++ peardoc/en/package/datetime/date/examples.xml Tue Jul 3 06:54:14 2007 @@ -1,8 +1,15 @@ <?xml version="1.0" encoding="utf-8"?> -<!-- $Revision: 1.1 $ --> -<sect2 id="package.datetime.date.examples"> - <title>Examples</title> - <para> +<!-- $Revision: 1.2 $ --> +<refentry id="package.datetime.date.examples"> + <refnamediv> + <refname>Examples</refname> + <refpurpose>Learning by doing</refpurpose> + </refnamediv> + + <refsect1 id="package.datetime.date.examples.intro"> + <title>Introduction</title> + + <para> Following the saying "learning by doing", we start with some examples. </para> @@ -35,7 +42,11 @@ <para> After finishing your work with the date object, you probably want to - have it back. This can be done in different ways. + have it back. This can be done in different ways, for example by + using + <ulink url="&phpdocbase.datetime-date.method;getTime"><methodname>getTime</methodname></ulink> + or + <ulink url="&phpdocbase.datetime-date.method;getDate"><methodname>getDate</methodname></ulink>. </para> <example> @@ -65,14 +76,22 @@ we'll do some easy tasks. </para> + </refsect1> - <sect3 id="package.datetime.date.examples.timediff"> + <refsect1 id="package.datetime.date.examples.timediff"> <title>Calculating a time difference</title> <para> You often have the task to know which time span lies between two dates. With <classname>Date</classname>, this is easy to accomplish. + First we use + <ulink url="&phpdocbase.datetime-date_span.method;setFromDateDiff"><methodname>setFromDateDiff</methodname></ulink> + on a fresh + <classname>Date_Span</classname> object and then + <ulink url="&phpdocbase.datetime-date_span.method;toDays"><methodname>toDays</methodname></ulink> + to get the exact number of days + between the two dates. </para> <example> @@ -82,7 +101,7 @@ require_once 'Date.php'; $someDate = new Date('1813-02-23T05:34:23'); -$otherDate = new Date('1714-12-21T18:23:42'); +$otherDate = new Date('1789-12-21T18:23:42'); $span = new Date_Span(); $span->setFromDateDiff($someDate, $otherDate); @@ -103,20 +122,33 @@ or 68 years. </para> </note> - </sect3> + </refsect1> - <sect3 id="package.datetime.date.examples.converttimezone"> + <refsect1 id="package.datetime.date.examples.converttimezone"> <title>Converting timezones</title> <para> <classname>Date</classname> can help you working with time zones. An array with all supported timezones can be retrieved by using + <ulink url="&phpdocbase.datetime-date_timezone.method;getAvailableIDs"><methodname>getAvailableIDs</methodname></ulink> + statically as in <command>$list = Date_TimeZone::getAvailableIDs();</command>. </para> + <para> + <methodname>convertTZ</methodname> converts the Date object's + internal settings to the given time zone. + Using + <ulink url="&phpdocbase.datetime-date.method;format"><methodname>format</methodname></ulink> + you can display the timezone + setting. With <classname>Date_TimeZone</classname>'s + <methodname>getDefault</methodname> method the default time + zone for this computer can be obtained. + </para> + <example> <title>Converting timezones</title> <programlisting role="php"><![CDATA[ @@ -145,17 +177,18 @@ ]]></programlisting> </example> - </sect3> + </refsect1> - <sect3 id="package.datetime.date.examples.sorting"> + <refsect1 id="package.datetime.date.examples.sorting"> <title>Sorting an array of dates</title> <para> Once you have an array of <classname>Date</classname> objects, you might want to sort it. The class provides a static method - <methodname>compare</methodname> that helps with this. + <ulink url="&phpdocbase.datetime-date.method;compare"><methodname>compare</methodname></ulink> + that helps with this. </para> <example> @@ -185,9 +218,9 @@ ]]></programlisting> </example> - </sect3> + </refsect1> -</sect2> +</refentry> <!-- Keep this comment at the end of the file Local variables: mode: sgml http://cvs.php.net/viewvc.cgi/peardoc/en/package/datetime/date/basics.xml?view=markup&rev=1.1 Index: peardoc/en/package/datetime/date/basics.xml +++ peardoc/en/package/datetime/date/basics.xml <?xml version="1.0" encoding="utf-8"?> <!-- $Revision: 1.1 $ --> <refentry id="package.datetime.date.basics"> <refnamediv> <refname>Basics</refname> <refpurpose>How to get information</refpurpose> </refnamediv> <refsect1 id="package.datetime.date.basics.intro"> <title>Introduction</title> <para> The auto-generated <ulink url="&phpdocbase.datetime-date;">API documentation</ulink> is very valuable to get information about this packages' methods and which parameters they require. But of course you first need to have an overview about the abilities of the class. </para> </refsect1> <refsect1 id="package.datetime.date.basics.getting"> <title>Getting data</title> <para> There are a number of simple getter methods that let you retrieve single pieces of a date currently set. </para> <itemizedlist> <listitem> <para> <ulink url="&phpdocbase.datetime-date.method;getYear"><methodname>getYear</methodname></ulink> </para> </listitem> <listitem> <para> <ulink url="&phpdocbase.datetime-date.method;getMonth"><methodname>getMonth</methodname></ulink> </para> </listitem> <listitem> <para> <ulink url="&phpdocbase.datetime-date.method;getDay"><methodname>getDay</methodname></ulink> </para> </listitem> <listitem> <para> <ulink url="&phpdocbase.datetime-date.method;getHour"><methodname>getHour</methodname></ulink> </para> </listitem> <listitem> <para> <ulink url="&phpdocbase.datetime-date.method;getMinute"><methodname>getMinute</methodname></ulink> </para> </listitem> <listitem> <para> <ulink url="&phpdocbase.datetime-date.method;getSecond"><methodname>getSecond</methodname></ulink> </para> </listitem> </itemizedlist> <para> <classname>Date</classname> does also have some advanced methods to obtain data from it. </para> <itemizedlist> <listitem> <para> <ulink url="&phpdocbase.datetime-date.method;getDayName"><methodname>getDayName</methodname></ulink> returns the name of the day in short (<literal>Mon</literal>) or long form (<literal>Monday</literal>) </para> </listitem> <listitem> <para> <ulink url="&phpdocbase.datetime-date.method;getMonthName"><methodname>getMonthName</methodname></ulink> returns the name of the month in short (<literal>Jan</literal>) or long form (<literal>Monday</literal>) </para> </listitem> <listitem> <para> <ulink url="&phpdocbase.datetime-date.method;getDayOfWeek"><methodname>getDayOfWeek</methodname></ulink> calculates the number of the day in the week (0-6, Sunday being 0) </para> </listitem> <listitem> <para> <ulink url="&phpdocbase.datetime-date.method;getWeekOfYear"><methodname>getWeekOfYear</methodname></ulink> returns the week number of this date </para> </listitem> <listitem> <para> <ulink url="&phpdocbase.datetime-date.method;getQuarterOfYear"><methodname>getQuarterOfYear</methodname></ulink> </para> </listitem> </itemizedlist> </refsect1> <refsect1 id="package.datetime.date.basics.navigation"> <title>Navigating between dates</title> <para> The following method all return a new date object. </para> <itemizedlist> <listitem> <para> <ulink url="&phpdocbase.datetime-date.method;getNextDay"><methodname>getNextDay</methodname></ulink> </para> </listitem> <listitem> <para> <ulink url="&phpdocbase.datetime-date.method;getPrevDay"><methodname>getPrevDay</methodname></ulink> </para> </listitem> <listitem> <para> <ulink url="&phpdocbase.datetime-date.method;getNextWeekday"><methodname>getNextWeekday</methodname></ulink> </para> </listitem> <listitem> <para> <ulink url="&phpdocbase.datetime-date.method;getPrevWeekday"><methodname>getPrevWeekday</methodname></ulink> </para> </listitem> <!-- <listitem> <para> <ulink url="&phpdocbase.datetime-date.method;"><methodname></methodname></ulink> </para> </listitem> --> </itemizedlist> <para> You can also do excact calculations by adding and subtracting intervals. The <literal>*Span</literal> methods require a <classname>Date_Span</classname> object to be passed as only parameter while the others take a number representing seconds. </para> <itemizedlist> <listitem> <para> <ulink url="&phpdocbase.datetime-date.method;addSeconds"><methodname>addSeconds</methodname></ulink> </para> </listitem> <listitem> <para> <ulink url="&phpdocbase.datetime-date.method;subtractSeconds"><methodname>subtractSeconds</methodname></ulink> </para> </listitem> <listitem> <para> <ulink url="&phpdocbase.datetime-date.method;addSpan"><methodname>addSpan</methodname></ulink> </para> </listitem> <listitem> <para> <ulink url="&phpdocbase.datetime-date.method;subtractSpan"><methodname>subtractSpan</methodname></ulink> </para> </listitem> </itemizedlist> </refsect1> </refentry>
« previous php.pear.doc (#9866) next »