Professional Web Applications Themes

#25787 [Opn->Bgs]: 'yday' in getdate() function is out by one day - PHP Development

ID: 25787 Updated by: [email]sniperphp.net[/email] Reported By: australia at bookrealm dot com -Status: Open +Status: Bogus Bug Type: Date/time related Operating System: SuSE Linux 8.2 PHP Version: 4.3.1 New Comment: Day count for this date (2003-10-08) is 280. e.g. # php -r 'echo date("z");' 280 It's propably mcal that is broken. (and I mean the library, not extension) Previous Comments: ------------------------------------------------------------------------ [2003-10-08 04:21:51] australia at bookrealm dot com Description: ------------ The array key 'yday' from getdate() is one day less than it should be. Bug can be confirmed using mcal_day_of_year(). Reproduce code: --------------- <?php $y = date(Y); $m = date(n); ...

  1. #1

    Default #25787 [Opn->Bgs]: 'yday' in getdate() function is out by one day

    ID: 25787
    Updated by: [email]sniperphp.net[/email]
    Reported By: australia at bookrealm dot com
    -Status: Open
    +Status: Bogus
    Bug Type: Date/time related
    Operating System: SuSE Linux 8.2
    PHP Version: 4.3.1
    New Comment:

    Day count for this date (2003-10-08) is 280.

    e.g.
    # php -r 'echo date("z");'
    280

    It's propably mcal that is broken. (and I mean the library, not
    extension)



    Previous Comments:
    ------------------------------------------------------------------------

    [2003-10-08 04:21:51] australia at bookrealm dot com

    Description:
    ------------
    The array key 'yday' from getdate() is one day less than it
    should be. Bug can be confirmed using mcal_day_of_year().



    Reproduce code:
    ---------------
    <?php
    $y = date(Y);
    $m = date(n);
    $d = date(j);
    echo mcal_day_of_year($y,$m,$d) . "<br />";

    $day_year = getdate();
    echo $day_year[yday];
    ?>

    Expected result:
    ----------------
    Example date:
    2003-10-8

    Expected result:
    281
    281

    Actual result:
    --------------
    Example date:
    2003-10-8

    Actual result:
    281
    280


    ------------------------------------------------------------------------


    --
    Edit this bug report at [url]http://bugs.php.net/?id=25787&edit=1[/url]
    sniper@php.net Guest

  2. #2

    Default #25787 [Opn->Bgs]: 'yday' in getdate() function is out by one day

    ID: 25787
    Updated by: [email]sniperphp.net[/email]
    Reported By: australia at bookrealm dot com
    -Status: Open
    +Status: Bogus
    Bug Type: Date/time related
    Operating System: SuSE Linux 8.2
    PHP Version: 4.3.1
    New Comment:

    Maybe this clears it for you:
    # php -r 'echo date("z", mktime(1,1,1,1,1,2003));'
    0

    The count starts from 0..



    Previous Comments:
    ------------------------------------------------------------------------

    [2003-10-08 05:56:06] australia at bookrealm dot com

    And, IMHO, the example you gave,
    echo date("z");
    thus also seems to give incorrect results.

    ------------------------------------------------------------------------

    [2003-10-08 05:30:45] australia at bookrealm dot com

    Month / days (2003)

    Jan: 31
    Feb: 28
    Mar: 31
    Apr: 30
    May: 31
    Jun: 30
    Jul: 31
    Aug: 31
    Sep: 30
    TOTAL: 273 days

    Currently 8th of Oct, 2003, thus
    PLUS 8 days (273 + 8). So today is day: 281

    Thus, in my humble opinion, mcal_day_of_year() seem
    correct, getdate() seems not to be. But, if getdate() is
    correct, then that makes all the calendars and organizers,
    paper and computer, incorrect when they state Oct 8, 2003,
    as being day '281' and not '280'.

    I did "RTFM" as you had suggested. "0-366" just indicates
    the number range, correct?

    Cheers,
    Andrew Skripshak

    ------------------------------------------------------------------------

    [2003-10-08 04:52:20] [email]sniperphp.net[/email]

    And RTFM: yday == 0-366 days


    ------------------------------------------------------------------------

    [2003-10-08 04:51:41] [email]sniperphp.net[/email]

    Day count for this date (2003-10-08) is 280.

    e.g.
    # php -r 'echo date("z");'
    280

    It's propably mcal that is broken. (and I mean the library, not
    extension)


    ------------------------------------------------------------------------

    [2003-10-08 04:21:51] australia at bookrealm dot com

    Description:
    ------------
    The array key 'yday' from getdate() is one day less than it
    should be. Bug can be confirmed using mcal_day_of_year().



    Reproduce code:
    ---------------
    <?php
    $y = date(Y);
    $m = date(n);
    $d = date(j);
    echo mcal_day_of_year($y,$m,$d) . "<br />";

    $day_year = getdate();
    echo $day_year[yday];
    ?>

    Expected result:
    ----------------
    Example date:
    2003-10-8

    Expected result:
    281
    281

    Actual result:
    --------------
    Example date:
    2003-10-8

    Actual result:
    281
    280


    ------------------------------------------------------------------------


    --
    Edit this bug report at [url]http://bugs.php.net/?id=25787&edit=1[/url]
    sniper@php.net Guest

  3. #3

    Default #25787 [Opn->Bgs]: 'yday' in getdate() function is out by one day

    ID: 25787
    Updated by: [email]sniperphp.net[/email]
    Reported By: australia at bookrealm dot com
    -Status: Open
    +Status: Bogus
    Bug Type: Date/time related
    Operating System: SuSE Linux 8.2
    PHP Version: 4.3.1
    New Comment:

    There is no bug and this is how it works in libc provided date() too.



    Previous Comments:
    ------------------------------------------------------------------------

    [2003-10-08 06:27:10] australia at bookrealm dot com

    Yes, I figured the count started from zero, but really it
    shouldn't. The 1st of the 1st of any year should be day #
    1, not day # 0.

    The manuals state that 'yday' in getdate() and 'z' in
    date() give "The day of the year". This is not correct if
    both are out by one day, and no indication that that is the
    case, and no indication that you must add one day to make
    them correct.

    The proper fix would be to fix the code, but a slacker fix
    would be to state in the manuals that you must add a day,
    ie., date("z") + 1, to get the correct "day of the year"
    number.

    Up to you, of course, which you choose to do.

    Cheers,
    Andrew Skripshak

    ------------------------------------------------------------------------

    [2003-10-08 06:05:45] [email]sniperphp.net[/email]

    Maybe this clears it for you:
    # php -r 'echo date("z", mktime(1,1,1,1,1,2003));'
    0

    The count starts from 0..


    ------------------------------------------------------------------------

    [2003-10-08 05:56:06] australia at bookrealm dot com

    And, IMHO, the example you gave,
    echo date("z");
    thus also seems to give incorrect results.

    ------------------------------------------------------------------------

    [2003-10-08 05:30:45] australia at bookrealm dot com

    Month / days (2003)

    Jan: 31
    Feb: 28
    Mar: 31
    Apr: 30
    May: 31
    Jun: 30
    Jul: 31
    Aug: 31
    Sep: 30
    TOTAL: 273 days

    Currently 8th of Oct, 2003, thus
    PLUS 8 days (273 + 8). So today is day: 281

    Thus, in my humble opinion, mcal_day_of_year() seem
    correct, getdate() seems not to be. But, if getdate() is
    correct, then that makes all the calendars and organizers,
    paper and computer, incorrect when they state Oct 8, 2003,
    as being day '281' and not '280'.

    I did "RTFM" as you had suggested. "0-366" just indicates
    the number range, correct?

    Cheers,
    Andrew Skripshak

    ------------------------------------------------------------------------

    [2003-10-08 04:52:20] [email]sniperphp.net[/email]

    And RTFM: yday == 0-366 days


    ------------------------------------------------------------------------

    The remainder of the comments for this report are too long. To view
    the rest of the comments, please view the bug report online at
    [url]http://bugs.php.net/25787[/url]

    --
    Edit this bug report at [url]http://bugs.php.net/?id=25787&edit=1[/url]
    sniper@php.net Guest

Similar Threads

  1. #25787 [Opn]: 'yday' in getdate() function is out by one day
    By australia at bookrealm dot com in forum PHP Development
    Replies: 1
    Last Post: October 9th, 12:45 AM
  2. #25787 [Bgs->Opn]: 'yday' in getdate() function is out by one day
    By australia at bookrealm dot com in forum PHP Development
    Replies: 2
    Last Post: October 9th, 12:34 AM
  3. #25787 [Bgs]: 'yday' in getdate() function is out by one day
    By sniper@php.net in forum PHP Development
    Replies: 1
    Last Post: October 8th, 10:46 AM
  4. #25787 [NEW]: 'yday' in getdate() function is out by one day
    By australia at bookrealm dot com in forum PHP Development
    Replies: 0
    Last Post: October 8th, 08:24 AM
  5. remove time from getdate()
    By Vishal Parkar in forum Microsoft SQL / MS SQL Server
    Replies: 7
    Last Post: July 8th, 07:57 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139