php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #8242 the date('B') gives bogus output when system date is Thu Dec 14 01:56:02 EET 20
Submitted: 2000-12-13 18:59 UTC Modified: 2001-01-10 01:49 UTC
From: boian at bonev dot com Assigned:
Status: Closed Package: Date/time related
PHP Version: 4.0.3pl1 OS: Linux glibc 2.1
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: boian at bonev dot com
New email:
PHP Version: OS:

 

 [2000-12-13 18:59 UTC] boian at bonev dot com
Sometimes in tzones GMT+something the calculation below can give negative or time greater than 1000

the fix just checks both cases since timezone cannot add more than a day (or less respectively) or in other terms 1000 swatch beats

case 'B':       /* Swatch Beat a.k.a. Internet Time */
beat =  (((((long)the_time)-(((long)the_time) -
        ((((long)the_time) % 86400) + 3600))) * 10) / 864);

-- the fix --

if (beat < 0) beat += 1000;
if (beat > 999) beat -= 1000;

-- end fix --

sprintf(tmp_buff, "%03d", beat); /* SAFE */
strcat(return_value->value.str.val, tmp_buff);
break;

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-01-10 01:49 UTC] david@php.net
fixed with:
                while (beat < 0) {
                    beat += 1000;
                }
                beat = beat % 1000;

Swatch Internet Time is very, very sad.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Apr 20 05:01:27 2024 UTC