snipt

Ctrl+h for KB shortcuts

JavaScript

jquery.tweet.js (linea 121 a 129)

1
2
3
4
5
6
7
8
9
    function format_relative_time(time_ago) {
      if ( time_ago.days > 2 )     return 'hace ' + time_ago.days + ' días';
      if ( time_ago.hours > 24 )   return 'hace un día';
      if ( time_ago.hours > 2 )    return 'hace ' + time_ago.hours + ' horas';
      if ( time_ago.minutes > 45 ) return 'una hora atrás';
      if ( time_ago.minutes > 2 )  return 'hace ' + time_ago.minutes + ' minutos';
      if ( time_ago.seconds > 1 )  return 'hace ' + time_ago.seconds + ' segundos';
      return 'hace unos momentos';
    }
https://snipt.net/embed/7624fb6581c9f19345d4277e482ce795/
/raw/7624fb6581c9f19345d4277e482ce795/
7624fb6581c9f19345d4277e482ce795
js
JavaScript
9
2019-07-23T15:39:06
True
False
False
Oct 18, 2012 at 03:36 PM
/api/public/snipt/48770/
jquerytweetjs-linea-121-a-129
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a> <a href="#L-4">4</a> <a href="#L-5">5</a> <a href="#L-6">6</a> <a href="#L-7">7</a> <a href="#L-8">8</a> <a href="#L-9">9</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a> <span class="kd">function</span> <span class="nx">format_relative_time</span><span class="p">(</span><span class="nx">time_ago</span><span class="p">)</span> <span class="p">{</span> </span><span id="L-2"><a name="L-2"></a> <span class="k">if</span> <span class="p">(</span> <span class="nx">time_ago</span><span class="p">.</span><span class="nx">days</span> <span class="o">&gt;</span> <span class="mi">2</span> <span class="p">)</span> <span class="k">return</span> <span class="s1">&#39;hace &#39;</span> <span class="o">+</span> <span class="nx">time_ago</span><span class="p">.</span><span class="nx">days</span> <span class="o">+</span> <span class="s1">&#39; d&amp;iacute;as&#39;</span><span class="p">;</span> </span><span id="L-3"><a name="L-3"></a> <span class="k">if</span> <span class="p">(</span> <span class="nx">time_ago</span><span class="p">.</span><span class="nx">hours</span> <span class="o">&gt;</span> <span class="mi">24</span> <span class="p">)</span> <span class="k">return</span> <span class="s1">&#39;hace un d&amp;iacute;a&#39;</span><span class="p">;</span> </span><span id="L-4"><a name="L-4"></a> <span class="k">if</span> <span class="p">(</span> <span class="nx">time_ago</span><span class="p">.</span><span class="nx">hours</span> <span class="o">&gt;</span> <span class="mi">2</span> <span class="p">)</span> <span class="k">return</span> <span class="s1">&#39;hace &#39;</span> <span class="o">+</span> <span class="nx">time_ago</span><span class="p">.</span><span class="nx">hours</span> <span class="o">+</span> <span class="s1">&#39; horas&#39;</span><span class="p">;</span> </span><span id="L-5"><a name="L-5"></a> <span class="k">if</span> <span class="p">(</span> <span class="nx">time_ago</span><span class="p">.</span><span class="nx">minutes</span> <span class="o">&gt;</span> <span class="mi">45</span> <span class="p">)</span> <span class="k">return</span> <span class="s1">&#39;una hora atr&amp;aacute;s&#39;</span><span class="p">;</span> </span><span id="L-6"><a name="L-6"></a> <span class="k">if</span> <span class="p">(</span> <span class="nx">time_ago</span><span class="p">.</span><span class="nx">minutes</span> <span class="o">&gt;</span> <span class="mi">2</span> <span class="p">)</span> <span class="k">return</span> <span class="s1">&#39;hace &#39;</span> <span class="o">+</span> <span class="nx">time_ago</span><span class="p">.</span><span class="nx">minutes</span> <span class="o">+</span> <span class="s1">&#39; minutos&#39;</span><span class="p">;</span> </span><span id="L-7"><a name="L-7"></a> <span class="k">if</span> <span class="p">(</span> <span class="nx">time_ago</span><span class="p">.</span><span class="nx">seconds</span> <span class="o">&gt;</span> <span class="mi">1</span> <span class="p">)</span> <span class="k">return</span> <span class="s1">&#39;hace &#39;</span> <span class="o">+</span> <span class="nx">time_ago</span><span class="p">.</span><span class="nx">seconds</span> <span class="o">+</span> <span class="s1">&#39; segundos&#39;</span><span class="p">;</span> </span><span id="L-8"><a name="L-8"></a> <span class="k">return</span> <span class="s1">&#39;hace unos momentos&#39;</span><span class="p">;</span> </span><span id="L-9"><a name="L-9"></a> <span class="p">}</span> </span></pre></div> </td></tr></table>
jquery, plugin, tweet, twitter