Version 1 by Geoffrey Tran
on Feb 12, 2009 11:34.

compared with
Version 2 by Geoffrey Tran
on Feb 12, 2009 11:37.

This line was removed.
This word was removed. This word was added.
This line was added.

Changes (31)

View Page History
{info:title=New Proposal Template}
This page has been created from a template that uses "zones." To proceed:

# Edit the page
# Replace sample content within each zone-data tag with your own content
# Remove this notice
# Save the page
# When you are ready for community review, move this page to the [Ready for Review] section on the edit page.

{note:title=No placeholders allowed!}
Please do not create placeholders. Wait until you have sufficient content to replace all sample data in the proposal template before creating your proposal document.

{zone-template-instance:ZFPROP:Proposal Zone Template}

Zend_Magic Zend_View_Helper_TimeUntil

[My Name|]
[Geoffrey Tran]


1.0 - 1 January 2008: Initial Draft.

Zend_Magic is a simple component that reads my mind and generates code dynamically to do what I want.
This helper calculates the time to an event from timestamps to generate a formatted string like "5 days and 4 hours". It is similar to the TimeSince helper except applications of this helper are generally seen in "This event will start in 5 days and 4 hours" or "3 weeks before expiration" type lines.

Units supported are years, months, weeks, days, minutes, seconds. String format is the largest possible unit and if possible the unit below it. If a 1 year and 2 weeks have passed then "1 year" is the output; however, if 1 year, 2 months and 5 days have passed then "1 year and 2 months" is returned. If less than a second have passed then "less than a second" is returned.

Output is automatically translated if possible using Zend_View_Helper_Translate. The translation format is '%d months'. An already completed gettext pot file is located on Zym's demo in the data locale folder.

* [Harry Houdini Wikipedia Entry|]
* [|]
* [Zym Project's TimeSince|]
* [Zym Project's TimeSince gettext POT|]

Most requirements take the form of "foo will do ...." or "foo will not support ...", although different words and sentence structure might be used. Adding functionality to your proposal is requirements creep (bad), unless listed below. Discuss major changes with your team first, and then open a "feature improvement" issue against this component.

* This component *will* correctly reads a developers mind for intent and generate the right configuration file.
* The generated config file *will not* support XML, but will provide an extension point in the API.
* This component *will* use no more memory than twice the size of all data it contains.
* This component *will* include a factory method. extend Zend_View_Helper_Abstract
* This component *will not* allow subclassing. (i.e. when reviewed, we expect to see "final" keyword in code)
* This component *will* only generate data exports strictly complying with RFC 12345.
* This component *will* validate input data against formats supported by ZF component Foo.
* This component *will not* save any data using Zend_Cache or the filesystem. All transient data *will be* saved using Zend_Session.
* This component *will* allow the use of translation
* This component *will* format a date using a timestamp

* Zend_Exception Zend_View_Helper_Abstract
* Zend_View_Helper_Translate

The component is instantiated with a mind-link that ...
Calculates time until a specified time.

Describe some intermediate state of this component in terms of design notes, additional material added to this page, and / code. Note any significant dependencies here, such as, "Milestone #3 can not be completed until feature Foo has been added to ZF component XYZ." Milestones will be required for acceptance of future proposals. They are not hard, and many times you will only need to think of the first three below.
* Milestone 1: [design notes will be published here|]
* Milestone 2: Working prototype checked into the incubator supporting use cases #1, #2, ...
* Milestone 1: [DONE] Proposal creation
* Milestone 2: [DONE] Working Code, Documentation, Tests
* Milestone 3: Working prototype checked into the incubator supporting use cases #3 and #4.
* Milestone 4: Unit tests exist, work, and are checked into SVN.
* Milestone 5: Initial documentation exists.

If a milestone is already done, begin the description with "\[DONE\]", like this:
* Milestone #: \[DONE\] Unit tests ...

* Zend_Magic_Exception Zend_View_Helper_TimeUntil
* Zend_Magic (factory class)
* Zend_Magic_MindProbe
* Zend_Magic_MindProbe_Intent
* Zend_Magic_Action
* Zend_Magic_CodeGen

... (see good use cases book)
<!-- Simple -->
Your account will expire in <?= $this->timeUntil($timestamp); ?>.

<!-- Time until a specified timestamp -->
<?= $this->timeUntil($timestamp, strtotime('+1 day')); ?>

class Zend_Magic_Exception extends Zend_Exception {}
class Zend_View_Helper_TimeUntil
public function timeUntil($timestamp, $time = null)

class Zend_Magic {
... }