/**
* Date Functions
*
* @package EDD
* @subpackage Functions
* @copyright Copyright (c) 2018, Easy Digital Downloads, LLC
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
* @since 3.0
*/
/**
* Retrieves a localized, formatted date based on the WP timezone rather than UTC.
*
* @since 3.0
*
* @param int $timestamp Timestamp. Can either be based on UTC or WP settings.
* @param string $format Optional. Accepts shorthand 'date', 'time', or 'datetime'
* date formats, as well as any valid date_format() string.
* Default 'date' represents the value of the 'date_format' option.
* @return string The formatted date, translated if locale specifies it.
*/
function edd_date_i18n( $timestamp, $format = 'date' ) {
$format = edd_get_date_format( $format );
// If timestamp is a string, attempt to turn it into a timestamp.
if ( ! is_numeric( $timestamp ) ) {
$timestamp = strtotime( $timestamp );
}
// We need to get the timezone offset so we can pass that to date_i18n.
$date = EDD()->utils->date( 'now', edd_get_timezone_id(), false );
return date_i18n( $format, (int) $timestamp + $date->getOffset() );
}
/**
* Retrieve timezone ID
*
* @since 1.6
* @return string $timezone The timezone ID
*/
function edd_get_timezone_id() {
return EDD()->utils->get_time_zone( true );
}
/**
* Accept an EDD date object and get the UTC equivalent version of it.
* The EDD date object passed-in can be in any timezone. The one you'll get back will be the UTC equivalent of that time.
* This is useful when querying data from the tables by a user-defined date range, like "today".
*
* @since 3.0
* @param EDD\Utils\Date $edd_date_object The EDD Date object for which you wish to get the UTC equiavalent.
* @return EDD\Utils\Date The EDD date object set at the UTC equivalent time.
*/
function edd_get_utc_equivalent_date( $edd_date_object ) {
$instance_check = 'EDD\Utils\Date';
if ( ! $edd_date_object instanceof $instance_check ) {
return false;
}
// Convert the timezone (and thus, also the time) from the WP/EDD Timezone to the UTC equivalent.
$utc_timezone = new DateTimeZone( 'utc' );
$edd_date_object->setTimezone( $utc_timezone );
return $edd_date_object;
}
/**
* Accept an EDD date object set in UTC, and get the WP/EDD Timezone equivalent version of it.
* The EDD date object must be in UTC. The one you'll get back will be the WP timezone equivalent of that time.
* This is useful when showing date information to the user, so that they see it in the proper timezone, instead of UTC.
*
* @since 3.0
* @param EDD\Utils\Date $edd_date_object The EDD Date object for which you wish to get the UTC equiavalent.
* @return EDD\Utils\Date The EDD date object set at the UTC equivalent time.
*/
function edd_get_edd_timezone_equivalent_date_from_utc( $edd_date_object ) {
$instance_check = 'EDD\Utils\Date';
if ( ! $edd_date_object instanceof $instance_check ) {
return false;
}
// If you passed a date object to this function that isn't set to UTC, that is incorrect usage.
if ( 'UTC' !== $edd_date_object->format( 'T' ) ) {
return false;
}
// Convert the timezone (and thus, also the time) from UTC to the WP/EDD Timezone.
$edd_timezone = new DateTimeZone( edd_get_timezone_id() );
$edd_date_object->setTimezone( $edd_timezone );
return $edd_date_object;
}
/**
* Get the timezone abbreviation for the WordPress timezone setting.
*
* @since 3.0
*
* @return string The abreviation for the current WordPress timezone setting.
*/
function edd_get_timezone_abbr() {
$edd_timezone = edd_get_timezone_id();
$edd_date_object = EDD()->utils->date( 'now', $edd_timezone, true );
return $edd_date_object->format( 'T' );
}
/**
* Retrieves a date format string based on a given short-hand format.
*
* @since 3.0
*
* @see \EDD_Utilities::get_date_format_string()
*
* @param string $format Shorthand date format string. Accepts 'date', 'time', 'mysql', or
* 'datetime'. If none of the accepted values, the original value will
* simply be returned. Default 'date' represents the value of the
* 'date_format' option.
*
* @return string date_format()-compatible date format string.
*/
function edd_get_date_format( $format = 'date' ) {
return EDD()->utils->get_date_format_string( $format );
}
/**
* Get the format used by jQuery UI Datepickers.
*
* Use this if you need to use placeholder or format attributes in input fields.
*
* This is a bit different than `edd_get_date_format()` because these formats
* are exposed to users as hints and also used by jQuery UI so the Datepicker
* knows what format it returns into it's connected input value.
*
* Previous to this function existing, all values were hard-coded, causing some
* inconsistencies across admin-area screens.
*
* @see https://github.com/easydigitaldownloads/easy-digital-downloads/commit/e9855762892b6eec578b0a402f7950f22bd19632
*
* @since 3.0
*
* @param string $context The context we are getting the format for. Accepts 'display' or 'js'.
* Use 'js' for use with jQuery UI Datepicker. Use 'display' for HTML attributes.
* @return string
*/
function edd_get_date_picker_format( $context = 'display' ) {
// What is the context that we are getting the picker format for?
switch ( $context ) {
// jQuery UI Datepicker does its own thing
case 'js' :
case 'javascript' :
$retval = EDD()->utils->get_date_format_string( 'date-js' );
break;
// Used to display in an attribute, placeholder, etc...
case 'display' :
default :
$retval = EDD()->utils->get_date_format_string( 'date-attribute' );
break;
}
/**
* Filter the date picker format, allowing for custom overrides
*
* @since 3.0
*
* @param string $retval Date format for date picker
* @param string $context The context this format is for
*/
return apply_filters( 'edd_get_date_picker_format', $retval, $context );
}
/**
* Return an array of values used to populate an hour dropdown
*
* @since 3.0
*
* @return array
*/
function edd_get_hour_values() {
return (array) apply_filters( 'edd_get_hour_values', array(
'00' => '00',
'01' => '01',
'02' => '02',
'03' => '03',
'04' => '04',
'05' => '05',
'06' => '06',
'07' => '07',
'08' => '08',
'09' => '09',
'10' => '10',
'11' => '11',
'12' => '12',
'13' => '13',
'14' => '14',
'15' => '15',
'16' => '16',
'17' => '17',
'18' => '18',
'19' => '19',
'20' => '20',
'21' => '21',
'22' => '22',
'23' => '23',
'24' => '24'
) );
}
/**
* Return an array of values used to populate a minute dropdown
*
* @since 3.0
*
* @return array
*/
function edd_get_minute_values() {
return (array) apply_filters( 'edd_get_minute_values', array(
'00' => '00',
'01' => '01',
'02' => '02',
'03' => '03',
'04' => '04',
'05' => '05',
'06' => '06',
'07' => '07',
'08' => '08',
'09' => '09',
'10' => '10',
'11' => '11',
'12' => '12',
'13' => '13',
'14' => '14',
'15' => '15',
'16' => '16',
'17' => '17',
'18' => '18',
'19' => '19',
'20' => '20',
'21' => '21',
'22' => '22',
'23' => '23',
'24' => '24',
'25' => '25',
'26' => '26',
'27' => '27',
'28' => '28',
'29' => '29',
'30' => '30',
'31' => '31',
'32' => '32',
'33' => '33',
'34' => '34',
'35' => '35',
'36' => '36',
'37' => '37',
'38' => '38',
'39' => '39',
'40' => '40',
'41' => '41',
'42' => '42',
'43' => '43',
'44' => '44',
'45' => '45',
'46' => '46',
'47' => '47',
'48' => '48',
'49' => '49',
'50' => '50',
'51' => '51',
'52' => '52',
'53' => '53',
'54' => '54',
'55' => '55',
'56' => '56',
'57' => '57',
'58' => '58',
'59' => '59'
) );
}
Searching for the right medicine for a patient is difficult enough without variation from one grower to the next. Some growers have made significant investment - facilities, genetics, media, personnel, training and process refining - to deliver a superior product, while others just 'wing it'. It is our goal to document which growers are producing the best medicine, which chemotypes they offer, how our experts rated the crops, and how to find them for purchase.
Higher Ground is recruiting talented reviewers NOW in all Medical and Recreational Use states, not only Washington, Oregon, Alaska, California, Hawaii and Colorado. Contact editor Jeff Cole to learn how you can take part (or go ahead and Subscribe now as a Contributor and begin helping today).
The HIGHERGROUND420 Story
Jeff Cole began graduate studies in 1997 while working in the laboratory of Dr. William Hildebrand in the department of Microbiology and Immunology at the University of Oklahoma Health Sciences Center. Family crisis interrupted grad school, but not his interest in Science.
Cole spent several years teaching Math and Sciences in area high schools and colleges. It was while teaching an unruly group Cole lovingly called 'the rough boys', that he was challenged to learn the real reasons behind cannabis prohibition and ultimately became an advocate for the end of cannabis prohibition.
Cole was recognized by a civic group in 2008 for his contribution to local history while publishing a regional magazine. 14 issues and a commemorative history book later, Cole took interest in cannabis and the history of the Pacific Northwest. Following extensive research begun in 2008 into the actual risks, effects, history and prohibition of cannabis in America, Cole emigrated to Seattle in 2013 shortly after Washington state legalized cannabis for recreational use with an initiative vote of the people in late 2012. Now in Seattle, his numerous and colorful stories extracted from Seattle history draw both Seattle Bliss and HigherGround420 supporters to choose the Seattle Bliss tour when they visit.
News and Reviews are accessible to everyone - free of charge - thanks to the generous support from subscribing individuals, businesses and special affiliates helping us learn more about the plant. Subscribe or Contribute and be a HigherGround420 hero.