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);
 }
 /**
  * @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();
 }