Subversion-Projekte lars-tiefland.ci

Revision

Revision 68 | Revision 2049 | Zur aktuellen Revision | Ganze Datei anzeigen | Leerzeichen ignorieren | Details | Blame | Letzte Änderung | Log anzeigen | RSS feed

Revision 68 Revision 1257
Zeile 705... Zeile 705...
705
			return array(date($format, $unix_start));
705
			return array(date($format, $unix_start));
706
		}
706
		}
Zeile 707... Zeile 707...
707
 
707
 
Zeile 708... Zeile -...
708
		$range = array();
-
 
709
 
-
 
710
		/* NOTE: Even though the DateTime object has many useful features, it appears that
-
 
711
		 *	 it doesn't always handle properly timezones, when timestamps are passed
-
 
712
		 *	 directly to its constructor. Neither of the following gave proper results:
-
 
713
		 *
-
 
714
		 *		new DateTime('<timestamp>')
-
 
715
		 *		new DateTime('<timestamp>', '<timezone>')
-
 
716
		 *
-
 
717
		 *	 --- available in PHP 5.3:
-
 
718
		 *
-
 
719
		 *		DateTime::createFromFormat('<format>', '<timestamp>')
-
 
720
		 *		DateTime::createFromFormat('<format>', '<timestamp>', '<timezone')
-
 
721
		 *
-
 
722
		 *	 ... so we'll have to set the timestamp after the object is instantiated.
-
 
723
		 *	 Furthermore, in PHP 5.3 we can use DateTime::setTimestamp() to do that and
-
 
724
		 *	 given that we have UNIX timestamps - we should use it.
708
		$range = array();
-
 
709
 
Zeile 725... Zeile -...
725
		*/
-
 
726
		$from = new DateTime();
-
 
727
 
-
 
728
		if (is_php('5.3'))
-
 
729
		{
-
 
730
			$from->setTimestamp($unix_start);
-
 
731
			if ($is_unix)
-
 
732
			{
-
 
733
				$arg = new DateTime();
-
 
734
				$arg->setTimestamp($mixed);
-
 
735
			}
-
 
736
			else
-
 
737
			{
-
 
738
				$arg = (int) $mixed;
-
 
739
			}
-
 
740
 
-
 
741
			$period = new DatePeriod($from, new DateInterval('P1D'), $arg);
-
 
742
			foreach ($period as $date)
-
 
743
			{
-
 
744
				$range[] = $date->format($format);
-
 
745
			}
-
 
746
 
-
 
747
			/* If a period end date was passed to the DatePeriod constructor, it might not
-
 
748
			 * be in our results. Not sure if this is a bug or it's just possible because
-
 
749
			 * the end date might actually be less than 24 hours away from the previously
-
 
750
			 * generated DateTime object, but either way - we have to append it manually.
-
 
751
			 */
-
 
752
			if ( ! is_int($arg) && $range[count($range) - 1] !== $arg->format($format))
-
 
753
			{
-
 
754
				$range[] = $arg->format($format);
-
 
755
			}
-
 
756
 
-
 
757
			return $range;
-
 
758
		}
-
 
759
 
710
		$from = new DateTime();
760
		$from->setDate(date('Y', $unix_start), date('n', $unix_start), date('j', $unix_start));
711
		$from->setTimestamp($unix_start);
761
		$from->setTime(date('G', $unix_start), date('i', $unix_start), date('s', $unix_start));
712
 
762
		if ($is_unix)
-
 
763
		{
713
		if ($is_unix)
764
			$arg = new DateTime();
714
		{
765
			$arg->setDate(date('Y', $mixed), date('n', $mixed), date('j', $mixed));
715
			$arg = new DateTime();
766
			$arg->setTime(date('G', $mixed), date('i', $mixed), date('s', $mixed));
716
			$arg->setTimestamp($mixed);
767
		}
717
		}
768
		else
718
		else
769
		{
-
 
Zeile -... Zeile 719...
-
 
719
		{
770
			$arg = (int) $mixed;
720
			$arg = (int) $mixed;
771
		}
721
		}
772
		$range[] = $from->format($format);
-
 
773
 
-
 
774
		if (is_int($arg)) // Day intervals
-
 
775
		{
722
 
776
			do
-
 
777
			{
-
 
778
				$from->modify('+1 day');
723
		$period = new DatePeriod($from, new DateInterval('P1D'), $arg);
779
				$range[] = $from->format($format);
-
 
780
			}
-
 
781
			while (--$arg > 0);
-
 
782
		}
-
 
783
		else // end date UNIX timestamp
-
 
784
		{
-
 
Zeile 785... Zeile 724...
785
			for ($from->modify('+1 day'), $end_check = $arg->format('Ymd'); $from->format('Ymd') < $end_check; $from->modify('+1 day'))
724
		foreach ($period as $date)
-
 
725
		{
-
 
726
			$range[] = $date->format($format);
-
 
727
		}
-
 
728
 
-
 
729
		/* If a period end date was passed to the DatePeriod constructor, it might not
-
 
730
		 * be in our results. Not sure if this is a bug or it's just possible because
786
			{
731
		 * the end date might actually be less than 24 hours away from the previously
787
				$range[] = $from->format($format);
732
		 * generated DateTime object, but either way - we have to append it manually.
Zeile 788... Zeile 733...
788
			}
733
		 */
789
 
734
		if ( ! is_int($arg) && $range[count($range) - 1] !== $arg->format($format))