Page MenuHomePhabricator

Write a convenience function for human-readable time calculations
Closed, ResolvedPublic

Description

It would be nice to have some sort of method that works like this:

$ttl = phutil_units('30 days in seconds');

It would parse the string, throw if it couldn't interpret it, and otherwise compute the desired value. This would make this kind of junk:

$ttl = (60 * 60 * 24 * 30); // 30 days

...self-documenting and impossible to get wrong. In almost every case where we use a constant like this, I suspect we can spare the extra function call and regexp.

Event Timeline

epriestley raised the priority of this task from to Needs Triage.
epriestley updated the task description. (Show Details)
epriestley added subscribers: epriestley, btrahan.

See also phabricator_parse_bytes().

epriestley triaged this task as Wishlist priority.Jan 15 2014, 9:55 PM