Req #61366 [Opn]: DateInterval should support weeks and days combined

2012-03-14 Thread evert at rooftopsolutions dot nl
Edit report at https://bugs.php.net/bug.php?id=61366edit=1

 ID: 61366
 User updated by:evert at rooftopsolutions dot nl
 Reported by:evert at rooftopsolutions dot nl
 Summary:DateInterval should support weeks and days combined
 Status: Open
 Type:   Feature/Change Request
 Package:Date/time related
 Operating System:   Any
 PHP Version:5.3.10
 Block user comment: N
 Private report: N

 New Comment:

Well, I have several counter points:

1) If it's not supported, it should throw an exception. At the moment it fails 
silently.
2) There's no reason to support a superset of ISO 8601
3) I'm using this because I'm implementing an iCalendar parser. The DURATION 
property type is based on ISO 8601:

http://tools.ietf.org/html/rfc5545#section-3.3.6

In the wild I'm finding duration values with mixed weeks and days. Now I need 
to pre-parse this string, do weeks * 7, then regenerate the (almost identical) 
string before I can add it to the constructor.

I feel adding support for W and D at the same time does not pose additional 
confusion, and is a sensible feature.


Previous Comments:

[2012-03-14 01:51:40] uramihsayibok at gmail dot com

ISO 8601 doesn't allow mixing weeks with anything else.

If you need both then just do the math: 7 * weeks + days


[2012-03-12 21:53:19] evert at rooftopsolutions dot nl

Description:

The DateInterval should support specifying weeks and days at the same time.

This is documented to not be supported, but this is imho silly and confusing.

Test script:
---
?php

$di = new DateIterval('P1W1D');
echo $di-d;

?

Expected result:

8

Actual result:
--
1






-- 
Edit this bug report at https://bugs.php.net/bug.php?id=61366edit=1


Req #61366 [Opn]: DateInterval should support weeks and days combined

2012-03-14 Thread derick
Edit report at https://bugs.php.net/bug.php?id=61366edit=1

 ID: 61366
 Updated by: der...@php.net
 Reported by:evert at rooftopsolutions dot nl
 Summary:DateInterval should support weeks and days combined
 Status: Open
 Type:   Feature/Change Request
 Package:Date/time related
 Operating System:   Any
 PHP Version:5.3.10
 Block user comment: N
 Private report: N

 New Comment:

It should not be as part of d, but rather as part of days. I can quite 
easily add this for just weeks and days, but putting months etc in the mix is 
not going to work. In any case, -days is the only computed property, the rest 
are as parsed.


Previous Comments:

[2012-03-14 09:19:40] evert at rooftopsolutions dot nl

Well, I have several counter points:

1) If it's not supported, it should throw an exception. At the moment it fails 
silently.
2) There's no reason to support a superset of ISO 8601
3) I'm using this because I'm implementing an iCalendar parser. The DURATION 
property type is based on ISO 8601:

http://tools.ietf.org/html/rfc5545#section-3.3.6

In the wild I'm finding duration values with mixed weeks and days. Now I need 
to pre-parse this string, do weeks * 7, then regenerate the (almost identical) 
string before I can add it to the constructor.

I feel adding support for W and D at the same time does not pose additional 
confusion, and is a sensible feature.


[2012-03-14 01:51:40] uramihsayibok at gmail dot com

ISO 8601 doesn't allow mixing weeks with anything else.

If you need both then just do the math: 7 * weeks + days


[2012-03-12 21:53:19] evert at rooftopsolutions dot nl

Description:

The DateInterval should support specifying weeks and days at the same time.

This is documented to not be supported, but this is imho silly and confusing.

Test script:
---
?php

$di = new DateIterval('P1W1D');
echo $di-d;

?

Expected result:

8

Actual result:
--
1






-- 
Edit this bug report at https://bugs.php.net/bug.php?id=61366edit=1


Req #61366 [Opn]: DateInterval should support weeks and days combined

2012-03-14 Thread evert at rooftopsolutions dot nl
Edit report at https://bugs.php.net/bug.php?id=61366edit=1

 ID: 61366
 User updated by:evert at rooftopsolutions dot nl
 Reported by:evert at rooftopsolutions dot nl
 Summary:DateInterval should support weeks and days combined
 Status: Open
 Type:   Feature/Change Request
 Package:Date/time related
 Operating System:   Any
 PHP Version:5.3.10
 Block user comment: N
 Private report: N

 New Comment:

But it appears that currently both P1W and P1D individually get parsed into the 
'd' property.

Wouldn't it make more sense to retain this behaviour when both are supplied, 
but just add them up?

In a sense -d itself is also a computed property, as this is weeks * 7 for 
P1W. There is no -w property.


Previous Comments:

[2012-03-14 10:08:52] der...@php.net

It should not be as part of d, but rather as part of days. I can quite 
easily add this for just weeks and days, but putting months etc in the mix is 
not going to work. In any case, -days is the only computed property, the rest 
are as parsed.


[2012-03-14 09:19:40] evert at rooftopsolutions dot nl

Well, I have several counter points:

1) If it's not supported, it should throw an exception. At the moment it fails 
silently.
2) There's no reason to support a superset of ISO 8601
3) I'm using this because I'm implementing an iCalendar parser. The DURATION 
property type is based on ISO 8601:

http://tools.ietf.org/html/rfc5545#section-3.3.6

In the wild I'm finding duration values with mixed weeks and days. Now I need 
to pre-parse this string, do weeks * 7, then regenerate the (almost identical) 
string before I can add it to the constructor.

I feel adding support for W and D at the same time does not pose additional 
confusion, and is a sensible feature.


[2012-03-14 01:51:40] uramihsayibok at gmail dot com

ISO 8601 doesn't allow mixing weeks with anything else.

If you need both then just do the math: 7 * weeks + days


[2012-03-12 21:53:19] evert at rooftopsolutions dot nl

Description:

The DateInterval should support specifying weeks and days at the same time.

This is documented to not be supported, but this is imho silly and confusing.

Test script:
---
?php

$di = new DateIterval('P1W1D');
echo $di-d;

?

Expected result:

8

Actual result:
--
1






-- 
Edit this bug report at https://bugs.php.net/bug.php?id=61366edit=1