View Source

<ac:macro ac:name="unmigrated-inline-wiki-markup"><ac:plain-text-body><![CDATA[{zone-template-instance:ZFPROP:Proposal Zone Template}


{zone-data:component-name}
Zend_View_Helper_TimeUntil
{zone-data}

{zone-data:proposer-list}
[Geoffrey Tran]
{zone-data}

{zone-data:liaison}
TBD
{zone-data}

{zone-data:revision}
1.0 - 1 January 2008: Initial Draft.
{zone-data}

{zone-data:overview}
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.
{zone-data}

{zone-data:references}
* [Zym Project's TimeUntil|http://www.zym-project.com/docs/reference/zym.view.html#zym.view.helpers.timeuntil]
* [Zym Project's TimeUntil gettext POT|http://code.google.com/p/zym/source/browse/trunk/demo/data/locale/time.pot]
{zone-data}

{zone-data:requirements}
* This component *will* extend Zend_View_Helper_Abstract
* This component *will* allow the use of translation
* This component *will* format a date using a timestamp
{zone-data}

{zone-data:dependencies}
* Zend_View_Helper_Abstract
* Zend_View_Helper_Translate
{zone-data}

{zone-data:operation}
Calculates time until a specified time.
{zone-data}

{zone-data:milestones}
* Milestone 1: [DONE] Proposal creation
* Milestone 2: [DONE] Working Code, Documentation, Tests
* Milestone 3: Working prototype checked into the incubator.
* Milestone 4: Unit tests exist, work, and are checked into SVN.
* Milestone 5: Initial documentation exists.
{zone-data}

{zone-data:class-list}
* Zend_View_Helper_TimeUntil
{zone-data}

{zone-data:use-cases}
||UC-01||
{code}
<!-- Simple -->
Your account will expire in <?= $this->timeUntil($timestamp); ?>.

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

{zone-data:skeletons}
{code}
class Zend_View_Helper_TimeUntil
{
public function timeUntil($timestamp, $time = null)
{}

}
{code}
{zone-data}

{zone-template-instance}]]></ac:plain-text-body></ac:macro>