Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: rmm5t/jquery-timeago
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v1.5.1
Choose a base ref
...
head repository: rmm5t/jquery-timeago
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
Loading
Showing with 2,389 additions and 1,218 deletions.
  1. BIN .DS_Store
  2. +9 −0 .github/FUNDING.yml
  3. +13 −0 .github/no-response.yml
  4. +1 −0 .gitignore
  5. +1 −1 LICENSE.txt
  6. +18 −23 README.markdown
  7. +37 −9 Rakefile
  8. +1 −1 composer.json
  9. +21 −18 index.html
  10. +13 −6 jquery.timeago.js
  11. +30 −20 locales/jquery.timeago.af.js
  12. +30 −0 locales/jquery.timeago.am.js
  13. +13 −5 locales/jquery.timeago.ar.js
  14. +30 −0 locales/jquery.timeago.az-short.js
  15. +29 −0 locales/jquery.timeago.az.js
  16. +43 −0 locales/jquery.timeago.be.js
  17. +28 −18 locales/jquery.timeago.bg.js
  18. +13 −7 locales/jquery.timeago.bs.js
  19. +30 −18 locales/jquery.timeago.ca.js
  20. +34 −24 locales/jquery.timeago.cs.js
  21. +30 −20 locales/jquery.timeago.cy.js
  22. +28 −18 locales/jquery.timeago.da.js
  23. +30 −0 locales/jquery.timeago.de-short.js
  24. +29 −18 locales/jquery.timeago.de.js
  25. +32 −22 locales/jquery.timeago.dv.js
  26. +28 −18 locales/jquery.timeago.el.js
  27. +30 −20 locales/jquery.timeago.en-short.js
  28. +30 −20 locales/jquery.timeago.en.js
  29. +30 −0 locales/jquery.timeago.eo.js
  30. +31 −20 locales/jquery.timeago.es-short.js
  31. +29 −18 locales/jquery.timeago.es.js
  32. +28 −18 locales/jquery.timeago.et.js
  33. +28 −17 locales/jquery.timeago.eu.js
  34. +30 −20 locales/jquery.timeago.fa-short.js
  35. +32 −22 locales/jquery.timeago.fa.js
  36. +38 −28 locales/jquery.timeago.fi.js
  37. +26 −16 locales/jquery.timeago.fr-short.js
  38. +27 −17 locales/jquery.timeago.fr.js
  39. +28 −18 locales/jquery.timeago.gl.js
  40. +26 −16 locales/jquery.timeago.he.js
  41. +53 −48 locales/jquery.timeago.hr.js
  42. +28 −18 locales/jquery.timeago.hu.js
  43. +28 −18 locales/jquery.timeago.hy.js
  44. +29 −18 locales/jquery.timeago.id.js
  45. +29 −19 locales/jquery.timeago.is.js
  46. +30 −20 locales/jquery.timeago.it-short.js
  47. +28 −16 locales/jquery.timeago.it.js
  48. +29 −19 locales/jquery.timeago.ja.js
  49. +28 −18 locales/jquery.timeago.jv.js
  50. +30 −0 locales/jquery.timeago.ka.js
  51. +31 −20 locales/jquery.timeago.ko.js
  52. +12 −4 locales/jquery.timeago.ky.js
  53. +30 −20 locales/jquery.timeago.lt.js
  54. +30 −20 locales/jquery.timeago.lv.js
  55. +30 −20 locales/jquery.timeago.mk.js
  56. +30 −0 locales/jquery.timeago.ne.js
  57. +30 −20 locales/jquery.timeago.nl.js
  58. +28 −18 locales/jquery.timeago.no.js
  59. +11 −3 locales/jquery.timeago.pl.js
  60. +30 −20 locales/jquery.timeago.pt-br-short.js
  61. +28 −18 locales/jquery.timeago.pt-br.js
  62. +30 −20 locales/jquery.timeago.pt-short.js
  63. +26 −16 locales/jquery.timeago.pt.js
  64. +29 −18 locales/jquery.timeago.ro.js
  65. +53 −48 locales/jquery.timeago.rs.js
  66. +14 −5 locales/jquery.timeago.ru.js
  67. +30 −20 locales/jquery.timeago.rw.js
  68. +28 −18 locales/jquery.timeago.si.js
  69. +34 −18 locales/jquery.timeago.sk.js
  70. +45 −39 locales/jquery.timeago.sl.js
  71. +26 −0 locales/jquery.timeago.sq.js
  72. +54 −0 locales/jquery.timeago.sr.js
  73. +28 −18 locales/jquery.timeago.sv.js
  74. +30 −20 locales/jquery.timeago.th.js
  75. +30 −0 locales/jquery.timeago.tr-short.js
  76. +26 −16 locales/jquery.timeago.tr.js
  77. +12 −4 locales/jquery.timeago.uk.js
  78. +30 −0 locales/jquery.timeago.ur.js
  79. +29 −19 locales/jquery.timeago.uz.js
  80. +30 −20 locales/jquery.timeago.vi.js
  81. +31 −20 locales/jquery.timeago.zh-CN.js
  82. +30 −20 locales/jquery.timeago.zh-TW.js
  83. +2 −2 package.json
  84. +81 −19 test/index.html
  85. +73 −3 test/test_helpers.js
  86. +2 −2 timeago.jquery.json
  87. BIN vendor/cache/fssm-0.2.0.gem
Binary file added .DS_Store
Binary file not shown.
9 changes: 9 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# These are supported funding model platforms

github: [rmm5t]
# patreon: # Replace with a single Patreon username
# open_collective: # Replace with a single Open Collective username
# ko_fi: # Replace with a single Ko-fi username
# tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
# community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
custom: "https://www.paypal.me/rmm5t/5"
13 changes: 13 additions & 0 deletions .github/no-response.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Configuration for probot-no-response - https://github.com/probot/no-response

# Number of days of inactivity before an Issue is closed for lack of response
daysUntilClose: 7
# Label requiring a response
responseRequiredLabel: more-information-needed
# Comment to post when closing an Issue for lack of response. Set to `false` to disable
closeComment: >
This issue has been automatically closed because there has been no response
to our request for more information from the original author. With only the
information that is currently in the issue, we don't have enough information
to take action. Please reach out if you have or find the answers we need so
that we can investigate further.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.bundle
vendor/ruby
public
node_modules/
2 changes: 1 addition & 1 deletion LICENSE.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2008-2015 Ryan McGeary
Copyright (c) 2008-2019 Ryan McGeary

MIT License

41 changes: 18 additions & 23 deletions README.markdown
Original file line number Diff line number Diff line change
@@ -1,26 +1,12 @@
# timeago: a jQuery plugin

[![NPM](https://img.shields.io/npm/v/timeago.svg)](https://www.npmjs.com/package/timeago)
[![Bower](https://img.shields.io/bower/v/jquery-timeago.svg)](http://bower.io/search/?q=jquery-timeago)

Timeago is a jQuery plugin that makes it easy to support automatically updating
fuzzy timestamps (e.g. "4 minutes ago" or "about 1 day ago") from ISO 8601
formatted dates and times embedded in your HTML (à la microformats).

---

**How You Can Help**

[![Square Cash](http://img.shields.io/badge/square%20cash-$rmm5t-brightgreen.svg)][square]
[![Gratipay](http://img.shields.io/gratipay/rmm5t.svg)][gratipay]
[![Book a Codementor session](http://img.shields.io/badge/codementor-book%20a%20session-orange.svg)][codementor]

If you like this project, [buy me a coffee][square], [donate via Gratipay][gratipay], or [book a session with me on Codementor][codementor].

Bitcoin: `1rmm5tv6f997JK5bLcGbRCZyVjZUPkQ2m`

[square]: https://cash.me/$rmm5t "Donate to rmm5t for open source!"
[gratipay]: https://gratipay.com/rmm5t/ "Donate to rmm5t for open source!"
[bitcoin]: bitcoin:1rmm5tv6f997JK5bLcGbRCZyVjZUPkQ2m?amount=0.01&label=Coffee%20to%20rmm5t%20for%20Open%20Source "Buy rmm5t a coffee for open source!"
[codementor]: https://www.codementor.io/rmm5t?utm_campaign=profile&utm_source=button-rmm5t&utm_medium=shields "Book a session with rmm5t on Codementor!"

## Usage

First, load jQuery and the plugin:
@@ -55,7 +41,7 @@ into something like this:
<time class="timeago" datetime="2011-12-17T09:24:17Z" title="December 17, 2011">about 1 day ago</time>
```

`<abbr>` elements are also supported (this is for
`<abbr>` elements (or any other HTML elements) are also supported (this is for
[legacy microformat support](http://microformats.org/wiki/datetime-design-pattern)
and was originally supported by the library before the `time` element was
introduced to HTML5):
@@ -79,10 +65,20 @@ $("time#some_id").timeago("update", new Date());

**For different language configurations**: visit the [`locales`](https://github.com/rmm5t/jquery-timeago/tree/master/locales) directory.

## Settings

**`cutoff`** : Return the original date if time distance is older than `cutoff` (miliseconds).

```javascript
// Display original dates older than 24 hours
jQuery.timeago.settings.cutoff = 1000*60*60*24;
```

## Changes

| Version | Notes |
|---------|---------------------------------------------------------------------------------|
| 1.6.x | ([compare][compare-1.6]) Wraped locales in UMD wrappers; locale improvements |
| 1.5.x | ([compare][compare-1.5]) Added Date as argument to update function; locales |
| 1.4.x | ([compare][compare-1.4]) Added allowPast setting; locale updates |
| 1.3.x | ([compare][compare-1.3]) Added updateFromDOM function; bug fixes; bower support |
@@ -96,7 +92,8 @@ $("time#some_id").timeago("update", new Date());
| 0.7.x | ([compare][compare-0.7]) locale function overrides; unit tests |
| ... | ... |

[compare-1.5]: https://github.com/rmm5t/jquery-timeago/compare/v1.4.3...v1.5.1
[compare-1.6]: https://github.com/rmm5t/jquery-timeago/compare/v1.5.4...v1.6.7
[compare-1.5]: https://github.com/rmm5t/jquery-timeago/compare/v1.4.3...v1.5.4
[compare-1.4]: https://github.com/rmm5t/jquery-timeago/compare/v1.3.2...v1.4.3
[compare-1.3]: https://github.com/rmm5t/jquery-timeago/compare/v1.2.0...v1.3.2
[compare-1.2]: https://github.com/rmm5t/jquery-timeago/compare/v1.1.0...v1.2.0
@@ -112,8 +109,6 @@ $("time#some_id").timeago("update", new Date());

[Ryan McGeary](http://ryan.mcgeary.org) ([@rmm5t](http://twitter.com/rmm5t))

## Other

[MIT License](http://www.opensource.org/licenses/mit-license.php)
## License

Copyright (c) 2008-2015, Ryan McGeary (ryan -[at]- mcgeary [*dot*] org)
[MIT License](https://rmm5t.mit-license.org/)
46 changes: 37 additions & 9 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -2,16 +2,8 @@ require "bundler/setup"

task default: :test

desc "Publish \"marketing\" docs"
task :publish_docs do
sh("git rebase master gh-pages")
sh("git checkout master")
sh("git push origin master")
sh("git push origin gh-pages")
end

desc "Publish new release"
task publish: :publish_docs do
task :publish do
sh("git push --tags")
sh("npm publish")
end
@@ -20,3 +12,39 @@ desc "Open your default browser with the test page"
task :test do
sh("open test/index.html")
end

desc "Automatically wrap given locale files in UMD declarations"
task :umd, [:files] do |t, args|
def indent(str)
indented = str.split("\n").map do |line|
" #{line}"
end
indented.join("\n")
end

def wrap_in_umd(str)
<<~HEREDOC
(function (factory) {
if (typeof define === 'function' && define.amd) {
define(['jquery'], factory);
} else if (typeof module === 'object' && typeof module.exports === 'object') {
factory(require('jquery'));
} else {
factory(jQuery);
}
}(function (jQuery) {
#{indent(str)}
}));
HEREDOC
end

matches = Dir.glob(args[:files])
puts "Pattern did not match any file" if matches.length == 0
matches.each do |file|
input = File.read(file)
base = Pathname.new(file).basename
output = File.open("locales/#{base}", "w")
output.write(wrap_in_umd(input))
output.close
end
end
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -17,7 +17,7 @@
"microformat"
],
"require": {
"components/jquery": ">=1.2.3"
"components/jquery": ">=1.5.0 <4.0"
},
"extra": {
"component": {
39 changes: 21 additions & 18 deletions index.html
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<meta name="microid" content="mailto+http:sha1:566841e568e84b46c92d2291b44b836dfddc5c42" />
<title>timeago: a jQuery plugin</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.4/jquery.min.js"></script>
<script src="jquery.timeago.js" type="text/javascript"></script>
<script src="test/test_helpers.js" type="text/javascript"></script>
<script type="text/javascript">
@@ -18,6 +18,7 @@
});

</script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/github-fork-ribbon-css/0.2.0/gh-fork-ribbon.min.css" />
<style>
* { margin: 0; padding: 0; }
body { font-family: Helvetica,Arial,sans-serif; color: #333; background-color: #ccc; font-size: 16px; line-height: 24px; }
@@ -32,16 +33,28 @@
li { line-height: 24px; }
pre { background-color: #333; color: #fff; margin: 12px 0; font-size: 12px; padding: 0 6px; }
pre em { font-style: normal; background-color: #554; }
pre, tt { font-family: monaco,"courier new",mono; }
pre, tt { font-family: monaco, "courier new", mono, monospace; }
abbr[title], time[title] { border-bottom: 1px dotted #333; }
tt { font-size: 14px; }
a { color: #06e; padding: 1px; }
em { font-style: normal; background-color: #feb }
em { font-style: normal; background-color: #feb; }
a:hover { background-color: #06c; color: #fff; text-decoration: none; }
#content { margin:0 auto; padding: 24px; width:700px; background-color:#fff; border: 1px solid #999; border-width: 0 1px 1px 1px; }
#footer { margin:0 auto 24px; padding: 12px; width:700px; line-height: 24px; }
.help { font-size: 14px; color: #888; }
.github-fork-ribbon:before { background-color: #f80; }
</style>
<!-- Google Analytics -->
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');

ga('create', 'UA-2856277-2', 'auto');
ga('send', 'pageview');
</script>
<!-- End Google Analytics -->
</head>
<body>
<div id="content">
@@ -119,7 +132,7 @@ <h3>How?</h3>
<p class="how">
To disable timestamps in the past, use the <tt>allowPast</tt> setting.
This setting is set to true by default. When set to false, if the time is in the past then instead of displaying a message like "5 minutes ago" a static message will be displayed.
The staic message displayed can be configured with the <tt>strings.inPast</tt> setting:
The static message displayed can be configured with the <tt>strings.inPast</tt> setting:
</p>
<pre>
jQuery.timeago.settings.strings.inPast = "time has elapsed";
@@ -151,12 +164,12 @@ <h3>Who?</h3>

<h3>When?</h3>
<p>
Timeago was conceived <time class="timeago" title="2008-07-17T02:30:00-0500">on July 17, 2008</time>. <span class="help">(Yup, that's powered by timeago too)</span>
Timeago was conceived <time class="timeago" datetime="2008-07-17T07:30:00-0500">on July 17, 2008</time>. <span class="help">(Yup, that's powered by timeago too)</span>
</p>

<h3>What else?</h3>
<p class="example">
The HTML5 <tt>time</tt> tag is strongly recommended, but the legacy <a href="http://microformats.org/wiki/datetime-design-pattern">datetime microformat</a> using the <tt>abbr</tt> tag is also supported:
The HTML5 <tt>time</tt> tag is strongly recommended, but the legacy <a href="http://microformats.org/wiki/datetime-design-pattern">datetime microformat</a> using the <tt>abbr</tt> tag ( or any other HTML element ) is also supported:
</p>
<pre>
&lt;abbr class=&quot;<em>timeago</em>&quot; title=&quot;<em>2008-07-17T09:24:17Z</em>&quot;&gt;July 17, 2008&lt;/abbr&gt;</pre>
@@ -202,20 +215,10 @@ <h3>Do you use Timeago?</h3>
<a href="http://www.opensource.org/licenses/mit-license.php">MIT
License</a>
</div>
Copyright &copy; 2008-2015 <a href="http://ryan.mcgeary.org">Ryan McGeary</a>
Copyright &copy; 2008-2019 <a href="http://ryan.mcgeary.org">Ryan McGeary</a>
(<a href="http://twitter.com/rmm5t">@rmm5t</a>)
</div>

<a href="http://github.com/rmm5t/jquery-timeago"><img style="position: absolute; top: 0; right: 0; border: 0;" src="http://s3.amazonaws.com/github/ribbons/forkme_right_orange_ff7600.png" alt="Fork me on GitHub" /></a>

<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
var pageTracker = _gat._getTracker("UA-2856277-2");
pageTracker._initData();
pageTracker._trackPageview();
</script>
<a class="github-fork-ribbon" href="http://github.com/rmm5t/jquery-timeago" title="Fork me on GitHub">Fork me on GitHub</a>
</body>
</html>
19 changes: 13 additions & 6 deletions jquery.timeago.js
Original file line number Diff line number Diff line change
@@ -3,15 +3,15 @@
* updating fuzzy timestamps (e.g. "4 minutes ago" or "about 1 day ago").
*
* @name timeago
* @version 1.5.1
* @requires jQuery v1.2.3+
* @version 1.6.7
* @requires jQuery >=1.5.0 <4.0
* @author Ryan McGeary
* @license MIT License - http://www.opensource.org/licenses/mit-license.php
*
* For usage and examples, visit:
* http://timeago.yarp.com/
*
* Copyright (c) 2008-2015, Ryan McGeary (ryan -[at]- mcgeary [*dot*] org)
* Copyright (c) 2008-2019, Ryan McGeary (ryan -[at]- mcgeary [*dot*] org)
*/

(function (factory) {
@@ -51,7 +51,7 @@
prefixFromNow: null,
suffixAgo: "ago",
suffixFromNow: "from now",
inPast: 'any moment now',
inPast: "any moment now",
seconds: "less than a minute",
minute: "about a minute",
minutes: "%d minutes",
@@ -140,6 +140,7 @@
// functions are called with context of a single element
var functions = {
init: function() {
functions.dispose.call(this);
var refresh_el = $.proxy(refresh, this);
refresh_el();
var $s = $t.settings;
@@ -150,7 +151,9 @@
update: function(timestamp) {
var date = (timestamp instanceof Date) ? timestamp : $t.parse(timestamp);
$(this).data('timeago', { datetime: date });
if ($t.settings.localeTitle) $(this).attr("title", date.toLocaleString());
if ($t.settings.localeTitle) {
$(this).attr("title", date.toLocaleString());
}
refresh.apply(this);
},
updateFromDOM: function() {
@@ -190,8 +193,12 @@
var data = prepareData(this);

if (!isNaN(data.datetime)) {
if ( $s.cutoff == 0 || Math.abs(distance(data.datetime)) < $s.cutoff) {
if ( $s.cutoff === 0 || Math.abs(distance(data.datetime)) < $s.cutoff) {
$(this).text(inWords(data.datetime));
} else {
if ($(this).attr('title').length > 0) {
$(this).text($(this).attr('title'));
}
}
}
return this;
50 changes: 30 additions & 20 deletions locales/jquery.timeago.af.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,30 @@
// Afrikaans
jQuery.timeago.settings.strings = {
prefixAgo: null,
prefixFromNow: null,
suffixAgo: "gelede",
suffixFromNow: "van nou af",
seconds: "%d sekondes",
minute: "1 minuut",
minutes: "%d minute",
hour: "1 uur",
hours: "%d ure",
day: "1 dag",
days: "%d dae",
month: "1 maand",
months: "%d maande",
year: "1 jaar",
years: "%d jaar",
wordSeparator: " ",
numbers: []
};
(function (factory) {
if (typeof define === 'function' && define.amd) {
define(['jquery'], factory);
} else if (typeof module === 'object' && typeof module.exports === 'object') {
factory(require('jquery'));
} else {
factory(jQuery);
}
}(function (jQuery) {
// Afrikaans
jQuery.timeago.settings.strings = {
prefixAgo: null,
prefixFromNow: null,
suffixAgo: "gelede",
suffixFromNow: "van nou af",
seconds: "%d sekondes",
minute: "1 minuut",
minutes: "%d minute",
hour: "1 uur",
hours: "%d ure",
day: "1 dag",
days: "%d dae",
month: "1 maand",
months: "%d maande",
year: "1 jaar",
years: "%d jaar",
wordSeparator: " ",
numbers: []
};
}));
Loading