include/SugarDateTime.php

Show: inherited
Table of Contents

\SugarDateTime

Package: SugarCRM

Sugar DateTime container Extends regular PHP DateTime with useful services

Parent(s)
\DateTime
Api
 

Properties

Propertyprotected\DateTimeZone  $_gmt= ''
static

Details
Type
\DateTimeZone
Propertyprotectedarray  $_strings= ''

Calendar strings

Details
Type
array
Propertyprotected  $data_init= 'array( "tm_hour" => 0, "tm_min" => 0, "tm_sec" => 0, )'
static
Default valuearray( "tm_hour" => 0, "tm_min" => 0, "tm_sec" => 0, )Details
Type
n/a
Propertyprotected  $formats= 'array( "sec" => "s", "min" => "i", "hour" => "G", "zhour" => "H", "day" => "j", "zday" => "d", "days_in_month" => "t", "day_of_week" => "w", "day_of_year" => "z", "week" => "W", "month" => "n", "zmonth" => "m", "year" => "Y", "am_pm" => "A", "hour_12" => "g", )'
Default valuearray( "sec" => "s", "min" => "i", "hour" => "G", "zhour" => "H", "day" => "j", "zday" => "d", "days_in_month" => "t", "day_of_week" => "w", "day_of_year" => "z", "week" => "W", "month" => "n", "zmonth" => "m", "year" => "Y", "am_pm" => "A", "hour_12" => "g", )Details
Type
n/a
Propertyprotectedarray  $parts_match= 'array( 'Y' => 'tm_year', 'm' => 'tm_mon', 'n' => 'tm_mon', 'd' => 'tm_mday', 'H' => 'tm_hour', 'h' => 'tm_hour', 'i' => 'tm_min', 's' => 'tm_sec', )'
static

Match between tm_ parts and date() format strings

Default valuearray( 'Y' => 'tm_year', 'm' => 'tm_mon', 'n' => 'tm_mon', 'd' => 'tm_mday', 'H' => 'tm_hour', 'h' => 'tm_hour', 'i' => 'tm_min', 's' => 'tm_sec', )Details
Type
array
Propertypublic  $strptime_long_mon= ''
Details
Type
n/a
Propertyprotected  $strptime_short_mon= ''
static
Details
Type
n/a
Propertypublicbool  $use_php_parser= 'true'
static

For testing - if we allowed to use PHP date parse

Default valuetrueDetails
Type
bool
Propertypublicbool  $use_strptime= 'true'
static

For testing - if we allowed to use strptime()

Default valuetrueDetails
Type
bool
Propertyprotected  $var_gets= 'array( "24_hour" => "hour", "day_of_week" => "day_of_week_long", "day_of_week_short" => "day_of_week_short", "month_name" => "month_long", "hour" => "hour_12", )'
Default valuearray( "24_hour" => "hour", "day_of_week" => "day_of_week_long", "day_of_week_short" => "day_of_week_short", "month_name" => "month_long", "hour" => "hour_12", )Details
Type
n/a

Methods

methodpublic__call( string $name, array $args ) : mixed

Implement some get_ methods that fetch variables

Parameters
Name Type Description
$name string
$args array
Returns
Type Description
mixed
methodpublic__get( string $var ) : mixed

Fetch property of the date by name

Parameters
Name Type Description
$var string

Property name

Returns
Type Description
mixed
methodpublic__toString( ) : string

Convert date to string - 'r' format, like: Thu, 21 Dec 2000 16:01:07 +0200

Returns
Type Description
string
methodpublicasDb( bool $tz = true ) : string

Print datetime in standard DB format

Set $tz parameter to false if you are sure that the date is in UTC.

Parameters
Name Type Description
$tz bool

do conversion to UTC

Returns
Type Description
string
methodpublicasDbDate( bool $tz = true ) : string

Print date in standard DB format

Set $tz parameter to false if you are sure that the date is in UTC.

Parameters
Name Type Description
$tz bool

do conversion to UTC

Returns
Type Description
string
methodpubliccreateFromFormat( string $format, string $time, \DateTimeZone $timezone = null ) : \SugarDateTime
static

Copy of DateTime::createFromFormat

Needed to return right type of the object

Parameters
Name Type Description
$format string

Format like in date()

$time string

Time to parse

$timezone \DateTimeZone
Returns
Type Description
\SugarDateTime
Details
See
\DateTime::createFromFormat  
methodpublicget( string $expression ) : \SugarDateTime

Get new date, modified by date expression

Parameters
Name Type Description
$expression string
Returns
Type Description
\SugarDateTime
Details
Example
$yesterday = $today->get("yesterday");  
methodpublicgetHashList( string $view, \SugarDateTime $start_time, \SugarDateTime $end_time ) : array
static

Create a list of time slots for calendar view Times must be in user TZ

Parameters
Name Type Description
$view string

Which view we are using - day, week, month

$start_time \SugarDateTime

Start time

$end_time \SugarDateTime

End time

Returns
Type Description
array
methodpublicget_date_str( ) : string

Get query string for the date, year=%d&month=%d&day=%d&hour=%d

Returns
Type Description
string
methodpublicget_datetime_by_index_today( int $hour_index ) : \SugarDateTime

Get specific hour of today

Parameters
Name Type Description
$hour_index int
Returns
Type Description
\SugarDateTime
methodpublicget_day_begin( int $day = null, int $month = null, int $year = null ) : \SugarDateTime

Get the beginning of the given day

Parameters
Name Type Description
$day int

Day, starting with 1, default is current

$month int

Month, starting with 1, default is current

$year int

Year, default is current

Returns
Type Description
\SugarDateTime
methodpublicget_day_by_index_this_month( int $day_index ) : \SugarDateTime

Get the beginning of i's day of the month

Parameters
Name Type Description
$day_index int

0 is the first day of the month (sic!)

Returns
Type Description
\SugarDateTime
methodpublicget_day_by_index_this_week( int $day_index ) : \SugarDateTime

Get the beginning of i's day of the week

Parameters
Name Type Description
$day_index int

Day, 0 is Sunday, 1 is Monday, etc.

Returns
Type Description
\SugarDateTime
methodpublicget_day_by_index_this_year( int $month_index ) : \SugarDateTime

Get the beginning of the last day of i's the month

Parameters
Name Type Description
$month_index int

Month, January is 0

Returns
Type Description
\SugarDateTime
Details
Deprecated
FIXME: no idea why this function exists and what's the use of it  
methodpublicget_day_end( int $day = null, int $month = null, int $year = null ) : \SugarDateTime

Get the last second of the given day

Parameters
Name Type Description
$day int

Day, starting with 1, default is current

$month int

Month, starting with 1, default is current

$year int

Year, default is current

Returns
Type Description
\SugarDateTime
methodpublicget_day_end_time( ) : \SugarDateTime

Get the last second of the current day

Returns
Type Description
\SugarDateTime
methodpublicget_hour_end_time( ) : \SugarDateTime

Get the last second of current hour

Returns
Type Description
\SugarDateTime
methodpublicget_year_begin( int $year ) : \SugarDateTime

Get the beginning of the first day of the year

Parameters
Name Type Description
$year int
Returns
Type Description
\SugarDateTime
methodpublicmodify(  $modify ) : \SugarDateTime

(non-PHPdoc)

Parameters
Name Type Description
$modify
Returns
Type Description
\SugarDateTime
Details
See
\DateTime::modify()  
methodpublicparse_utc_date_time( string $str ) : \SugarDateTime
static

Create from ISO 8601 datetime

Parameters
Name Type Description
$str string
Returns
Type Description
\SugarDateTime
methodpublicsetDate(  $year,  $month,  $day ) : \SugarDateTime

(non-PHPdoc)

Parameters
Name Type Description
$year
$month
$day
Returns
Type Description
\SugarDateTime
Details
See
\DateTime::setDate()  
methodpublicsetTime(  $hour,  $minute, int $sec = 0 ) : \SugarDateTime

(non-PHPdoc)

Parameters
Name Type Description
$hour
$minute
$sec int
Returns
Type Description
\SugarDateTime
Details
See
\DateTime::setTime()  
methodpublicsetTimezone( \DateTimeZone $timezone ) : \SugarDateTime

(non-PHPdoc)

Parameters
Name Type Description
$timezone \DateTimeZone
Returns
Type Description
\SugarDateTime
Details
See
\DateTime::setTimezone()  
Documentation was generated by DocBlox 0.18.1.