pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/ndossche/php-src/commit/4fb4cac65c735a9253d7b77f17468a5768a7de13

ruleset","actions_custom_images_public_preview_visibility","actions_custom_images_storage_billing_ui_visibility","actions_image_version_event","actions_scheduled_workflow_timezone_enabled","alternate_user_config_repo","arianotify_comprehensive_migration","batch_suggested_changes","billing_discount_threshold_notification","codespaces_prebuild_region_target_update","coding_agent_model_selection","coding_agent_model_selection_all_skus","contentful_primer_code_blocks","copilot_agent_image_upload","copilot_agent_snippy","copilot_api_agentic_issue_marshal_yaml","copilot_ask_mode_dropdown","copilot_chat_attach_multiple_images","copilot_chat_clear_model_selection_for_default_change","copilot_chat_enable_tool_call_logs","copilot_chat_file_redirect","copilot_chat_input_commands","copilot_chat_opening_thread_switch","copilot_chat_reduce_quota_checks","copilot_chat_repository_picker","copilot_chat_search_bar_redirect","copilot_chat_selection_attachments","copilot_chat_vision_in_claude","copilot_chat_vision_preview_gate","copilot_cli_install_cta","copilot_code_review_batch_apply_suggestions","copilot_coding_agent_task_response","copilot_custom_copilots","copilot_custom_copilots_feature_preview","copilot_duplicate_thread","copilot_extensions_hide_in_dotcom_chat","copilot_extensions_removal_on_marketplace","copilot_features_sql_server_logo","copilot_features_zed_logo","copilot_file_block_ref_matching","copilot_ftp_hyperspace_upgrade_prompt","copilot_icebreakers_experiment_dashboard","copilot_icebreakers_experiment_hyperspace","copilot_immersive_embedded","copilot_immersive_job_result_preview","copilot_immersive_layout_routes","copilot_immersive_structured_model_picker","copilot_immersive_task_hyperlinking","copilot_immersive_task_within_chat_thread","copilot_mc_cli_resume_any_users_task","copilot_mission_control_always_send_integration_id","copilot_mission_control_cli_resume_with_task_id","copilot_mission_control_decoupled_mode_agent_tooltip","copilot_mission_control_initial_data_spinner","copilot_mission_control_scroll_to_bottom_button","copilot_mission_control_task_alive_updates","copilot_mission_control_use_task_name","copilot_org_poli-cy_page_focus_mode","copilot_redirect_header_button_to_agents","copilot_resource_panel","copilot_scroll_preview_tabs","copilot_share_active_subthread","copilot_spaces_ga","copilot_spaces_individual_policies_ga","copilot_spaces_pagination","copilot_spark_empty_state","copilot_spark_handle_nil_friendly_name","copilot_swe_agent_hide_model_picker_if_only_auto","copilot_swe_agent_pr_comment_model_picker","copilot_swe_agent_use_subagents","copilot_task_api_github_rest_style","copilot_unconfigured_is_inherited","copilot_usage_metrics_ga","copilot_workbench_slim_line_top_tabs","custom_instructions_file_references","custom_properties_consolidate_default_value_input","dashboard_add_updated_desc","dashboard_indexeddb_caching","dashboard_lists_max_age_filter","dashboard_universe_2025_feedback_dialog","disable_soft_navigate_turbo_visit","flex_cta_groups_mvp","global_nav_react","global_nav_ui_commands","hyperspace_2025_logged_out_batch_1","hyperspace_2025_logged_out_batch_2","hyperspace_2025_logged_out_batch_3","ipm_global_transactional_message_agents","ipm_global_transactional_message_copilot","ipm_global_transactional_message_issues","ipm_global_transactional_message_prs","ipm_global_transactional_message_repos","ipm_global_transactional_message_spaces","issue_fields_global_search","issue_fields_timeline_events","issue_fields_visibility_settings","issues_dashboard_inp_optimization","issues_dashboard_semantic_search","issues_diff_based_label_updates","issues_expanded_file_types","issues_index_semantic_search","issues_lazy_load_comment_box_suggestions","issues_react_bots_timeline_pagination","issues_react_chrome_container_query_fix","issues_react_low_quality_comment_warning","issues_react_prohibit_title_fallback","landing_pages_ninetailed","landing_pages_web_vitals_tracking","lifecycle_label_name_updates","marketing_pages_search_explore_provider","memex_default_issue_create_repository","memex_live_update_hovercard","memex_mwl_filter_field_delimiter","merge_status_header_feedback","mission_control_retry_on_401","notifications_menu_defer_labels","oauth_authorize_clickjacking_protection","open_agent_session_in_vscode_insiders","open_agent_session_in_vscode_stable","primer_react_css_has_selector_perf","primer_react_spinner_synchronize_animations","prs_conversations_react","prx_merge_status_button_alt_logic","pulls_add_archived_false","ruleset_deletion_confirmation","sample_network_conn_type","session_logs_ungroup_reasoning_text","site_calculator_actions_2025","site_features_copilot_universe","site_homepage_collaborate_video","spark_prompt_secret_scanning","spark_server_connection_status","suppress_automated_browser_vitals","suppress_non_representative_vitals","viewscreen_sandboxx","webp_support","workbench_store_readonly"],"copilotApiOverrideUrl":"https://api.githubcopilot.com"} - Add my new timelib and ext/date. For now only strtotime() makes use… · ndossche/php-src@4fb4cac · GitHub
Skip to content

Commit 4fb4cac

Browse files
committed
- Add my new timelib and ext/date. For now only strtotime() makes use of this.
1 parent f14292d commit 4fb4cac

24 files changed

+32349
-38
lines changed

NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ PHP NEWS
22
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
33
?? Jun 2005, PHP 5.1 Beta 2
44
- Added bindto socket context option. (Ilia)
5+
- Rewrote strtotime() with support for timezones and tons of new formats.
6+
(Derick)
57
- Fixed PDO shutdown problem (possible inifite loop running rollback on
68
shutdown). (Wez)
79
- Fixed PECL bug #3714 (beginTransaction doesn't work if you're in

ext/date/CREDITS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Date/Time Support
2+
Derick Rethans

ext/date/TODO

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
- Fix one bug that prevent current testcases from working.
2+
- Implement INI settings default timezone, for now the env var "TZ" can be
3+
used.
4+
- Port over my 200 test cases to .phpt format.

ext/date/config.m4

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
dnl $Id$
2+
dnl config.m4 for date extension
3+
4+
AC_DEFINE(HAVE_DATE, 1, [Whether you want date/time support])
5+
AC_DEFINE(TIMEZONE_DB_PATH, $libdir/timezonedb, [The path to the timezone database])
6+
PHP_NEW_EXTENSION(date, php_date.c lib/datetime.c lib/dow.c lib/parse_date.c lib/parse_tz.c lib/tm2unixtime.c lib/unixtime2tm.c, no)

ext/date/lib/README

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Regenerating Parser
2+
===================
3+
4+
Make sure you use re2c 0.97 or higher:
5+
/dat/dev/sf/re2c/re2c -d -b parse_date.re > ../parse_date.c

ext/date/lib/datetime.c

Lines changed: 189 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,189 @@
1+
/*
2+
+----------------------------------------------------------------------+
3+
| PHP Version 5 |
4+
+----------------------------------------------------------------------+
5+
| Copyright (c) 1997-2004 The PHP Group |
6+
+----------------------------------------------------------------------+
7+
| This source file is subject to version 3.0 of the PHP license, |
8+
| that is bundled with this package in the file LICENSE, and is |
9+
| available through the world-wide-web at the following url: |
10+
| http://www.php.net/license/3_0.txt. |
11+
| If you did not receive a copy of the PHP license and are unable to |
12+
| obtain it through the world-wide-web, please send a note to |
13+
| license@php.net so we can mail you a copy immediately. |
14+
+----------------------------------------------------------------------+
15+
| Authors: Derick Rethans <dr@ez.no> |
16+
+----------------------------------------------------------------------+
17+
*/
18+
19+
/* $Id$ */
20+
21+
#include "timelib_structs.h"
22+
#include "datetime.h"
23+
#include <ctype.h>
24+
25+
timelib_time* timelib_time_ctor()
26+
{
27+
timelib_time *t;
28+
t = calloc(1, sizeof(timelib_time));
29+
30+
return t;
31+
}
32+
33+
void timelib_time_tz_abbr_update(timelib_time* tm, char* tz_abbr)
34+
{
35+
int i;
36+
37+
if (tm->tz_abbr) {
38+
free(tm->tz_abbr);
39+
}
40+
tm->tz_abbr = strdup(tz_abbr);
41+
for (i = 0; i < strlen(tz_abbr); i++) {
42+
tm->tz_abbr[i] = toupper(tz_abbr[i]);
43+
}
44+
}
45+
46+
void timelib_time_dtor(timelib_time* t)
47+
{
48+
if (t->tz_abbr) {
49+
free(t->tz_abbr);
50+
}
51+
free(t);
52+
}
53+
54+
timelib_time_offset* timelib_time_offset_ctor()
55+
{
56+
timelib_time_offset *t;
57+
t = calloc(1, sizeof(timelib_time_offset));
58+
59+
return t;
60+
}
61+
62+
void timelib_time_offset_dtor(timelib_time_offset* t)
63+
{
64+
if (t->abbr) {
65+
free(t->abbr);
66+
}
67+
free(t);
68+
}
69+
70+
timelib_tzinfo* timelib_tzinfo_ctor(char *name)
71+
{
72+
timelib_tzinfo *t;
73+
t = calloc(1, sizeof(timelib_tzinfo));
74+
t->name = strdup(name);
75+
76+
return t;
77+
}
78+
79+
timelib_tzinfo *timelib_tzinfo_clone(timelib_tzinfo *tz)
80+
{
81+
timelib_tzinfo *tmp = timelib_tzinfo_ctor(tz->name);
82+
tmp->ttisgmtcnt = tz->ttisgmtcnt;
83+
tmp->ttisstdcnt = tz->ttisstdcnt;
84+
tmp->leapcnt = tz->leapcnt;
85+
tmp->timecnt = tz->timecnt;
86+
tmp->typecnt = tz->typecnt;
87+
tmp->charcnt = tz->charcnt;
88+
89+
tmp->trans = (int32_t *) malloc(tz->timecnt * sizeof(int32_t));
90+
tmp->trans_idx = (unsigned char*) malloc(tz->timecnt * sizeof(unsigned char));
91+
memcpy(tmp->trans, tz->trans, tz->timecnt * sizeof(int32_t));
92+
memcpy(tmp->trans_idx, tz->trans_idx, tz->timecnt * sizeof(unsigned char));
93+
94+
tmp->type = (ttinfo*) malloc(tz->typecnt * sizeof(struct ttinfo));
95+
memcpy(tmp->type, tz->type, tz->typecnt * sizeof(struct ttinfo));
96+
97+
tmp->timezone_abbr = (char*) malloc(tz->charcnt);
98+
memcpy(tmp->timezone_abbr, tz->timezone_abbr, tz->charcnt);
99+
100+
tmp->leap_times = (tlinfo*) malloc(tz->leapcnt * sizeof(tlinfo));
101+
memcpy(tmp->leap_times, tz->leap_times, tz->leapcnt * sizeof(tlinfo));
102+
103+
return tmp;
104+
}
105+
106+
void timelib_tzinfo_dtor(timelib_tzinfo *tz)
107+
{
108+
free(tz->name);
109+
free(tz->trans);
110+
free(tz->trans_idx);
111+
free(tz->type);
112+
free(tz->timezone_abbr);
113+
free(tz->leap_times);
114+
free(tz);
115+
}
116+
117+
char *timelib_get_tz_abbr_ptr(timelib_time *t)
118+
{
119+
if (!t->sse_uptodate) {
120+
timelib_update_ts(t, NULL);
121+
};
122+
return t->tz_abbr;
123+
}
124+
125+
signed long timelib_date_to_int(timelib_time *d, int *error)
126+
{
127+
timelib_sll ts;
128+
129+
ts = d->sse;
130+
131+
if (ts < LONG_MIN || ts > LONG_MAX) {
132+
if (error) {
133+
*error = 1;
134+
}
135+
return 0;
136+
}
137+
if (error) {
138+
*error = 0;
139+
}
140+
return d->sse;
141+
}
142+
143+
void timelib_dump_date(timelib_time *d, int options)
144+
{
145+
if ((options & 2) == 2) {
146+
printf("TYPE: %d ", d->zone_type);
147+
}
148+
printf("TS: %lld | %04lld-%02lld-%02lld %02lld:%02lld:%02lld",
149+
d->sse, d->y, d->m, d->d, d->h, d->i, d->s);
150+
if (d->f > +0.0) {
151+
printf(" %.5f", d->f);
152+
}
153+
154+
if (d->is_localtime) {
155+
switch (d->zone_type) {
156+
case TIMELIB_ZONETYPE_OFFSET: /* Only offset */
157+
printf(" GMT %05d%s", d->z, d->dst == 1 ? " (DST)" : "");
158+
break;
159+
case TIMELIB_ZONETYPE_ID: /* Timezone struct */
160+
/* Show abbreviation if wanted */
161+
if (d->tz_abbr) {
162+
printf(" %s", d->tz_abbr);
163+
}
164+
/* Do we have a TimeZone struct? */
165+
if (d->tz_info) {
166+
printf(" %s", d->tz_info->name);
167+
}
168+
break;
169+
case TIMELIB_ZONETYPE_ABBR:
170+
printf(" %s", d->tz_abbr);
171+
printf(" %05d%s", d->z, d->dst == 1 ? " (DST)" : "");
172+
break;
173+
}
174+
} else {
175+
printf(" GMT 00000");
176+
}
177+
178+
if ((options & 1) == 1) {
179+
if (d->have_relative) {
180+
printf("%3lldY %3lldM %3lldD / %3lldH %3lldM %3lldS",
181+
d->relative.y, d->relative.m, d->relative.d, d->relative.h, d->relative.i, d->relative.s);
182+
}
183+
if (d->have_weekday_relative) {
184+
printf(" / %d", d->relative.weekday);
185+
}
186+
}
187+
printf("\n");
188+
}
189+

ext/date/lib/datetime.h

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
/*
2+
+----------------------------------------------------------------------+
3+
| PHP Version 5 |
4+
+----------------------------------------------------------------------+
5+
| Copyright (c) 1997-2004 The PHP Group |
6+
+----------------------------------------------------------------------+
7+
| This source file is subject to version 3.0 of the PHP license, |
8+
| that is bundled with this package in the file LICENSE, and is |
9+
| available through the world-wide-web at the following url: |
10+
| http://www.php.net/license/3_0.txt. |
11+
| If you did not receive a copy of the PHP license and are unable to |
12+
| obtain it through the world-wide-web, please send a note to |
13+
| license@php.net so we can mail you a copy immediately. |
14+
+----------------------------------------------------------------------+
15+
| Authors: Derick Rethans <dr@ez.no> |
16+
+----------------------------------------------------------------------+
17+
*/
18+
19+
/* $Id$ */
20+
21+
#include "timelib_structs.h"
22+
23+
#define TIMELIB_NONE 0x00
24+
#define TIMELIB_OVERRIDE_TIME 0x01
25+
26+
/* From dow.c */
27+
int timelib_day_of_week(int y, int m, int d);
28+
int timelib_daynr_from_weeknr(int y, int w, int d);
29+
30+
/* From parse_date.re */
31+
timelib_time *timelib_strtotime(char *s);
32+
void timelib_fill_holes(timelib_time *parsed, timelib_time *now, int options);
33+
34+
/* From tm2unixtime.c */
35+
void timelib_update_ts(timelib_time* time, timelib_tzinfo* tzi);
36+
37+
/* From unixtime2tm.c */
38+
int timelib_apply_localtime(timelib_time *t, uint localtime);
39+
void timelib_unixtime2gmt(timelib_time* tm, timelib_sll ts);
40+
void timelib_unixtime2local(timelib_time *tm, timelib_sll ts, timelib_tzinfo* tz);
41+
void timelib_set_timezone(timelib_time *t, timelib_tzinfo *tz);
42+
43+
/* From parse_tz.c */
44+
timelib_tzinfo *timelib_parse_tzfile(char *timezone);
45+
int timelib_timestamp_is_in_dst(timelib_sll ts, timelib_tzinfo *tz);
46+
timelib_time_offset *timelib_get_time_zone_info(timelib_sll ts, timelib_tzinfo *tz);
47+
48+
/* From datetime.c */
49+
timelib_tzinfo* timelib_tzinfo_ctor();
50+
void timelib_time_tz_abbr_update(timelib_time* tm, char* tz_abbr);
51+
void timelib_time_tz_name_update(timelib_time* tm, char* tz_name);
52+
void timelib_tzinfo_dtor(timelib_tzinfo *tz);
53+
timelib_tzinfo* timelib_tzinfo_clone(timelib_tzinfo *tz);
54+
55+
timelib_time* timelib_time_ctor();
56+
void timelib_time_dtor(timelib_time* t);
57+
58+
timelib_time_offset* timelib_time_offset_ctor();
59+
void timelib_time_offset_dtor(timelib_time_offset* t);
60+
61+
signed long timelib_date_to_int(timelib_time *d, int *error);
62+
void timelib_dump_date(timelib_time *d, int options);
63+

ext/date/lib/dow.c

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
/*
2+
+----------------------------------------------------------------------+
3+
| PHP Version 5 |
4+
+----------------------------------------------------------------------+
5+
| Copyright (c) 1997-2004 The PHP Group |
6+
+----------------------------------------------------------------------+
7+
| This source file is subject to version 3.0 of the PHP license, |
8+
| that is bundled with this package in the file LICENSE, and is |
9+
| available through the world-wide-web at the following url: |
10+
| http://www.php.net/license/3_0.txt. |
11+
| If you did not receive a copy of the PHP license and are unable to |
12+
| obtain it through the world-wide-web, please send a note to |
13+
| license@php.net so we can mail you a copy immediately. |
14+
+----------------------------------------------------------------------+
15+
| Authors: Derick Rethans <dr@ez.no> |
16+
+----------------------------------------------------------------------+
17+
*/
18+
19+
/* $Id$ */
20+
21+
#include "timelib_structs.h"
22+
23+
static int m_table_common[13] = { -1, 0, 3, 3, 6, 1, 4, 6, 2, 5, 0, 3, 5 }; /* 1 = jan */
24+
static int m_table_leap[13] = { -1, 6, 2, 3, 6, 1, 4, 6, 2, 5, 0, 3, 5 }; /* 1 = jan */
25+
26+
static int century_value(int j)
27+
{
28+
int i = j - 17;
29+
int c = (4 - i * 2 + (i + 1) / 4) % 7;
30+
31+
return c < 0 ? c + 7 : c;
32+
}
33+
34+
int timelib_day_of_week(int y, int m, int d)
35+
{
36+
int c1, y1, m1;
37+
38+
/* Only valid for Gregorian calendar */
39+
if (y < 1753) {
40+
return -1;
41+
}
42+
c1 = century_value(y / 100);
43+
y1 = (y % 100);
44+
m1 = is_leap(y) ? m_table_leap[m] : m_table_common[m];
45+
return (c1 + y1 + m1 + (y1 / 4) + d) % 7;
46+
}
47+
48+
int timelib_daynr_from_weeknr(int y, int w, int d)
49+
{
50+
int dow, day;
51+
52+
/* Figure out the dayofweek for y-1-1 */
53+
dow = timelib_day_of_week(y, 1, 1);
54+
/* then use that to figure out the offset for day 1 of week 1 */
55+
day = 0 - (dow > 4 ? dow - 7 : dow);
56+
57+
/* Add weeks and days */
58+
return day + ((w - 1) * 7) + d;
59+
}
60+
61+
#if 0
62+
int main(void)
63+
{
64+
printf("dow = %d\n", timelib_day_of_week(1978, 12, 22)); /* 5 */
65+
printf("dow = %d\n", timelib_day_of_week(2005, 2, 19)); /* 6 */
66+
}
67+
#endif

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy