protected function create_wp_comment($action_id, $message, DateTime $date)
 {
     $comment_date_gmt = $date->format('Y-m-d H:i:s');
     $date->setTimezone(ActionScheduler_TimezoneHelper::get_local_timezone());
     $comment_data = array('comment_post_ID' => $action_id, 'comment_date' => $date->format('Y-m-d H:i:s'), 'comment_date_gmt' => $comment_date_gmt, 'comment_author' => self::AGENT, 'comment_content' => $message, 'comment_agent' => self::AGENT, 'comment_type' => self::TYPE);
     return wp_insert_comment($comment_data);
 }
 public static function get_local_timezone($reset = FALSE)
 {
     if ($reset) {
         self::$local_timezone = NULL;
     }
     if (!isset(self::$local_timezone)) {
         $tzstring = get_option('timezone_string');
         if (empty($tzstring)) {
             $gmt_offset = get_option('gmt_offset');
             if ($gmt_offset == 0) {
                 $tzstring = 'UTC';
             } else {
                 $gmt_offset *= HOUR_IN_SECONDS;
                 $tzstring = timezone_name_from_abbr('', $gmt_offset);
                 if (false === $tzstring) {
                     $is_dst = date('I');
                     foreach (timezone_abbreviations_list() as $abbr) {
                         foreach ($abbr as $city) {
                             if ($city['dst'] == $is_dst && $city['offset'] == $gmt_offset) {
                                 $tzstring = $city['timezone_id'];
                                 break 2;
                             }
                         }
                     }
                 }
                 if (false === $tzstring) {
                     $tzstring = 'UTC';
                 }
             }
         }
         self::$local_timezone = new DateTimeZone($tzstring);
     }
     return self::$local_timezone;
 }
 /**
  * @param string $action_id
  *
  * @throws InvalidArgumentException
  * @return DateTime The date the action is schedule to run, or the date that it ran.
  */
 public function get_date($action_id)
 {
     $post = get_post($action_id);
     if (empty($post) || $post->post_type != self::POST_TYPE) {
         throw new InvalidArgumentException(sprintf(__('Unidentified action %s', 'action-scheduler'), $action_id));
     }
     if ($post->post_status == 'publish') {
         return new DateTime($post->post_modified, ActionScheduler_TimezoneHelper::get_local_timezone());
     } else {
         return new DateTime($post->post_date, ActionScheduler_TimezoneHelper::get_local_timezone());
     }
 }
 protected function get_local_timezone()
 {
     return ActionScheduler_TimezoneHelper::get_local_timezone();
 }