nikopol / relatime.js

display dates in a relative form and auto-update them

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

relatime.js 0.2
===============

display dates in a relative form and automatically update them every minutes.

methods:

setup(opt)      setup relatime parameters :
                  opt.locale     see locale(lang) below
                  opt.tag        (by default "time")
                  opt.classname  tag.classname (by default "relatime")
                  opt.refresh    auto-updates interval in seconds (by default 60)
                  

locale('fr')    force locale. by default navigator language or en.
                actually en/fr/de/es are supported.

locale()        return the current locale.

start()         start the auto-update of displayed dates.
                by default auto-updates are automatically started
                when html(date) is called.

start(opt)      same shit but with setup option provided.

stop()          stop the auto-update of displayed dates.

started()       return true if auto-update is started.

text(date)      return a relative representation of date
                date can be a string or a Date object.
                eg: "one hour ago"

html(date)      return a relative representation of date
                embedded in an auto-updated time tag.
                date can be a string or a Date object.
                eg: "<time class="relatime" datetime="2013-11-14T13:24:43.310Z"
                      title="11/14/2013, 2:24:43 PM">one hour ago</time>"

look at test.html to have some sample usages.

About

display dates in a relative form and auto-update them


Languages

Language:JavaScript 100.0%