Actualización

This commit is contained in:
Xes
2025-04-10 12:24:57 +02:00
parent 8969cc929d
commit 45420b6f0d
39760 changed files with 4303286 additions and 0 deletions

4
vendor/jimmiw/php-time-ago/.gitignore vendored Normal file
View File

@@ -0,0 +1,4 @@
vendor
# IDE's
.idea

View File

@@ -0,0 +1,8 @@
language: php
php:
- '5.4'
- '5.5'
- '5.6'
- '7.0'
install:
- composer install

View File

@@ -0,0 +1,137 @@
Inspired by the comments at: "http://dk.php.net/time":http://dk.php.net/time and "http://api.rubyonrails.org/classes/ActionView/Helpers/DateHelper.html#M001695":http://api.rubyonrails.org/classes/ActionView/Helpers/DateHelper.html#M001695
h1. Using this scheme to determine the "ago" time:
<pre><code>
0 <-> 29 secs # => less than a minute
30 secs <-> 1 min, 29 secs # => 1 minute
1 min, 30 secs <-> 44 mins, 29 secs # => [2..44] minutes
44 mins, 30 secs <-> 89 mins, 29 secs # => about 1 hour
89 mins, 29 secs <-> 23 hrs, 59 mins, 29 secs # => about [2..24] hours
23 hrs, 59 mins, 29 secs <-> 47 hrs, 59 mins, 29 secs # => 1 day
47 hrs, 59 mins, 29 secs <-> 29 days, 23 hrs, 59 mins, 29 secs # => [2..29] days
29 days, 23 hrs, 59 mins, 30 secs <-> 59 days, 23 hrs, 59 mins, 29 secs # => about 1 month
59 days, 23 hrs, 59 mins, 30 secs <-> 1 yr minus 1 sec # => [2..12] months
1 yr <-> 2 yrs minus 1 secs # => about 1 year
2 yrs <-> max time or date # => over [2..X] years
</code></pre>
h1. Changes since last version
Lots have changed since the last version. The WWDateTime class is no longer supported.
I have implemented a new class which takes a time string as parameter (and a
timezone if needed), and calculates the time between them.
By request from "lsolesen" (a guy from here on github) I did removed the whole
DateTime dependence thingy.
h1. About
This class is here to give you the same functionality that DateTime::diff will give you.
However, this will work with PHP versions lower than 5.3.0
This code is also available on Packagist: https://packagist.org/packages/jimmiw/php-time-ago
h1. Two methods instead of just one!
There are now two methods you can call: (well, 3, but two important ones!)
<pre><code>
$timeAgo = new TimeAgo();
echo $timeAgo->inWords("2010/1/10 23:05:00");
// OR
echo timeAgoInWords("2010/1/10 23:05:00");
</code></pre>
Both methods gives the same answer, the "timeAgoInWords()" function is just a
convenience wrapper for you.
h1. Do you want the actual years, months, days, hours, minutes, seconds difference?
Good news for you then!
I've implemented a nice little function that does just that for you. Simply do the
following:
<pre><code>
$timeAgo = new TimeAgo();
$dateDifferenceArray = $timeAgo->dateDifference("2010/1/10 23:05:00");
</code></pre>
This will return an array with the following data:
<pre><code>
array(
);
</code></pre>
h1. Translations added
You can now translate the texts returned using the $timeAgo->inWords() or timeAgoInWords() methods.
The translation is simply a language code string added to the end of the class init or timeAgoInWords() method.
Examples using the Danish translations:
<pre><code>
$timeZone = NULL; // just use the system timezone
$timeAgo = new TimeAgo($timeZone, 'da');
echo $timeAgo->inWords("2010/1/10 23:05:00");
// OR
echo timeAgoInWords("2010/1/10 23:05:00", $timeZone, 'da');
</code></pre>
h1. Changes (versions)
0.4.15: Added Turkish translation (@esrefesen), and Thai (@jaideejung007) and iranian- Farsi(Persian) (@datamweb) and French (@lamberttraccard)
0.4.14: Added Arabic translation (@xc0d3rz)
0.4.13: @jmontoyaa fixed a timezone setting bug
0.4.12: Merged #18, #33 (you can now supply an alternative translations folder), #35 and Added Czech (@misaon)
0.4.11: Changes to French translation (@souhailmerroun). Added Russian and Ukranian translations (@akavolkol)
0.4.10: Added Korean and Finnish translations (thanks to @easylogic and @tk1sul1)
0.4.9: Added Spanish and Hungarian and Brazilian Portuguese (thanks to @khrizt and @technodelight and @gugoan)
0.4.8: Added French and Japanese and Taiwanese translations (thanks to @barohatoum and @hotengchang)
0.4.7: Changes to fix annoying "floor" bugs.
0.4.6: Added Dutch and Chinese translations (thanks to @NielsdeBlaauw and @su-xiaolin)
0.4.5: Fix for wrongly named variable - patch from @rimager
0.4.4: Changed the previous fix, since it caused a problem with the "Scheme" at the start of this document. "about 1 hour ago" is between 44mins30secs and 89mins29secs.
0.4.3: Added a fix for "about 1 hour ago", which would yield "1 hours ago" if the time was 1hour 30minutes. Giving a pluralization error.
0.4.2: Added German translations .
0.4.1: Added "ago" to the end of the translations, so the texts now read "about 1 hour ago".
0.4.0: Added translations (Danish and English) to the plugin.
h1. The old way of doing things.
Just if you wanted to try out the old "time ago" class, I've kept it in the project.
It will eventually be deleted, but hey, go have fun with it. Perhaps even extend it etc.
Bear in mind though, that the new DateTime::diff in PHP version 5.3.0 will eventually
replace it completely. (PHP 5.3.0 DateTime::diff link: http://www.php.net/manual/en/datetime.diff.php)
h1. Known bugs
* dateDifference() calculates a bit wrong when finding differences over 1 year.
h1. The MIT License
Copyright © 2014 Jimmi Westerberg (http://westsworld.dk)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the “Software”), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

View File

@@ -0,0 +1,27 @@
{
"name": "jimmiw/php-time-ago",
"description": "Simple module, that displays the date in a \"time ago\" format",
"keywords": ["time ago", "distance of time", "time ago in words"],
"homepage": "https://github.com/jimmiw/php-time-ago",
"license": "MIT",
"authors": [
{
"name": "Jimmi Westerberg",
"homepage": "http://www.westsworld.dk",
"role": "Developer"
}
],
"require": {
"php": ">=4"
},
"require-dev": {
"phpunit/phpunit": "5.*@stable",
"phpunit/dbunit": "2.0.*"
},
"autoload": {
"files": ["timeago.inc.php"]
},
"config": {
"bin-dir": "vendor/bin/"
}
}

1171
vendor/jimmiw/php-time-ago/composer.lock generated vendored Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,101 @@
<?php
/**
* Testing timeago dates
* @author jimmiw
* @since 2016-03-11
*/
class TimeagoTest extends PHPUnit_Framework_TestCase
{
public function testIsAlive()
{
$this->assertTrue(true);
}
public function testInit()
{
$timeAgo = new TimeAgo();
$this->assertNotNull($timeAgo);
}
/**
* Tests the old core functionality, by being in the same timezone and not changing language.
*/
public function testTimeAgoInWords()
{
$timeAgo = new TimeAgo();
// testing "less than a minute"
$this->assertEquals('less than a minute ago', $timeAgo->inWords("now"));
$this->assertEquals('less than a minute ago', $timeAgo->inWords("-1 second"));
$this->assertEquals('less than a minute ago', $timeAgo->inWords("-29 second"));
$this->assertNotEquals('less than a minute ago', $timeAgo->inWords("-30 second"));
// testing "1 minute"
$this->assertEquals('1 minute ago', $timeAgo->inWords("-30 second"));
$this->assertEquals('1 minute ago', $timeAgo->inWords("-60 second"));
$this->assertEquals('1 minute ago', $timeAgo->inWords("-89 second"));
$this->assertNotEquals('1 minute ago', $timeAgo->inWords("-90 second"));
// testing 2..44 minutes
$this->assertContains('minutes ago', $timeAgo->inWords("-2 minute"));
$this->assertContains('minutes ago', $timeAgo->inWords("-44 minute"));
$this->assertContains('minutes ago', $timeAgo->inWords("-44 minute -29 second"));
$this->assertNotContains('minutes ago', $timeAgo->inWords("-44 minute -30 second"));
// testing about 1 hour
$this->assertEquals('about 1 hour ago', $timeAgo->inWords("-44 minute -30 second"));
$this->assertEquals('about 1 hour ago', $timeAgo->inWords("-89 minute -29 second"));
$this->assertNotEquals('about 1 hour ago', $timeAgo->inWords("-90 minute"));
// testing about 2..24 hours
$this->assertContains('hours ago', $timeAgo->inWords("-90 minute"));
$this->assertContains('hours ago', $timeAgo->inWords("-23 hour -59 minute -29 second"));
$this->assertNotContains('hours ago', $timeAgo->inWords("-23 hour -59 minute -30 second"));
$this->assertNotContains('hours ago', $timeAgo->inWords("-24 hour"));
// testing 1 day
$this->assertEquals('1 day ago', $timeAgo->inWords("-23 hour -59 minute -30 second"));
$this->assertEquals('1 day ago', $timeAgo->inWords("-47 hour -59 minute -29 second"));
$this->assertNotEquals('1 day ago', $timeAgo->inWords("-47 hour -59 minute -30 second"));
// testing 2..24 days
$this->assertContains('days ago', $timeAgo->inWords("-47 hour -59 minute -30 second"));
$this->assertContains('days ago', $timeAgo->inWords("-29 day -23 hour -59 minute -29 second"));
$this->assertNotContains('days ago', $timeAgo->inWords("-29 day -23 hour -59 minute -30 second"));
// testing 1 month
$this->assertEquals('about 1 month ago', $timeAgo->inWords("-29 day -23 hour -59 minute -30 second"));
$this->assertEquals('about 1 month ago', $timeAgo->inWords("-59 day -23 hour -59 minute -29 second"));
$this->assertNotEquals('about 1 month ago', $timeAgo->inWords("-59 day -23 hour -59 minute -30 second"));
// testing 2..12 months
$this->assertContains('months ago', $timeAgo->inWords("-59 day -23 hour -59 minute -30 second"));
// seemed to be the easiest way to get 1 year - 1 second, which should be the day before 1 year ago :)
$oneYearAgo = strtotime("-1 year");
// NOTE: this fails around leap years... so... -2 days must be accurate enough
$twoDays = (2*86400); // 2 days in seconds
$this->assertContains('months ago', $timeAgo->inWords(date('c', $oneYearAgo + $twoDays)));
$this->assertNotContains('months ago', $timeAgo->inWords($oneYearAgo));
// testing 1 year
$this->assertContains('1 year ago', $timeAgo->inWords(date('c', $oneYearAgo - $twoDays)));
$twoYearsAgo = strtotime("-2 year");
$this->assertContains('1 year ago', $timeAgo->inWords(date('c', $twoYearsAgo + $twoDays)));
$this->assertNotContains('1 year ago', $timeAgo->inWords($twoYearsAgo));
// testing 2 years or more
$this->assertEquals('over 2 years ago', $timeAgo->inWords("-2 year"));
$this->assertEquals('over 2 years ago', $timeAgo->inWords("-2 year - 59 day"));
$this->assertEquals('over 3 years ago', $timeAgo->inWords("-3 year"));
$this->assertEquals('over 4 years ago', $timeAgo->inWords("-4 year"));
$this->assertEquals('over 5 years ago', $timeAgo->inWords("-5 year"));
$this->assertEquals('over 6 years ago', $timeAgo->inWords("-6 year"));
$this->assertEquals('over 7 years ago', $timeAgo->inWords("-7 year"));
$this->assertEquals('over 8 years ago', $timeAgo->inWords("-8 year"));
$this->assertEquals('over 9 years ago', $timeAgo->inWords("-9 year"));
$this->assertEquals('over 10 years ago', $timeAgo->inWords("-10 year"));
// you get the point right?...
}
}

View File

@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
colors="true"
forceCoversAnnotation="false"
codecoverage="true">
<!-- <formatter type="clover" usefile="false" />
<logging>
<log type="coverage-html" target="../build/coverage"/>
<log type="coverage-clover" target="../build/logs/clover.xml"/>
<log type="coverage-crap4j" target="../build/logs/crap4j.xml"/>
<log type="junit" target="../build/logs/junit.xml" logIncompleteSkipped="false"/>
</logging> -->
<testsuite name="php-time-ago">
<directory>./</directory>
</testsuite>
<filter>
<whitelist>
<file>../timeago.inc.php</file>
</whitelist>
</filter>
</phpunit>

View File

@@ -0,0 +1,180 @@
<?php
require('../westsworld.datetime.class.php');
require('../timeago.inc.php');
echo "<h1>TimeAgo class tests!</h1>";
echo "<p>";
echo "<h2>testing TimeAgo class</h2>";
echo "<strong>rule 1</strong> (0 <-> 29 secs # => less than a minute)<br/>";
$timeAgo = new TimeAgo();
echo $timeAgo->inWords("2010/4/26 22:03:29","2010/4/26 22:03:58");
echo "<br/>";
echo "<br/><strong>rule 2</strong> (30 secs <-> 1 min, 29 secs # => 1 minute)<br/>";
$timeAgo = new TimeAgo();
echo $timeAgo->inWords("2010/4/26 22:03:30","2010/4/26 22:04:58");
echo "<br/>";
echo "<br/><strong>rule 3</strong> (1 min, 30 secs <-> 44 mins, 29 secs # => [2..44] minutes)<br/>";
$timeAgo = new TimeAgo();
echo $timeAgo->inWords("2010/4/26 22:03:28","2010/4/26 22:04:58");
echo "<br/>";
$timeAgo = new TimeAgo();
echo $timeAgo->inWords("2010/4/26 22:03:28","2010/4/26 22:15:58");
echo "<br/>";
$timeAgo = new TimeAgo();
echo $timeAgo->inWords("2010/4/26 22:03:28","2010/4/26 22:47:57");
echo "<br/>";
echo "<br/><strong>rule 4</strong> (44 mins, 30 secs <-> 89 mins, 29 secs # => about 1 hour)<br/>";
$timeAgo = new TimeAgo();
echo $timeAgo->inWords("2010/4/26 22:03:28","2010/4/26 22:47:58");
echo "<br/>";
$timeAgo = new TimeAgo();
echo $timeAgo->inWords("2010/4/26 22:03:28","2010/4/26 23:32:57");
echo "<br/>";
echo "<br/><strong>rule 5</strong>(89 mins, 29 secs <-> 23 hrs, 59 mins, 29 secs # => about [2..24] hours)<br/>";
$timeAgo = new TimeAgo();
echo $timeAgo->inWords("2010/4/26 00:00:00","2010/4/26 01:30:00");
echo "<br/>";
$timeAgo = new TimeAgo();
echo $timeAgo->inWords("2010/4/26 00:00:00","2010/4/26 13:49:00");
echo "<br/>";
$timeAgo = new TimeAgo();
echo $timeAgo->inWords("2010/4/26 00:00:00","2010/4/26 23:59:29");
echo "<br/>";
echo "<br/><strong>rule 6</strong> (23 hrs, 59 mins, 29 secs <-> 47 hrs, 59 mins, 29 secs # => 1 day)<br/>";
$timeAgo = new TimeAgo();
echo $timeAgo->inWords("2010/4/26 00:00:00","2010/4/26 23:59:30");
echo "<br/>";
$timeAgo = new TimeAgo();
echo $timeAgo->inWords("2010/4/26 00:00:00","2010/4/27 13:10:00");
echo "<br/>";
$timeAgo = new TimeAgo();
echo $timeAgo->inWords("2010/4/26 00:00:00","2010/4/27 23:59:29");
echo "<br/>";
echo "<br/><strong>rule 7</strong> (47 hrs, 59 mins, 30 secs <-> 29 days, 23 hrs, 59 mins, 29 secs # => [2..29] days)<br/>";
$timeAgo = new TimeAgo();
echo $timeAgo->inWords("2010/4/26 00:00:00","2010/4/27 23:59:30");
echo "<br/>";
$timeAgo = new TimeAgo();
echo $timeAgo->inWords("2010/4/26 00:00:00","2010/5/10 00:00:00");
echo "<br/>";
$timeAgo = new TimeAgo();
echo $timeAgo->inWords("2010/4/26 00:00:00","2010/5/25 23:59:29");
echo "<br/>";
echo "<br/><strong>rule 8</strong> (29 days, 23 hrs, 59 mins, 30 secs <-> 59 days, 23 hrs, 59 mins, 29 secs # => about 1 month)<br/>";
$timeAgo = new TimeAgo();
echo $timeAgo->inWords("2010/4/26 00:00:00","2010/5/25 23:59:30");
echo "<br/>";
$timeAgo = new TimeAgo();
echo $timeAgo->inWords("2010/4/26 00:00:00","2010/5/28 10:05:30");
echo "<br/>";
$timeAgo = new TimeAgo();
echo $timeAgo->inWords("2010/4/26 00:00:00","2010/6/24 23:59:29");
echo "<br/>";
echo "<br/><strong>rule 9</strong> (59 days, 23 hrs, 59 mins, 30 secs <-> 1 yr minus 1 sec # => [2..12] months)<br/>";
$timeAgo = new TimeAgo();
echo $timeAgo->inWords("2010/4/26 00:00:00","2010/6/24 23:59:30");
echo "<br/>";
$timeAgo = new TimeAgo();
echo $timeAgo->inWords("2009/10/01 00:00:00","2010/5/28 10:05:30");
echo "<br/>";
$timeAgo = new TimeAgo();
echo $timeAgo->inWords("2009/4/26 00:00:00","2010/4/20 00:00:00");
echo "<br/>";
echo "<br/><strong>rule 10</strong> (1 yr <-> 2 yrs minus 1 secs # => about 1 year)<br/>";
$timeAgo = new TimeAgo();
echo $timeAgo->inWords("2009/4/26 00:00:00","2010/4/26 00:00:00");
echo "<br/>";
$timeAgo = new TimeAgo();
echo $timeAgo->inWords("2009/01/01 00:00:00","2010/5/01 00:00:00");
echo "<br/>";
$timeAgo = new TimeAgo();
echo $timeAgo->inWords("2010/4/26 00:00:00","2011/4/26 23:59:59");
echo "<br/>";
echo "<br/><strong>rule 11</strong> (2 yrs <-> max time or date # => over [2..X] years)<br/>";
$timeAgo = new TimeAgo();
echo $timeAgo->inWords("2009/4/26 00:00:00","2011/4/26 00:00:00");
echo "<br/>";
$timeAgo = new TimeAgo();
echo $timeAgo->inWords("2005/4/26 00:00:00","2011/4/26 00:00:00");
echo "<br/>";
$timeAgo = new TimeAgo();
echo $timeAgo->inWords("1999/4/26 00:00:00","2011/4/26 00:00:00");
echo "<br/>";
echo "</p>";
echo "<h2>TimeAgo class tests (dateDifference)</h2>";
echo "<p>";
$timeAgo = new TimeAgo();
echo "<pre>";
print_r($timeAgo->dateDifference("2010/4/01 00:00:00","2010/5/12 03:05:30"));
echo "</pre>";
echo "</p>";
echo "<h1>WWDateTime class tests!</h1>";
function test_time($timeAgo, $timeAsItShouldBe) {
echo "<p>";
$datetime = new WWDateTime($timeAgo);
echo $datetime->format(DATE_RFC3339);
echo " = ";
echo $datetime->timeAgoInWords();
echo " === ";
echo $timeAsItShouldBe;
echo "</p>";
}
test_time("-2 year", "over 2 years");
timeAgoInWords("-2 year");
test_time("-1 year", "about 1 year");
timeAgoInWords("-1 year");
test_time("-1 month", "about 1 month");
timeAgoInWords("-1 month");
test_time("-2 month", "about 2 months");
timeAgoInWords("-2 month");
test_time("-1 day", "1 day");
timeAgoInWords("-1 day");
test_time("-2 day", "2 days");
timeAgoInWords("-2 day");
test_time("-1 hour", "about 1 hour");
timeAgoInWords("-1 hour");
test_time("-2 hour", "about 2 hours");
timeAgoInWords("-2 hour");
test_time("-1 minute", "about 1 minute");
timeAgoInWords("-1 minute");
test_time("-2 minute", "about 2 minutes");
timeAgoInWords("-2 minute");
test_time("-44 minute", "about 44 minutes");
timeAgoInWords("-44 minute");
test_time("-45 minute", "about 1 hour");
timeAgoInWords("-45 minute");
test_time("-1 second", "less than a minute");
timeAgoInWords("-1 second");
test_time("-31 second", "1 minute");
timeAgoInWords("-31 second");
echo "<h2>Language testing</h2>";
echo "<p>";
echo "<br/><strong>English</strong><br/>";
$timeAgo = new TimeAgo();
echo $timeAgo->inWords("2015/5/26 10:00:10","2015/5/26 10:00:20");
echo "<br/>";
echo "<br/><strong>Danish</strong><br/>";
$timeAgo = new TimeAgo(NULL, 'da');
echo $timeAgo->inWords("2015/5/26 10:00:10","2015/5/26 10:00:20");
echo "<br/>";
echo "</p>";
?>

View File

@@ -0,0 +1,370 @@
<?php
// To allow overriding this function as will, if someone wants to use a derived class of `TimeAgo`
if (!function_exists('timeAgoInWords')) {
function timeAgoInWords($timestring, $timezone = null, $language = 'en')
{
$timeAgo = new TimeAgo($timezone, $language);
return $timeAgo->inWords($timestring, "now");
}
}
/**
* This class can help you find out just how much time has passed between
* two dates.
*
* It has two functions you can call:
* inWords() which gives you the "time ago in words" between two dates.
* dateDifference() which returns an array of years,months,days,hours,minutes and
* seconds between the two dates.
*
* @author jimmiw
* @since 0.2.0 (2010/05/05)
* @site http://github.com/jimmiw/php-time-ago
*/
class TimeAgo
{
// defines the number of seconds per "unit"
private $secondsPerMinute = 60;
private $secondsPerHour = 3600;
private $secondsPerDay = 86400;
private $secondsPerMonth = 2592000;
private $secondsPerYear = 31536000; // 31622400 seconds on leap years though...
private $timezone;
private $previousTimezone;
// translations variables
private static $language;
private static $timeAgoStrings = null;
/**
* TimeAgo constructor.
* @param null|DateTimeZone $timezone the timezone to use (uses system if none is given)
* @param string $language the language to use (defaults to 'en' for english)
*/
public function __construct($timezone = null, $language = 'en')
{
// loads the translation files
self::_loadTranslations($language);
// storing the current timezone
$this->timezone = $timezone;
}
/**
* Fetches the different between $past and $now in a spoken format.
* NOTE: both past and now should be parseable by strtotime
* @param string $past the past date to use
* @param string $now the current time, defaults to now (can be an other time though)
* @return string the difference in spoken format, e.g. 1 day ago
*/
public function inWords($past, $now = "now")
{
// sets the default timezone
$this->changeTimezone();
// finds the past in datetime
$past = strtotime($past);
// finds the current datetime
$now = strtotime($now);
// creates the "time ago" string. This always starts with an "about..."
$timeAgo = "";
// finds the time difference
$timeDifference = $now - $past;
// rule 0
// $past is null or empty or ''
if ($past === '' || is_null($past) || empty($past)) {
$timeAgo = $this->_translate('never');
}
// rule 1
// less than 29secs
else if ($timeDifference <= 29) {
$timeAgo = $this->_translate('lessThanAMinute');
}
// rule 2
// more than 29secs and less than 1min29secss
else if ($timeDifference >= 30 && $timeDifference <= 89) {
$timeAgo = $this->_translate('oneMinute');
}
// rule 3
// between 1min30secs and 44mins29secs
else if ($timeDifference >= 90 &&
$timeDifference <= (($this->secondsPerMinute * 44) + 29)
) {
$minutes = round($timeDifference / $this->secondsPerMinute);
$timeAgo = $this->_translate('lessThanOneHour', $minutes);
}
// rule 4
// between 44mins30secs and 1hour29mins59secs
else if (
$timeDifference >= (($this->secondsPerMinute * 44) + 30)
&&
$timeDifference <= ($this->secondsPerHour + ($this->secondsPerMinute * 29) + 59)
) {
$timeAgo = $this->_translate('aboutOneHour');
}
// rule 5
// between 1hour29mins59secs and 23hours59mins29secs
else if (
$timeDifference >= (
$this->secondsPerHour +
($this->secondsPerMinute * 30)
)
&&
$timeDifference <= (
($this->secondsPerHour * 23) +
($this->secondsPerMinute * 59) +
29
)
) {
$hours = round($timeDifference / $this->secondsPerHour);
$timeAgo = $this->_translate('hours', $hours);
}
// rule 6
// between 23hours59mins30secs and 47hours59mins29secs
else if (
$timeDifference >= (
($this->secondsPerHour * 23) +
($this->secondsPerMinute * 59) +
30
)
&&
$timeDifference <= (
($this->secondsPerHour * 47) +
($this->secondsPerMinute * 59) +
29
)
) {
$timeAgo = $this->_translate('aboutOneDay');
}
// rule 7
// between 47hours59mins30secs and 29days23hours59mins29secs
else if (
$timeDifference >= (
($this->secondsPerHour * 47) +
($this->secondsPerMinute * 59) +
30
)
&&
$timeDifference <= (
($this->secondsPerDay * 29) +
($this->secondsPerHour * 23) +
($this->secondsPerMinute * 59) +
29
)
) {
$days = round($timeDifference / $this->secondsPerDay);
$timeAgo = $this->_translate('days', $days);
}
// rule 8
// between 29days23hours59mins30secs and 59days23hours59mins29secs
else if (
$timeDifference >= (
($this->secondsPerDay * 29) +
($this->secondsPerHour * 23) +
($this->secondsPerMinute * 59) +
30
)
&&
$timeDifference <= (
($this->secondsPerDay * 59) +
($this->secondsPerHour * 23) +
($this->secondsPerMinute * 59) +
29
)
) {
$timeAgo = $this->_translate('aboutOneMonth');
}
// rule 9
// between 59days23hours59mins30secs and 1year (minus 1sec)
else if (
$timeDifference >= (
($this->secondsPerDay * 59) +
($this->secondsPerHour * 23) +
($this->secondsPerMinute * 59) +
30
)
&&
$timeDifference < $this->secondsPerYear
) {
$months = round($timeDifference / $this->secondsPerMonth);
// if months is 1, then set it to 2, because we are "past" 1 month
if ($months == 1) {
$months = 2;
}
$timeAgo = $this->_translate('months', $months);
}
// rule 10
// between 1year and 2years (minus 1sec)
else if (
$timeDifference >= $this->secondsPerYear
&&
$timeDifference < ($this->secondsPerYear * 2)
) {
$timeAgo = $this->_translate('aboutOneYear');
}
// rule 11
// 2years or more
else {
$years = floor($timeDifference / $this->secondsPerYear);
$timeAgo = $this->_translate('years', $years);
}
$this->restoreTimezone();
return $timeAgo;
}
/**
* Fetches the date difference between the two given dates.
* NOTE: both past and now should be parseable by strtotime
*
* @param string $past the "past" time to parse
* @param string $now the "now" time to parse
* @return array the difference in dates, using the two dates
*/
public function dateDifference($past, $now = "now")
{
// initializes the placeholders for the different "times"
$seconds = 0;
$minutes = 0;
$hours = 0;
$days = 0;
$months = 0;
$years = 0;
// sets the default timezone
$this->changeTimezone();
// finds the past in datetime
$past = strtotime($past);
// finds the current datetime
$now = strtotime($now);
// calculates the difference
$timeDifference = $now - $past;
// starts determining the time difference
if ($timeDifference >= 0) {
switch ($timeDifference) {
// finds the number of years
case ($timeDifference >= $this->secondsPerYear):
// uses floor to remove decimals
$years = floor($timeDifference / $this->secondsPerYear);
// saves the amount of seconds left
$timeDifference = $timeDifference - ($years * $this->secondsPerYear);
// finds the number of months
case ($timeDifference >= $this->secondsPerMonth && $timeDifference <= ($this->secondsPerYear - 1)):
// uses floor to remove decimals
$months = floor($timeDifference / $this->secondsPerMonth);
// saves the amount of seconds left
$timeDifference = $timeDifference - ($months * $this->secondsPerMonth);
// finds the number of days
case ($timeDifference >= $this->secondsPerDay && $timeDifference <= ($this->secondsPerYear - 1)):
// uses floor to remove decimals
$days = floor($timeDifference / $this->secondsPerDay);
// saves the amount of seconds left
$timeDifference = $timeDifference - ($days * $this->secondsPerDay);
// finds the number of hours
case ($timeDifference >= $this->secondsPerHour && $timeDifference <= ($this->secondsPerDay - 1)):
// uses floor to remove decimals
$hours = floor($timeDifference / $this->secondsPerHour);
// saves the amount of seconds left
$timeDifference = $timeDifference - ($hours * $this->secondsPerHour);
// finds the number of minutes
case ($timeDifference >= $this->secondsPerMinute && $timeDifference <= ($this->secondsPerHour - 1)):
// uses floor to remove decimals
$minutes = floor($timeDifference / $this->secondsPerMinute);
// saves the amount of seconds left
$timeDifference = $timeDifference - ($minutes * $this->secondsPerMinute);
// finds the number of seconds
case ($timeDifference <= ($this->secondsPerMinute - 1)):
// seconds is just what there is in the timeDifference variable
$seconds = $timeDifference;
}
}
$this->restoreTimezone();
$difference = [
"years" => $years,
"months" => $months,
"days" => $days,
"hours" => $hours,
"minutes" => $minutes,
"seconds" => $seconds,
];
return $difference;
}
/**
* Translates the given $label, and adds the given $time.
* @param string $label the label to translate
* @param string $time the time to add to the translated text.
* @return string the translated label text including the time.
*/
protected function _translate($label, $time = '')
{
// handles a usecase introduced in #18, where a new translation was added.
// This would cause an array-out-of-bound exception, since the index does not
// exist in most translations.
if (!isset(self::$timeAgoStrings[$label])) {
return '';
}
return sprintf(self::$timeAgoStrings[$label], $time);
}
/**
* Loads the translations into the system.
*/
protected static function _loadTranslations($language, $alternate_path = null)
{
// no time strings loaded? load them and store it all in static variables
if (self::$timeAgoStrings == null || self::$language != $language) {
include(__DIR__ . '/translations/' . $language . '.php');
if (!isset($timeAgoStrings) && $alternate_path) {
include($alternate_path);
}
// storing the time strings in the current object
self::$timeAgoStrings = $timeAgoStrings;
// loads the language files
if (self::$timeAgoStrings == null) {
error_log('Could not load language file for language ' . $language . '. Please ensure that the file exists in ' . __DIR__ . 'translations/' . $language . '.php');
}
}
// storing the language
self::$language = $language;
}
protected function changeTimezone()
{
$this->previousTimezone = false;
if ($this->timezone) {
$this->previousTimezone = date_default_timezone_get();
date_default_timezone_set($this->timezone);
}
}
protected function restoreTimezone()
{
if ($this->previousTimezone) {
date_default_timezone_set($this->previousTimezone);
$this->previousTimezone = false;
}
}
}

View File

@@ -0,0 +1,17 @@
<?php
$timeAgoStrings = array(
'aboutOneDay' => "منذ يوم",
'aboutOneHour' => "منذ ساعة",
'aboutOneMonth' => "منذ شهر",
'aboutOneYear' => "منذ سنة",
'days' => "منذ %s ايام",
'hours' => "منذ %s ساعات",
'lessThanAMinute' => "منذ أقل من دقيقة",
'lessThanOneHour' => "منذ %s دقيقة",
'months' => "منذ شهر",
'oneMinute' => "منذ دقيقة",
'years' => "منذ أكثر من سنة"
);

View File

@@ -0,0 +1,15 @@
<?php
$timeAgoStrings = array(
'aboutOneDay' => "před 1 dnem",
'aboutOneHour' => "před 1 hodinou",
'aboutOneMonth' => "před 1 měsícem",
'aboutOneYear' => "před 1 rokem",
'days' => "před %s dny",
'hours' => "před %s hodinami",
'lessThanAMinute' => "před méně jak minutou",
'lessThanOneHour' => "před %s minutami",
'months' => "před %s měsíci",
'oneMinute' => "před 1 minutou",
'years' => "před %s lety"
);

View File

@@ -0,0 +1,15 @@
<?php
$timeAgoStrings = array(
'aboutOneDay' => "1 dag siden",
'aboutOneHour' => "cirka 1 time siden",
'aboutOneMonth' => "cirka 1 måned siden",
'aboutOneYear' => "cirka 1 år siden",
'days' => "%s dage siden",
'hours' => "%s timer siden",
'lessThanAMinute' => "mindre end et minut siden",
'lessThanOneHour' => "%s minutter siden",
'months' => "%s måneder siden",
'oneMinute' => "1 minut siden",
'years' => "over %s år siden"
);

View File

@@ -0,0 +1,15 @@
<?php
$timeAgoStrings = array(
'aboutOneDay' => "vor einem Tag",
'aboutOneHour' => "vor etwa einer Stunde",
'aboutOneMonth' => "vor etwa einem Monat",
'aboutOneYear' => "vor etwa einem Jahr",
'days' => "vor %s Tagen",
'hours' => "vor %s Stunden",
'lessThanAMinute' => "vor weniger als einer Minute",
'lessThanOneHour' => "vor %s Minuten",
'months' => "vor %s Monaten",
'oneMinute' => "vor einer Minute",
'years' => "vor über %s Jahren"
);

View File

@@ -0,0 +1,16 @@
<?php
$timeAgoStrings = array(
'aboutOneDay' => "1 day ago",
'aboutOneHour' => "about 1 hour ago",
'aboutOneMonth' => "about 1 month ago",
'aboutOneYear' => "about 1 year ago",
'days' => "%s days ago",
'hours' => "%s hours ago",
'lessThanAMinute' => "less than a minute ago",
'lessThanOneHour' => "%s minutes ago",
'months' => "%s months ago",
'oneMinute' => "1 minute ago",
'years' => "over %s years ago",
'never' => 'Never'
);

View File

@@ -0,0 +1,15 @@
<?php
$timeAgoStrings = array(
'aboutOneDay' => "hace 1 día",
'aboutOneHour' => "hace 1 hora",
'aboutOneMonth' => "hace 1 mes",
'aboutOneYear' => "hace 1 año",
'days' => "hace %s días",
'hours' => "hace %s horas",
'lessThanAMinute' => "hace menos de 1 minuto",
'lessThanOneHour' => "hace %s minutos",
'months' => "hace %s meses",
'oneMinute' => "hace 1 minuto",
'years' => "hace %s años"
);

View File

@@ -0,0 +1,15 @@
<?php
$timeAgoStrings = array(
'aboutOneDay' => "1 روز قبل",
'aboutOneHour' => "حدود 1 ساعت قبل",
'aboutOneMonth' => "حدود 1 ماه قبل",
'aboutOneYear' => "حدود 1 سال قبل",
'days' => "%s روز قبل",
'hours' => "%s ساعت قبل",
'lessThanAMinute' => "کمتر از 1 دقیقه قبل",
'lessThanOneHour' => "%s دقیقه قبل",
'months' => "%sماه قبل",
'oneMinute' => "1 دقیقه قبل",
'years' => "بیش از %s سال قبل",
'never' => 'هرگز'
);

View File

@@ -0,0 +1,15 @@
<?php
$timeAgoStrings = array(
'aboutOneDay' => "1 päivä",
'aboutOneHour' => "noin tunti sitten",
'aboutOneMonth' => "noin kuukausi sitten",
'aboutOneYear' => "noin vuosi sitten",
'days' => "%s päivää sitten",
'hours' => "%s tuntia sitten",
'lessThanAMinute' => "alle minuutti sitten",
'lessThanOneHour' => "%s minuuttia sitten",
'months' => "%s kuukautta sitten",
'oneMinute' => "1 minuutti sitten",
'years' => "yli %s vuotta sitten"
);

View File

@@ -0,0 +1,15 @@
<?php
$timeAgoStrings = array(
'aboutOneDay' => "depuis un jour",
'aboutOneHour' => "depuis à peu près une heure",
'aboutOneMonth' => "depuis à peu près un mois",
'aboutOneYear' => "depuis à peu près une année",
'days' => "depuis %s jours",
'hours' => "depuis %s heures",
'lessThanAMinute' => "depuis moins d'une minute",
'lessThanOneHour' => "depuis %s minutes",
'months' => "depuis %s mois",
'oneMinute' => "depuis une minute",
'years' => "depuis plus de %s années"
);

View File

@@ -0,0 +1,15 @@
<?php
$timeAgoStrings = array(
'aboutOneDay' => "1 napja",
'aboutOneHour' => "körülbelül 1 órája",
'aboutOneMonth' => "körülbelül 1 hónapja",
'aboutOneYear' => "körülbelül 1 éve",
'days' => "%s napja",
'hours' => "%s órája",
'lessThanAMinute' => "kevesebb, mint egy perce",
'lessThanOneHour' => "%s perce",
'months' => "%s hónapja",
'oneMinute' => "1 perce",
'years' => "több, mint %s éve"
);

View File

@@ -0,0 +1,15 @@
<?php
$timeAgoStrings = array(
'aboutOneDay' => "1日前",
'aboutOneHour' => "約1時間前",
'aboutOneMonth' => "約1ヶ月前",
'aboutOneYear' => "約1年前",
'days' => "%s日前",
'hours' => "%s時間前",
'lessThanAMinute' => "たった今",
'lessThanOneHour' => "%s分前",
'months' => "%sヶ月前",
'oneMinute' => "1分前",
'years' => "%s年以上前"
);

View File

@@ -0,0 +1,15 @@
<?php
$timeAgoStrings = array(
'aboutOneDay' => "<EFBFBD>Ϸ<EFBFBD> <20><>",
'aboutOneHour' => "<EFBFBD><EFBFBD> <20>ð<EFBFBD> <20><>",
'aboutOneMonth' => "<EFBFBD><EFBFBD> <20><> <20><>",
'aboutOneYear' => "1<EFBFBD><EFBFBD> <20><>",
'days' => "%s<><73> <20><>",
'hours' => "%s<>ð<EFBFBD> <20><>",
'lessThanAMinute' => "<EFBFBD><EFBFBD><EFBFBD><EFBFBD>",
'lessThanOneHour' => "%s<><73> <20><>",
'months' => "%s<><73> <20><>",
'oneMinute' => "1<EFBFBD><EFBFBD> <20><>",
'years' => "%s<><73> <20><>"
);

View File

@@ -0,0 +1,15 @@
<?php
$timeAgoStrings = array(
'aboutOneDay' => "1 dag geleden",
'aboutOneHour' => "ongeveer 1 uur geleden",
'aboutOneMonth' => "ongeveer 1 maand geleden",
'aboutOneYear' => "ongeveer 1 jaar geleden",
'days' => "%s dagen geleden",
'hours' => "%s uur geleden",
'lessThanAMinute' => "minder dan een minuut geleden",
'lessThanOneHour' => "%s minuten geleden",
'months' => "%s maanden geleden",
'oneMinute' => "1 minuut geleden",
'years' => "meer dan %s jaar geleden"
);

View File

@@ -0,0 +1,15 @@
<?php
$timeAgoStrings = array(
'aboutOneDay' => "1 dia atrás",
'aboutOneHour' => "cerca de 1 hora atrás",
'aboutOneMonth' => "cerca de 1 mês atrás",
'aboutOneYear' => "cerca de 1 ano atrás",
'days' => "%s dias atrás",
'hours' => "%s horas atrás",
'lessThanAMinute' => "menos de um minuto atras",
'lessThanOneHour' => "%s minutos atrás",
'months' => "%s meses atrás",
'oneMinute' => "1 minuto atrás",
'years' => "mais de %s anos atrás"
);

View File

@@ -0,0 +1,15 @@
<?php
$timeAgoStrings = array(
'aboutOneDay' => "вчера",
'aboutOneHour' => "час назад",
'aboutOneMonth' => "около месяца назад",
'aboutOneYear' => "год назад",
'days' => "%s дней назад",
'hours' => "%s часов назад",
'lessThanAMinute' => "меньше минуты",
'lessThanOneHour' => "%s минут назад",
'months' => "%s месяцев назад",
'oneMinute' => "минуту назад",
'years' => "больше %s лет назад"
);

View File

@@ -0,0 +1,16 @@
<?php
$timeAgoStrings = array(
'aboutOneDay' => "1 วันที่แล้ว",
'aboutOneHour' => "ประมาณ 1 ชั่วโมงที่แล้ว",
'aboutOneMonth' => "ประมาณ 1 เดือนที่แล้ว",
'aboutOneYear' => "ประมาณ 1 ปีที่แล้ว",
'days' => "%s วันที่แล้ว",
'hours' => "%s ชั่วโมงที่แล้ว",
'lessThanAMinute' => "ไม่กี่นาทีที่แล้ว",
'lessThanOneHour' => "%s นาทีที่แล้ว",
'months' => "%s เดือนที่แล้ว",
'oneMinute' => "1 นาทีที่แล้ว",
'years' => "เกิน %s ปีแล้ว",
'never' => 'ไม่มีข้อมูล'
);

View File

@@ -0,0 +1,15 @@
<?php
$timeAgoStrings = array(
'aboutOneDay' => "1 gün önce",
'aboutOneHour' => "1 saat önce",
'aboutOneMonth' => "1 ay önce",
'aboutOneYear' => "1 yıl önce",
'days' => "%s gün önce",
'hours' => "%s saat önce",
'lessThanAMinute' => "biraz önce",
'lessThanOneHour' => "%s dakika önce",
'months' => "%s ay önce",
'oneMinute' => "1 dakika önce",
'years' => "%s yıldan fazla..."
);

View File

@@ -0,0 +1,15 @@
<?php
$timeAgoStrings = array(
'aboutOneDay' => "вчора",
'aboutOneHour' => "годину тому",
'aboutOneMonth' => "близько одного місяця",
'aboutOneYear' => "рік тому",
'days' => "%s днів тому",
'hours' => "%s годин тому",
'lessThanAMinute' => "менше хвилини",
'lessThanOneHour' => "%s хвилин тому",
'months' => "%s місяців тому",
'oneMinute' => "хвилину тому",
'years' => "більше %s років тому"
);

View File

@@ -0,0 +1,15 @@
<?php
$timeAgoStrings = array(
'aboutOneDay' => "1 天前",
'aboutOneHour' => "大约 1 小时前",
'aboutOneMonth' => "大约 1 个月前",
'aboutOneYear' => "大约 1 年前",
'days' => "%s 天前",
'hours' => "%s 小时前",
'lessThanAMinute' => "1 分钟内",
'lessThanOneHour' => "%s 分钟前",
'months' => "%s 个月前",
'oneMinute' => "1 分钟前",
'years' => "超过 %s 年前"
);

View File

@@ -0,0 +1,15 @@
<?php
$timeAgoStrings = array(
'aboutOneDay' => "1天前",
'aboutOneHour' => "大約1小時前",
'aboutOneMonth' => "大約1個月前",
'aboutOneYear' => "大約1年前",
'days' => "%s天前",
'hours' => "%s小時前",
'lessThanAMinute' => "1分鐘內",
'lessThanOneHour' => "%s分鐘前",
'months' => "%s個月前",
'oneMinute' => "1分鐘前",
'years' => "超過%s年前"
);

View File

@@ -0,0 +1,231 @@
<?php
/**
* NOTE: This class is no longer maintained as of version 0.2.0.
* You should use the timeAgoInWords("date") convenience method instead.
*
* A specialization of the DateTime class, that can print out,
* "how long ago" it was.
*
* @author jimmiw
* @since 2009-09-28
* @site http://github.com/jimmiw/php-time-ago
*/
class WWDateTime extends DateTime {
/**
*
*/
public function __construct(/*string*/ $time = "now",
DateTimeZone $timezone = NULL) {
// if the $timezone is null, we take 'Europe/London' as the default
// this was done, because the parent construct tossed an exception
if($timezone == NULL) {
$timezone = new DateTimeZone('Europe/London');
}
// initializes the parant
parent::__construct($time, $timezone);
}
/**
* Returns how long time ago this date object is, in words.
* E.g. current date could be "2009-01-02" and this object could hold
* "2009-01-01", then this function would return "1 day".
*
* @return the number of time ago, in words (e.g. 2 days).
*/
public function timeAgoInWords() {
$timeAgoInWords = NULL;
$yearDiff = 0;
$monthDiff = 0;
$dayDiff = 0;
$hourDiff = 0;
$minuteDiff = 0;
$secondDiff = 0;
$now = new DateTime("now", $this->getTimezone());
// tests the years
$yearDiff = $this->findDiff($now, $this, 'Y');
if($yearDiff == 1) {
$timeAgoInWords = $this->constructTimeAgoWord(
$yearDiff,
'year',
1,
'about'
);
}
else if($yearDiff >= 2) {
$timeAgoInWords = $this->constructTimeAgoWord(
$yearDiff,
'year',
1,
'over'
);
}
// tests the months
if($timeAgoInWords == NULL) {
$timeAgoInWords = $this->constructTimeAgoWord(
$this->findDiff($now, $this, 'n'),
'month',
1,
'about'
);
}
// tests the days
if($timeAgoInWords == NULL) {
$timeAgoInWords = $this->constructTimeAgoWord(
$this->findDiff($now, $this, 'j'),
'day',
1
);
}
// tests the hours
if($timeAgoInWords == NULL) {
$timeAgoInWords = $this->constructTimeAgoWord(
$this->findDiff($now, $this, 'G'),
'hour',
1,
'about'
);
}
// tests the minutes
if($timeAgoInWords == NULL) {
$minuteDiff = $this->findDiff($now, $this, 'i');
// if under 44 mins!
if($minuteDiff <= 44) {
$timeAgoInWords = $this->constructTimeAgoWord(
$minuteDiff,
'minute',
1
);
}
// else it's about an hour
else {
$timeAgoInWords = $this->constructTimeAgoWord(
1,
'hour',
1,
'about'
);
}
}
// tests the seconds
if($timeAgoInWords == NULL) {
$secondDiff = $this->findDiff($now, $this, 's');
// if under 29 secs
if($secondDiff <= 29) {
$timeAgoInWords = "less than a minute";
}
// else it's a minute!
else {
$timeAgoInWords = $this->constructTimeAgoWord(
1,
'minute'
);
}
}
return $timeAgoInWords;
}
/**
* Finds the difference in the two DateTime objects, using the given format.
* @param from
* @param to
* @param format
* @return the difference in the two DateTime objects
*/
private function findDiff(DateTime $from = NULL,
DateTime $to = NULL,
$format = NULL) {
return $from->format($format) - $to->format($format);
}
/**
* Constructs the actual "time ago"-word
* @param timeDifference
* @param timeName
* @param decidingTimeDifference
* @param prefix
* @param postfix
* @return the "time ago"-word generated
*/
private function constructTimeAgoWord($timeDiffrence = 0,
$timeName = NULL,
$decidingTimeDifference = 1,
$prefix = NULL,
$postfix = NULL) {
// initializes the timeAgoInWord placeholder
$timeAgoInWords = NULL;
if($timeDiffrence > 0) {
// sets the difference
$timeAgoInWords = $timeDiffrence . " ";
// adds the "prefix word", if any
if($prefix != NULL) {
// blindly adds a space between the words
$timeAgoInWords = $prefix . " " . $timeAgoInWords;
}
// tests if we are to pluralize the time name or not
if($timeDiffrence > $decidingTimeDifference) {
$timeAgoInWords .= $this->pluralize($timeName);
}
else {
$timeAgoInWords .= $timeName;
}
// adds the "postfix word", if any
if($postfix != NULL) {
// blindly adds a space between the words
$timeAgoInWords .= " " . $postfix;
}
}
// returns the "time ago in words" found, else NULL
return $timeAgoInWords;
}
/**
* Pluralizes the given word (only if it's in my list ofc!)
* @param $word the word to pluralize
* @return the pluralized word, if possible.
*/
private function pluralize($word = NULL) {
$pluralizedWord = $word;
if($word == 'year') {
$pluralizedWord = 'years';
}
else if($word == 'month') {
$pluralizedWord = 'months';
}
else if($word == 'day') {
$pluralizedWord = 'days';
}
else if($word == 'hour') {
$pluralizedWord = 'hours';
}
else if($word == 'minute') {
$pluralizedWord = 'minutes';
}
else if($word == 'second') {
$pluralizedWord = 'seconds';
}
return $pluralizedWord;
}
}
?>