天天看点

[翻译] NSDate-TimeAgo

nsdate-timeago

[翻译] NSDate-TimeAgo

<a href="https://github.com/kevinlawler/nsdate-timeago" target="_blank">https://github.com/kevinlawler/nsdate-timeago</a>

nsdate+timeago has merged with datetools. datetools is the parent project and matthew york is the project head.

nsdate+timeago是一个处理日期用的工具,他是matthew york项目中的一部分.

this repo is here in archive form. new work should be contributed to datetools.

这个资源只是一个存档的形式.我们只会在new work里面更新关于这个资源的信息.

description

this is an ios, objective-c, cocoa touch, iphone, ipad category for <code>nsdate</code>. it gives <code>nsdate</code> the ability to report times like <code>"a moment ago"</code>, <code>"30 seconds ago"</code>, <code>"5 minutes ago"</code>, <code>"yesterday"</code>, <code>"last month"</code>, <code>"2 years ago"</code>, and so on.

这是用于苹果开发中的关于nsdate的category.你可以这么用<code>"a moment ago"</code>, <code>"30 seconds ago"</code>, <code>"5 minutes ago"</code>, <code>"yesterday"</code>, <code>"last month"</code>, <code>"2 years ago"</code>

this functionality has variously been referred to as a "time ago", "time since", "relative date", or "fuzzy date" feature.

当然也支持这些"time ago", "time since", "relative date", or "fuzzy date"特性

<code>nsdate+timeago</code> currently supports the following languages:

目前,他支持以下这些语言:

en (english)

es (spanish)

zh_hans (chinese simplified)

zh_hant (chinese traditional)

pt (portuguese)

fr (french)

it (italian)

ru (russian)

de (german)

nl (dutch)

hu (hungarian)

fi (finnish)

ja (japanese)

vi (vietnamese)

ro (romanian)

da (danish)

cs (czech)

nb (norwegian)

lv (latvian)

tr (turkish)

ko (korean)

bg (bulgarian)

he (hebrew)

ar (arabic)

gre (greek)

pl (polish)

sv (swedish)

th (thai)

uk (ukrainian)

is (icelandic)

sq (albanian)

sk (slovak)

如果你的母语不在这份列表中,你可以可以提供一份翻译的列表.

this project is user driven (by people like you). pull requests close faster than issues (merged or rejected).

这份源码需要我们一起来维护,如果你喜欢,贡献你的一份力量吧.

use

<code>add</code> the files to your project - manually or via cocoapods (<code>pod 'nsdate+timeago'</code>) 你可以直接拖源码,或者是使用cocoapods

import the header using <code>#import "nsdate+timeago.h" 然后倒入头文件</code>

call the <code>timeago</code> method in the following way: 调用

2 other methods are available: 当然也支持这些方法

<code>datetimeago</code>: returns times with only strings of the type: "{value} {unit} ago"

<code>datetimeuntilnow</code>: returns only "yesterday" / "this morning" / "last week" / "this month" -- less precise than <code>datetimeago</code> but more natural

those three methods can be interchanged as they have the same signature.

future directions

would be nice to

add customization options (e.g., should it report seconds or just "a minute ago") 添加定制选项

add string customization 添加string的定制

have more localizations 更多的本地化语言

make <code>datetimeuntilnow</code> more precise: instead of "last week" use "last friday", "last monday" etc.

other

license

released under isc (similar to 2-clause bsd)

<a href="http://wikipedia.org/wiki/isc_license">http://wikipedia.org/wiki/isc_license</a>

credits

stéphane gerardot added <code>fr</code> french strings.

tonydyb added <code>ja</code> japanese strings.