PluginProbe ʕ •ᴥ•ʔ
Appointment Booking Plugin – LatePoint | Calendar & Scheduling for WordPress / 5.2.10
Appointment Booking Plugin – LatePoint | Calendar & Scheduling for WordPress v5.2.10
5.6.11 5.6.10 5.6.9 5.6.8 5.6.7 5.6.6 5.6.5 5.6.4 5.6.3 5.6.2 5.6.1 5.6.0 5.5.2 5.5.1 5.5.0 5.4.2 trunk 5.1.0 5.1.1 5.1.2 5.1.3 5.1.4 5.1.5 5.1.6 5.1.7 5.1.8 5.1.9 5.1.91 5.1.92 5.1.93 5.1.94 5.2.0 5.2.1 5.2.10 5.2.11 5.2.2 5.2.3 5.2.4 5.2.5 5.2.6 5.2.7 5.2.8 5.2.9 5.3.0 5.3.1 5.3.2 5.4.0 5.4.1
latepoint / lib / helpers / wp_datetime.php
latepoint / lib / helpers Last commit date
activities_helper.php 1 year ago agent_helper.php 1 year ago analytics_helper.php 6 months ago auth_helper.php 6 months ago blocks_helper.php 1 year ago booking_helper.php 6 months ago bricks_helper.php 1 year ago bundles_helper.php 1 year ago calendar_helper.php 11 months ago carts_helper.php 1 year ago connector_helper.php 11 months ago csv_helper.php 6 months ago customer_helper.php 6 months ago customer_import_helper.php 6 months ago database_helper.php 11 months ago debug_helper.php 1 year ago defaults_helper.php 1 year ago elementor_helper.php 1 year ago email_helper.php 11 months ago encrypt_helper.php 1 year ago events_helper.php 11 months ago form_helper.php 6 months ago icalendar_helper.php 1 year ago image_helper.php 1 year ago invoices_helper.php 6 months ago license_helper.php 1 year ago location_helper.php 1 year ago marketing_systems_helper.php 1 year ago meeting_systems_helper.php 1 year ago menu_helper.php 11 months ago meta_helper.php 6 months ago migrations_helper.php 1 year ago money_helper.php 6 months ago notifications_helper.php 11 months ago nps_survey_helper.php 6 months ago order_intent_helper.php 11 months ago orders_helper.php 1 year ago otp_helper.php 11 months ago pages_helper.php 1 year ago params_helper.php 1 year ago payments_helper.php 1 year ago price_breakdown_helper.php 1 year ago process_jobs_helper.php 1 year ago processes_helper.php 1 year ago replacer_helper.php 1 year ago resource_helper.php 1 year ago roles_helper.php 8 months ago router_helper.php 1 year ago service_helper.php 1 year ago sessions_helper.php 6 months ago settings_helper.php 6 months ago short_links_systems_helper.php 11 months ago shortcodes_helper.php 11 months ago sms_helper.php 1 year ago steps_helper.php 6 months ago stripe_connect_helper.php 11 months ago styles_helper.php 11 months ago support_topics_helper.php 1 year ago time_helper.php 11 months ago timeline_helper.php 11 months ago transaction_helper.php 6 months ago transaction_intent_helper.php 1 year ago util_helper.php 8 months ago version_specific_updates_helper.php 11 months ago whatsapp_helper.php 1 year ago work_periods_helper.php 7 months ago wp_datetime.php 1 year ago wp_user_helper.php 1 year ago
wp_datetime.php
78 lines
1 <?php
2 class OsWpDateTime extends DateTime {
3 function __construct(?string $time = 'now', ?DateTimeZone $timezone = null){
4 $timezone = ($timezone instanceof DateTimeZone) ? $timezone : OsTimeHelper::get_wp_timezone();
5 try{
6 if(empty($time)) $time = 'now';
7 parent::__construct($time, $timezone);
8 }catch(Exception $e){
9 OsDebugHelper::log('Error parsing date: '.$e->getMessage() , 'date_parsing' );
10 return parent::__construct('now', $timezone);
11 }
12 }
13
14 public static function datetime_in_utc(DateTime $datetime, $format = false){
15 $utc_datetime = clone $datetime;
16 $utc_datetime->setTimezone(new DateTimeZone("UTC"));
17 return $format ? $utc_datetime->format($format) : $utc_datetime;
18 }
19
20 public static function date_to_db_format($date_string, $default = ''){
21 if(empty($date_string)) return $default;
22 try{
23 $date = self::os_createFromFormat(OsSettingsHelper::get_date_format(), $date_string);
24 return $date->format('Y-m-d');
25 }catch(Exception $e){
26 return $default;
27 }
28 }
29
30 public static function date_from_db_format($date_string, $default = ''){
31 if(empty($date_string)) return $default;
32 try{
33 $timezone = new DateTimeZone('UTC');
34 $date = self::os_createFromFormat('Y-m-d', $date_string, $timezone);
35 return $date->format(OsSettingsHelper::get_date_format());
36 }catch(Exception $e){
37 return $default;
38 }
39 }
40
41 public static function os_createFromFormat($format, $datetime_string, $timezone = false){
42 $timezone = ($timezone) ? $timezone : OsTimeHelper::get_wp_timezone();
43 return self::createFromFormat($format, $datetime_string, $timezone);
44 }
45
46 // TODO will be deprecated, moved to GCal addon
47 public static function os_get_start_of_google_event($google_event){
48 if(!empty($google_event->start->dateTime)){
49 $date_string = $google_event->start->dateTime;
50 $date_format = \DateTime::RFC3339;
51 $timezone = new DateTimeZone($google_event->start->timeZone);
52 }else{
53 // Full day event
54 $date_string = $google_event->start->date.' 00:00:00';
55 $date_format = LATEPOINT_DATETIME_DB_FORMAT;
56 $timezone = false;
57 }
58 return self::os_createFromFormat($date_format, $date_string, $timezone);
59 }
60
61 // TODO will be deprecated, moved to GCal addon
62 public static function os_get_end_of_google_event($google_event){
63 if(!empty($google_event->end->dateTime)){
64 $date_string = $google_event->end->dateTime;
65 $date_format = \DateTime::RFC3339;
66 return self::os_createFromFormat($date_format, $date_string);
67 }else{
68 // Full day event
69 // !important, in full day events of Google Calendar - start day is inclusive and the end day is exclusive https://stackoverflow.com/questions/34992747/google-calendar-json-api-full-day-events-always-one-day-longer
70 $date_string = $google_event->end->date.' 23:59:59';
71 $date_format = LATEPOINT_DATETIME_DB_FORMAT;
72 $temp_date = self::os_createFromFormat($date_format, $date_string);
73 // move back 1 day to accomodate Google rule that end date is 1 day ahead of actual end date of a full day event
74 $temp_date->modify('-1 day');
75 return $temp_date;
76 }
77 }
78 }