[PHP-DEV] PHP 4.0 Bug #8828 Updated: mktime using mday=0

2001-04-15 Thread dieter

ID: 8828
User Update by: [EMAIL PROTECTED]
Status: Open
Bug Type: Date/time related
Description: mktime using mday=0

FIRST patch to make php_mktime() more compatible [i think it is not complete for the 
whole PHP4-project]. It includes a time correction for values less then 1 on "mday", 
"hour", "min", "sec". NOT on "mon"!!


*** ext/standard/datetime.c.origFri Dec  8 12:38:02 2000
--- ext/standard/datetime.c Sun Apr 15 16:42:37 2001
***
*** 81,87 
struct tm *ta, tmbuf;
time_t t;
int i, gmadjust, seconds, arg_count = ZEND_NUM_ARGS();
!   int is_dst = -1;
  
if (arg_count  7 || zend_get_parameters_array_ex(arg_count,arguments) == 
FAILURE) {
WRONG_PARAM_COUNT;
--- 81,87 
struct tm *ta, tmbuf;
time_t t;
int i, gmadjust, seconds, arg_count = ZEND_NUM_ARGS();
!   int is_dst = -1, val, chgsecs = 0;
  
if (arg_count  7 || zend_get_parameters_array_ex(arg_count,arguments) == 
FAILURE) {
WRONG_PARAM_COUNT;
***
*** 148,172 
  - (((*arguments[5])-value.lval  1000) ? 1900 : 0);
/* fall-through */
case 5:
!   ta-tm_mday = (*arguments[4])-value.lval;
/* fall-through */
case 4:
ta-tm_mon = (*arguments[3])-value.lval - 1;
/* fall-through */
case 3:
!   ta-tm_sec = (*arguments[2])-value.lval;
/* fall-through */
case 2:
!   ta-tm_min = (*arguments[1])-value.lval;
/* fall-through */
case 1:
!   ta-tm_hour = (*arguments[0])-value.lval;
/* fall-through */
case 0:
break;
}
  
!   seconds = mktime(ta);
if (is_dst == -1)
is_dst = ta-tm_isdst;
  
--- 148,180 
  - (((*arguments[5])-value.lval  1000) ? 1900 : 0);
/* fall-through */
case 5:
!   val = (*arguments[4])-value.lval;
!   if (val  1) { chgsecs += (1-val) * 60*60*24; val = 1; }
!   ta-tm_mday = val;
/* fall-through */
case 4:
ta-tm_mon = (*arguments[3])-value.lval - 1;
/* fall-through */
case 3:
!   val = (*arguments[2])-value.lval;
!   if (val  1) { chgsecs += (1-val); val = 1; }
!   ta-tm_sec = val;
/* fall-through */
case 2:
!   val = (*arguments[1])-value.lval;
!   if (val  1) { chgsecs += (1-val) * 60; val = 1; }
!   ta-tm_min = val;
/* fall-through */
case 1:
!   val = (*arguments[0])-value.lval;
!   if (val  1) { chgsecs += (1-val) * 60*60; val = 1; }
!   ta-tm_hour = val;
/* fall-through */
case 0:
break;
}
  
!   seconds = mktime(ta) - chgsecs;
if (is_dst == -1)
is_dst = ta-tm_isdst;


Previous Comments:
---

[2001-03-14 15:56:42] [EMAIL PROTECTED]
I was incorrect, This is not a part of C99(ANSI/ISO/IEC9899-1999) this is just 
implemented in Solaris, Linux, Irix, and possibly a few others.

-Jason

---

[2001-03-14 13:34:47] [EMAIL PROTECTED]
This actually is part of the Ansi C standard.

Solaris 8 manpage ---

The original values of the components may be either greater than or less than the 
specified range. For example, a tm_hour of -1 means 1 hour before midnight, tm_mday of 
0 means the day preceding the current month, and tm_mon of -2 means 2 months before 
January of tm_year


---

Alg from c standard


#define QUOT(a,b) ((a)0 ? (a)/(b) : -(((b)-(a)-1)/(b)))
#define REM(a,b) ((a)-(b)*QUOT(a,b))

SS = tm_hour*3600 + tm_min*60 + tm_sec +
  (tm_leapsecs == _NO_LEAP_SECONDS ? X1 :
 tm_leapsecs) -
  (tm_zone == _LOCALTIME ? X2 : tm_zone) * 60;

// X1 is the appropriate number of leap seconds, determined by
// the implementation, or 0 if it cannot be determined. 
// X2 is the appropriate offset from local time to UTC,
// determined by the implementation, or

// (tm_isdst = 0 ? tm_isdst : 0)
// if the offset cannot be determined

 M = REM(tm_mon, 12);
 Y = tm_year + 1900 + QUOT(tm_mon, 12);
 Z = Y - (M  2 ? 1 : 0);
 D = Y*365 + (Z/400)*97 + (Z%400)/4 +
 M[(int []){0,31,59,90,120,151,181,212,243,273,
   304,335}] +
tm_mday + QUOT(SS, 86400);
   S = REM(SS, 86400);

[PHP-DEV] PHP 4.0 Bug #8828 Updated: mktime using mday=0

2001-03-14 Thread jason

ID: 8828
Updated by: jason
Reported By: [EMAIL PROTECTED]
Status: Open
Bug Type: Date/time related
Assigned To: 
Comments:

This actually is part of the Ansi C standard.

Solaris 8 manpage ---

The original values of the components may be either greater than or less than the 
specified range. For example, a tm_hour of -1 means 1 hour before midnight, tm_mday of 
0 means the day preceding the current month, and tm_mon of -2 means 2 months before 
January of tm_year


---

Alg from c standard


#define QUOT(a,b) ((a)0 ? (a)/(b) : -(((b)-(a)-1)/(b)))
#define REM(a,b) ((a)-(b)*QUOT(a,b))

SS = tm_hour*3600 + tm_min*60 + tm_sec +
  (tm_leapsecs == _NO_LEAP_SECONDS ? X1 :
 tm_leapsecs) -
  (tm_zone == _LOCALTIME ? X2 : tm_zone) * 60;

// X1 is the appropriate number of leap seconds, determined by
// the implementation, or 0 if it cannot be determined. 
// X2 is the appropriate offset from local time to UTC,
// determined by the implementation, or

// (tm_isdst = 0 ? tm_isdst : 0)
// if the offset cannot be determined

 M = REM(tm_mon, 12);
 Y = tm_year + 1900 + QUOT(tm_mon, 12);
 Z = Y - (M  2 ? 1 : 0);
 D = Y*365 + (Z/400)*97 + (Z%400)/4 +
 M[(int []){0,31,59,90,120,151,181,212,243,273,
   304,335}] +
tm_mday + QUOT(SS, 86400);
   S = REM(SS, 86400);
--
Mac OS X is not following this standard

-Jason


Previous Comments:
---

[2001-01-27 07:26:19] [EMAIL PROTECTED]
I have send a bug report to darwin-developers and 
apple, too, but

i have check some UNIX-systems and i haven't found 
any man-page, where is describe what should be 
happend on "tm_mday" = 0.
IMHO this is a undocumented feature, which is used by 
PHP.

man mktime (Linux 2.2.13)

   tm_mday
  The day of the month, in the range 1 to 31.

Sun Release 4.1
--
   int tm_mday; /* day of month (1 - 31) */


SunOS 5.5
---
   int  tm_mday;   /* day of the month - [1, 31] */

HP-UX Release 10.20
--
   int tm_mday; /* day of month - [1,31] */


HP-UX Release 11.00
---
   int tm_mday; /* day of month - [1,31] */

AIX 4.3.2


   int tm_mday;/* Day of month (1 - 31) */


Darwin 1.0.2
-
   int tm_mday; /* day of month (1 - 31) */

I think i should by much better to check mktime() on 
configure and set a #define for compilation. Only on 
"datetime.c" must be made a patch to support MacOS 
X's / Darwin's mktime()-systemcall, i think!


---

[2001-01-22 22:32:57] [EMAIL PROTECTED]
macos x is behaving in a non-standard way. we just use the underlying mktime() 
function.

you might try reporting it to the darwin developers.

http://www.opensource.apple.com/projects/bugs.html

---

[2001-01-21 08:06:36] [EMAIL PROTECTED]
On PHP documantation:
mktime(hour,min,sec, year,0,mon) refers the last day of 
month 'mon-1'. On MacOS X this failed, there it refers 
the first day of month 'mon' and mktime(hour,min,sec, 
year,-1,mon) refers the last day of month 'mon-1'.

See the test:

[aragorn:~/Downloads] dieter% cat A.c
#include stdio.h
#include time.h

main()
{
struct tm mytm;
int i;

mytm.tm_sec = 0; mytm.tm_min = 0;
mytm.tm_hour = 0; mytm.tm_year = 101;
mytm.tm_wday = 0; mytm.tm_yday = 0;
mytm.tm_isdst = 0; mytm.tm_gmtoff = 0;
mytm.tm_zone = 0;

for (i = 2; i = -2; i--)
{
mytm.tm_mday = i;
mytm.tm_mon = 2;
printf ("%02d.%02d ",
   mytm.tm_mday, mytm.tm_mon+1);
printf (" -- %ld", mktime(mytm));
printf (" -- %02d.%02dn",
   mytm.tm_mday, mytm.tm_mon+1);
}
}
[aragorn:~/Downloads] dieter% cc -o A A.c
[aragorn:~/Downloads] dieter% ./A
02.03  -- 983487600 -- 02.03
01.03  -- 983401200 -- 01.03
00.03  -- 983401200 -- 01.03
-1.03  -- 983314800 -- 28.02
-2.03  -- 983228400 -- 27.02
[aragorn:~/Downloads] dieter% 


---



ATTENTION! Do NOT reply to this email!
To reply, use the web interface found at http://bugs.php.net/?id=8828edit=2


-- 
PHP Development Mailing List http://www.php.net/
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list 

Re: [PHP-DEV] PHP 4.0 Bug #8828 Updated: mktime using mday=0

2001-03-14 Thread Jason Greene

Hi Sascha,

Look at 7.23.2.6  Normalization of broken-down times
-Jason



- Original Message - 
From: "Sascha Schumann" [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Sent: Wednesday, March 14, 2001 12:49 PM
Subject: Re: [PHP-DEV] PHP 4.0 Bug #8828 Updated: mktime using mday=0


  This actually is part of the Ansi C standard.
 
  Solaris 8 manpage ---
 
  The original values of the components may be either greater
  than or less than the specified range. For example, a tm_hour
  of -1 means 1 hour before midnight, tm_mday of 0 means the day
  preceding the current month, and tm_mon of -2 means 2 months
  before January of tm_year
 
 This seems to be a Solaris extension.  It does not contradict
 C99, but I would not consider it portable.  Neither section
 7.23.1, "Components of time" nor 7.23.2.3, "The mktime
 function" say anything with regard to values which exceed the
 normal ranges as specified in 7.23.1.
 
 - Sascha  Experience IRCG
   http://schumann.cx/ http://schumann.cx/ircg
 
 
 -- 
 PHP Development Mailing List http://www.php.net/
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]
 


-- 
PHP Development Mailing List http://www.php.net/
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DEV] PHP 4.0 Bug #8828 Updated: mktime using mday=0

2001-03-14 Thread Sascha Schumann

On Wed, 14 Mar 2001, Jason Greene wrote:

 Hi Sascha,

 Look at 7.23.2.6  Normalization of broken-down times

Which version of the "Ansi C standard" are you referring to?

C99 (ANSI/IEC/ISO 9899:1999) does not contain such a section
nor does it contain the term normalization.

The Single Unix Spec II which predates C99 also does not say
anything with regard to ``normalization''.

- Sascha  Experience IRCG
  http://schumann.cx/ http://schumann.cx/ircg


-- 
PHP Development Mailing List http://www.php.net/
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DEV] PHP 4.0 Bug #8828 Updated: mktime using mday=0

2001-03-14 Thread Jason Greene

I think i was looking at a draft, 
is there anything in the your copy oflC99 that resembles?:

7.23.2.6  Normalization of broken-down times

   [#1]  A  broken-down  time  is  normalized  by  the  mkxtime
   function  in  the  following  manner.  A broken-down time is
   normalized by the mktime function in the same manner, but as
   if the struct tm structure had been replaced by a struct tmx
   structure containing the same values except:

   tm_versionis 1

   tm_zone   is _LOCALTIME

   7.23.2.4   Library  7.23.2.6



   WG14/N843August 3, 1998 389


   tm_leapsecs   is _NO_LEAP_SECONDS

   tm_isdst  is  -1,  0,   or   an   implementation-defined
 positive   value   according  to  whether  the
 original member is less  than,  equal  to,  or
 greater than zero

   [#2]  If  any  of  the  following  members  is  outside  the
   indicated range (where L is  LONG_MAX/8),  the  behavior  is
   undefined:

   tm_year   [-L/366, +L/366]

   tm_mon[-L/31, +L/31]

   tm_mday   [-L, +L]

   tm_hour   [-L/3600, +L/3600]

   tm_min[-L/60, +L/60]

   tm_sec[-L, +L]

   tm_leapsecs   [-L, +L] or _NO_LEAP_SECONDS

   tm_zone   [-L/60, +L/60]

   tm_isdst  [-L/60, +L/60] or _LOCALTIME

   The tm_version member shall be 1.

   [#3] Values S and D shall be determined as follows:


   7.23.2.6   Library  7.23.2.

   #define QUOT(a,b) ((a)0 ? (a)/(b) : -(((b)-(a)-1)/(b)))
   #define REM(a,b) ((a)-(b)*QUOT(a,b))




- Original Message - 
From: "Sascha Schumann" [EMAIL PROTECTED]
To: "Jason Greene" [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]; [EMAIL PROTECTED]
Sent: Wednesday, March 14, 2001 1:00 PM
Subject: Re: [PHP-DEV] PHP 4.0 Bug #8828 Updated: mktime using mday=0


 On Wed, 14 Mar 2001, Jason Greene wrote:
 
  Hi Sascha,
 
  Look at 7.23.2.6  Normalization of broken-down times
 
 Which version of the "Ansi C standard" are you referring to?
 
 C99 (ANSI/IEC/ISO 9899:1999) does not contain such a section
 nor does it contain the term normalization.
 
 The Single Unix Spec II which predates C99 also does not say
 anything with regard to ``normalization''.
 
 - Sascha  Experience IRCG
   http://schumann.cx/ http://schumann.cx/ircg
 
 
 -- 
 PHP Development Mailing List http://www.php.net/
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]
 


-- 
PHP Development Mailing List http://www.php.net/
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DEV] PHP 4.0 Bug #8828 Updated: mktime using mday=0

2001-03-14 Thread Sascha Schumann

On Wed, 14 Mar 2001, Jason Greene wrote:

 I think i was looking at a draft,
 is there anything in the your copy oflC99 that resembles?:

 7.23.2.6  Normalization of broken-down times

Jason,

[#1]  A  broken-down  time  is  normalized  by  the  mkxtime
  ^^^
this refers to a proposed new function mkxtime which has not
made it into the final C99.

The full proposal can be found here:

http://anubis.dkuug.dk/JTC1/SC22/WG14/www/docs/n793.htm

And the responding items here:

http://anubis.dkuug.dk/JTC1/SC22/WG14/www/docs/n735.htm

- Sascha Experience IRCG
  http://schumann.cx/http://schumann.cx/ircg


-- 
PHP Development Mailing List http://www.php.net/
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DEV] PHP 4.0 Bug #8828 Updated: mktime using mday=0

2001-03-14 Thread Sascha Schumann

Hi,

 Either way though, you are saying that this has not been
 excepted into the final C99?

Correct.  A bit of googling brought up this page where Paul
Eggert documents why the proposal is broken.

http://www.cl.cam.ac.uk/~mgk25/c-time/comment-eggert.html

 So should we depend on this being a portable standard yet? I
 have used the mday=0 on Solaris, and Linux and have seen it in
 the IRIX manpages

It is not portable as the Mac OS X case shows.  It would be
hard to convince a vendor to implement a certain feature, if
even the proposal for that feature was rejected by the
responsible language committee.

- Sascha Experience IRCG
  http://schumann.cx/http://schumann.cx/ircg


-- 
PHP Development Mailing List http://www.php.net/
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DEV] PHP 4.0 Bug #8828 Updated: mktime using mday=0

2001-03-14 Thread Jason Greene

Sascha + Everyone,

Thanks for pointing that out ( I should have known better to argue standards with 
Sascha: )
I reviewed the official C99 ANSI/ISO/IEC 9899-1999 and it does make no mention as to 
the 
use of mday=0 or the normalization of tm structs as specified in the proposal that I 
was citing.

This is not potable,  though I have seen many Unix's act this way. So should we a) 
just change our 
docs to say something to the effect of "Some UNIX's support mday=0 (Possible list of 
known os's) , but this is not the defacto
standard and you should refer to your system docs". b) remove all references from it
or c) detect when it doesn't work and emulate the functionality.

I vote for (A), seeing as there is no set standard for this, and there is no guarantee 
that the mday=0
functionality will stay. 

What do you guys think?
-Jason


 - 

- Original Message - 
From: "Sascha Schumann" [EMAIL PROTECTED]
To: "Jason Greene" [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Sent: Wednesday, March 14, 2001 1:39 PM
Subject: Re: [PHP-DEV] PHP 4.0 Bug #8828 Updated: mktime using mday=0


 Hi,
 
  Either way though, you are saying that this has not been
  excepted into the final C99?
 
 Correct.  A bit of googling brought up this page where Paul
 Eggert documents why the proposal is broken.
 
 http://www.cl.cam.ac.uk/~mgk25/c-time/comment-eggert.html
 
  So should we depend on this being a portable standard yet? I
  have used the mday=0 on Solaris, and Linux and have seen it in
  the IRIX manpages
 
 It is not portable as the Mac OS X case shows.  It would be
 hard to convince a vendor to implement a certain feature, if
 even the proposal for that feature was rejected by the
 responsible language committee.
 
 - Sascha Experience IRCG
   http://schumann.cx/http://schumann.cx/ircg
 
 
 -- 
 PHP Development Mailing List http://www.php.net/
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]
 


-- 
PHP Development Mailing List http://www.php.net/
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP-DEV] PHP 4.0 Bug #8828 Updated: mktime using mday=0

2001-03-14 Thread jason

ID: 8828
Updated by: jason
Reported By: [EMAIL PROTECTED]
Status: Open
Bug Type: Date/time related
Assigned To: 
Comments:

I was incorrect, This is not a part of C99(ANSI/ISO/IEC9899-1999) this is just 
implemented in Solaris, Linux, Irix, and possibly a few others.

-Jason

Previous Comments:
---

[2001-03-14 13:34:47] [EMAIL PROTECTED]
This actually is part of the Ansi C standard.

Solaris 8 manpage ---

The original values of the components may be either greater than or less than the 
specified range. For example, a tm_hour of -1 means 1 hour before midnight, tm_mday of 
0 means the day preceding the current month, and tm_mon of -2 means 2 months before 
January of tm_year


---

Alg from c standard


#define QUOT(a,b) ((a)0 ? (a)/(b) : -(((b)-(a)-1)/(b)))
#define REM(a,b) ((a)-(b)*QUOT(a,b))

SS = tm_hour*3600 + tm_min*60 + tm_sec +
  (tm_leapsecs == _NO_LEAP_SECONDS ? X1 :
 tm_leapsecs) -
  (tm_zone == _LOCALTIME ? X2 : tm_zone) * 60;

// X1 is the appropriate number of leap seconds, determined by
// the implementation, or 0 if it cannot be determined. 
// X2 is the appropriate offset from local time to UTC,
// determined by the implementation, or

// (tm_isdst = 0 ? tm_isdst : 0)
// if the offset cannot be determined

 M = REM(tm_mon, 12);
 Y = tm_year + 1900 + QUOT(tm_mon, 12);
 Z = Y - (M  2 ? 1 : 0);
 D = Y*365 + (Z/400)*97 + (Z%400)/4 +
 M[(int []){0,31,59,90,120,151,181,212,243,273,
   304,335}] +
tm_mday + QUOT(SS, 86400);
   S = REM(SS, 86400);
--
Mac OS X is not following this standard

-Jason


---

[2001-01-27 07:26:19] [EMAIL PROTECTED]
I have send a bug report to darwin-developers and 
apple, too, but

i have check some UNIX-systems and i haven't found 
any man-page, where is describe what should be 
happend on "tm_mday" = 0.
IMHO this is a undocumented feature, which is used by 
PHP.

man mktime (Linux 2.2.13)

   tm_mday
  The day of the month, in the range 1 to 31.

Sun Release 4.1
--
   int tm_mday; /* day of month (1 - 31) */


SunOS 5.5
---
   int  tm_mday;   /* day of the month - [1, 31] */

HP-UX Release 10.20
--
   int tm_mday; /* day of month - [1,31] */


HP-UX Release 11.00
---
   int tm_mday; /* day of month - [1,31] */

AIX 4.3.2


   int tm_mday;/* Day of month (1 - 31) */


Darwin 1.0.2
-
   int tm_mday; /* day of month (1 - 31) */

I think i should by much better to check mktime() on 
configure and set a #define for compilation. Only on 
"datetime.c" must be made a patch to support MacOS 
X's / Darwin's mktime()-systemcall, i think!


---

[2001-01-22 22:32:57] [EMAIL PROTECTED]
macos x is behaving in a non-standard way. we just use the underlying mktime() 
function.

you might try reporting it to the darwin developers.

http://www.opensource.apple.com/projects/bugs.html

---

[2001-01-21 08:06:36] [EMAIL PROTECTED]
On PHP documantation:
mktime(hour,min,sec, year,0,mon) refers the last day of 
month 'mon-1'. On MacOS X this failed, there it refers 
the first day of month 'mon' and mktime(hour,min,sec, 
year,-1,mon) refers the last day of month 'mon-1'.

See the test:

[aragorn:~/Downloads] dieter% cat A.c
#include stdio.h
#include time.h

main()
{
struct tm mytm;
int i;

mytm.tm_sec = 0; mytm.tm_min = 0;
mytm.tm_hour = 0; mytm.tm_year = 101;
mytm.tm_wday = 0; mytm.tm_yday = 0;
mytm.tm_isdst = 0; mytm.tm_gmtoff = 0;
mytm.tm_zone = 0;

for (i = 2; i = -2; i--)
{
mytm.tm_mday = i;
mytm.tm_mon = 2;
printf ("%02d.%02d ",
   mytm.tm_mday, mytm.tm_mon+1);
printf (" -- %ld", mktime(mytm));
printf (" -- %02d.%02dn",
   mytm.tm_mday, mytm.tm_mon+1);
}
}
[aragorn:~/Downloads] dieter% cc -o A A.c
[aragorn:~/Downloads] dieter% ./A
02.03  -- 983487600 -- 02.03
01.03  -- 983401200 -- 01.03
00.03  -- 983401200 -- 01.03
-1.03  -- 983314800 -- 28.02
-2.03  -- 983228400 -- 27.02
[aragorn:~/Downloads] dieter% 


---



ATTENTION! Do NOT 

[PHP-DEV] PHP 4.0 Bug #8828 Updated: mktime using mday=0

2001-01-27 Thread dieter

ID: 8828
User Update by: [EMAIL PROTECTED]
Old-Status: Closed
Status: Open
Bug Type: Date/time related
Description: mktime using mday=0

I have send a bug report to darwin-developers and 
apple, too, but

i have check some UNIX-systems and i haven't found 
any man-page, where is describe what should be 
happend on "tm_mday" = 0.
IMHO this is a undocumented feature, which is used by 
PHP.

man mktime (Linux 2.2.13)

   tm_mday
  The day of the month, in the range 1 to 31.

Sun Release 4.1
--
   int tm_mday; /* day of month (1 - 31) */


SunOS 5.5
---
   int  tm_mday;   /* day of the month - [1, 31] */

HP-UX Release 10.20
--
   int tm_mday; /* day of month - [1,31] */


HP-UX Release 11.00
---
   int tm_mday; /* day of month - [1,31] */

AIX 4.3.2


   int tm_mday;/* Day of month (1 - 31) */


Darwin 1.0.2
-
   int tm_mday; /* day of month (1 - 31) */

I think i should by much better to check mktime() on 
configure and set a #define for compilation. Only on 
"datetime.c" must be made a patch to support MacOS 
X's / Darwin's mktime()-systemcall, i think!


Previous Comments:
---

[2001-01-22 22:32:57] [EMAIL PROTECTED]
macos x is behaving in a non-standard way. we just use the underlying mktime() 
function.

you might try reporting it to the darwin developers.

http://www.opensource.apple.com/projects/bugs.html

---

[2001-01-21 08:06:36] [EMAIL PROTECTED]
On PHP documantation:
mktime(hour,min,sec, year,0,mon) refers the last day of 
month 'mon-1'. On MacOS X this failed, there it refers 
the first day of month 'mon' and mktime(hour,min,sec, 
year,-1,mon) refers the last day of month 'mon-1'.

See the test:

[aragorn:~/Downloads] dieter% cat A.c
#include stdio.h
#include time.h

main()
{
struct tm mytm;
int i;

mytm.tm_sec = 0; mytm.tm_min = 0;
mytm.tm_hour = 0; mytm.tm_year = 101;
mytm.tm_wday = 0; mytm.tm_yday = 0;
mytm.tm_isdst = 0; mytm.tm_gmtoff = 0;
mytm.tm_zone = 0;

for (i = 2; i = -2; i--)
{
mytm.tm_mday = i;
mytm.tm_mon = 2;
printf ("%02d.%02d ",
   mytm.tm_mday, mytm.tm_mon+1);
printf (" -- %ld", mktime(mytm));
printf (" -- %02d.%02dn",
   mytm.tm_mday, mytm.tm_mon+1);
}
}
[aragorn:~/Downloads] dieter% cc -o A A.c
[aragorn:~/Downloads] dieter% ./A
02.03  -- 983487600 -- 02.03
01.03  -- 983401200 -- 01.03
00.03  -- 983401200 -- 01.03
-1.03  -- 983314800 -- 28.02
-2.03  -- 983228400 -- 27.02
[aragorn:~/Downloads] dieter% 


---


Full Bug description available at: http://bugs.php.net/?id=8828


-- 
PHP Development Mailing List http://www.php.net/
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]