Skip to content
This repository has been archived by the owner on Jan 8, 2020. It is now read-only.

Adding a new static ::fromTime($time) method to AbstractDate #6338

Closed

Conversation

beryllium
Copy link

This will enable users to quickly set "future" headers (e.g., Expires):

$headers->addHeader(Expires::fromTime('+12 hours'));

Includes tests :)

Maks3w and others added 30 commits April 1, 2014 08:40
…tionServiceInterface

Use AuthenticationServiceInterface as type
Ocramius and others added 11 commits May 19, 2014 00:13
…callable that was instantiated

Also moving success path to the end of the code block
This will enable users to quickly set "future" headers (e.g., Expires):

```php
$headers->addHeader(Expires::fromTime('+12 hours'));
```

Includes tests :)
@@ -89,6 +89,34 @@ public static function fromString($headerLine)
}

/**
* Create date-based header from Unix time or strtotime()-compatible string
*
* @param $time
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing type.

@Xerkus
Copy link
Member

Xerkus commented Jun 16, 2014

I think that method name is a bit misguiding. Name it something like ::fromTimeString() or let it accept DateTime object
Also i'd suggest you to take a look at DateTime::modify() instead of strtotime

{
$dateHeader = new static();

if (!is_int($time)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really want to accept 2 different formats in a single method?

@weierophinney weierophinney added this to the 2.4.0 milestone Aug 6, 2014
@Ocramius Ocramius self-assigned this Nov 14, 2014
Ocramius added a commit that referenced this pull request Nov 14, 2014
Ocramius added a commit that referenced this pull request Nov 14, 2014
@Ocramius
Copy link
Member

I've manually merged this into develop, and applied minor fixes to it.

See 3e1e0e2

Thanks @beryllium

@Ocramius Ocramius closed this Nov 14, 2014
gianarb pushed a commit to zendframework/zend-http that referenced this pull request May 15, 2015
…e` docblocks/code, simplified logic as well
gianarb pushed a commit to zendframework/zend-http that referenced this pull request May 15, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.