[翻译] NSDate-TimeAgo

简介:

NSDate-TimeAgo

https://github.com/kevinlawler/NSDate-TimeAgo

 

NSDate+TimeAgo has merged with DateTools. DateTools is the parent project and Matthew York is the project head.

NSDate+TimeAgo是一个处理日期用的工具,他是Matthew York项目中的一部分.

 

This project is now part of DateTools. Please visit https://github.com/MatthewYork/DateTools

你可以在 https://github.com/MatthewYork/DateTools 中查看相关信息.

 

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 NSDate. It gives NSDate the ability to report times like "A moment ago""30 seconds ago""5 minutes ago""Yesterday""Last month""2 years ago", and so on.

这是用于苹果开发中的关于NSDate的category.你可以这么用"A moment ago""30 seconds ago""5 minutes ago""Yesterday""Last month""2 years ago"

 

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"特性

 

NSDate+TimeAgo 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)

If you know a language not listed here, please consider submitting a translation. Localization codes by language.

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

 

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

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

 

Use

  1. Add the files to your project - manually or via Cocoapods (pod 'NSDate+TimeAgo') 你可以直接拖源码,或者是使用Cocoapods
  2. Import the header using #import "NSDate+TimeAgo.h" 然后倒入头文件
  3. Call the timeAgo method in the following way: 调用
NSDate *date = [[NSDate alloc] initWithTimeIntervalSince1970:0];
NSString *ago = [date timeAgo];
NSLog(@"Output is: \"%@\"", ago);
2011-11-12 17:19:25.608 Proj[0:0] Output is: "41 years ago"

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

  • dateTimeAgo: returns times with only strings of the type: "{value} {unit} ago"
  • dateTimeUntilNow: returns only "yesterday" / "this morning" / "last week" / "this month" -- less precise than dateTimeAgo but more natural

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

 

Future Directions

Would be nice to

  1. add customization options (e.g., should it report seconds or just "a minute ago") 添加定制选项
  2. add string customization 添加string的定制
  3. have more localizations 更多的本地化语言
  4. make dateTimeUntilNow more precise: instead of "Last week" use "Last Friday", "Last Monday" etc.
  5. other

 

License

Released under ISC (similar to 2-clause BSD)

http://wikipedia.org/wiki/ISC_license

 

Credits

Originally based on code Christopher Pickslay posted to Forrst. Used with permission.http://twitter.com/cpickslay

Ramon Torres began support for internationalization/localization. Added es strings. http://rtorres.me/

Dennis Zhuang added zh_Hans Chinese Simplified strings. http://fnil.net/

Mozart Petter added pt_BR Brazilian Portuguese strings. http://www.mozartpetter.com/

Stéphane Gerardot added fr French strings.

Marco Sanson added it Italian strings. http://marcosanson.tumblr.com/

Almas Adilbek added ru Russian strings. Extended logic to support Russian idioms.http://mixdesign.kz/

Mallox51 added de German strings. https://github.com/Mallox51

Tieme van Veen added nl Dutch strings. http://www.tiemevanveen.nl

Árpád Goretity added hu Hungarian strings. http://apaczai.elte.hu/~13akga/

Anajavi added fi Finnish strings. https://github.com/anajavi

Tonydyb added ja Japanese strings.

Vinhnx added vi Vietnamese strings. http://vinhnx.github.io/

Ronail added zh_Hant Traditional Chinese strings. https://github.com/ronail

SorinAntohi added ro Romanian strings. https://github.com/SorinAntohi

spookd added da Danish strings. https://github.com/spookd

Barrett Jacobsen added cs Czech strings. https://github.com/barrettj

Dmitry Shmidt added nb Norwegian strings. https://github.com/shmidt

Martins Rudens added lv Latvian strings. https://github.com/rudensm

Osman Saral added tr Turkish strings. https://github.com/osrl

analogstyle added ko Korean strings. http://almacreative.net/

Flavio Caetano fixed pt Portuguese strings. http://flaviocaetano.com

kolarski added bg Bulgarian strings. http://github.com/kolarski

Vladimir Kofman added he Hebrew strings. https://github.com/vladimirkofman

Viraf Sarkari added ar Arabic, gre Greek, pl Polish, sv Swedish, and th Thai strings.https://github.com/viraf

Vasyl Skrypii added uk Ukranian strings. https://github.com/medlay

Maggi Trymbill added is Icelandic strings. https://github.com/grundvollur

Erid Bardhaj added sq Albanian strings. https://github.com/eridbardhaj

目录
相关文章
|
9月前
|
JSON 搜索推荐 API
Lazada Item_review API接口的开发应用与收益
Lazada作为东南亚领先的电商平台,通过其丰富的API接口为第三方开发者提供了强大的工具。其中,Lazada商品评论列表API(item_review API)尤为重要,能够实时获取商品评论数据,帮助开发者了解用户反馈、优化商品策略、提高购物体验和建立品牌形象,从而在电商行业中实现显著的收益。本文将深入探讨该API的开发应用及其多方面的价值。
156 14
|
5月前
|
SQL 缓存 分布式计算
2025年5大主流报表工具,哪款最适合你?
在中国企业的信息化建设中,报表是数据展示和业务决策的重要工具。然而,由于中国企业的特殊业务需求(如多层表头、复杂交叉报表、多源分片、动态扩展等),传统的国际报表工具往往难以满足需求。催生了专门针对中国式复杂报表的解决方案。下面带着大家一起看看2025年5大主流报表工具。
|
11月前
|
Java 测试技术 数据安全/隐私保护
🚀Java零基础-continue语句详解
【10月更文挑战第3天】本文收录于「滚雪球学Java」专栏,专业攻坚指数级提升,希望能够助你一臂之力,帮你早日登顶实现财富自由🚀;同时,欢迎大家关注&&收藏&&订阅!持续更新中,up!up!up!!
415 4
|
存储 缓存 NoSQL
Redis 7.0如何优化缓存命中率?
优化Redis缓存命中率的关键策略包括:合理设计键值结构以节省内存并提高查找效率,如使用哈希表存储共享前缀的键;采用LRU算法淘汰不常用键,保持热门数据;优化查询模式,避免大键与大量小键,使用`SCAN`代替`KEYS`减少负载;为临时数据设置过期时间自动清理;监控性能并适时调整策略;利用不同数据类型的优势;使用Pipeline减少网络延迟;限制键扫描范围;优化Lua脚本执行效率;以及根据应用场景合理配置Redis参数。这些方法有助于提升Redis性能和缓存效率。
352 1
|
Go
Golang语言之数组(array)快速入门篇
这篇文章是关于Go语言中数组的详细教程,包括数组的定义、遍历、注意事项、多维数组的使用以及相关练习题。
269 5
|
SQL 数据处理 数据库
|
消息中间件 Cloud Native 关系型数据库
定了!阿里云亮相 2024 KubeCon China,8月20-23日香港见
阿里云亮相 2024 KubeCon China,8月20-23日香港见
|
关系型数据库 分布式数据库 数据库
PolarDB产品使用问题之是否支持分库分表创建数据库
PolarDB产品使用合集涵盖了从创建与管理、数据管理、性能优化与诊断、安全与合规到生态与集成、运维与支持等全方位的功能和服务,旨在帮助企业轻松构建高可用、高性能且易于管理的数据库环境,满足不同业务场景的需求。用户可以通过阿里云控制台、API、SDK等方式便捷地使用这些功能,实现数据库的高效运维与持续优化。
|
前端开发
LayUi+SpringBoot+Mybatis:打造高效增删改查分页系统
LayUi+SpringBoot+Mybatis:打造高效增删改查分页系统
355 0
|
Java
小程序中base64解码/编码
很多人都在为小程序如何实现base64编码/解码困扰,于是我参考前端大佬们对JavaScript中实现base64的文章进行了改写。简单实现了一个。。希望能帮助到小程序开发一线的大家吧、 不多说直接上代码: /** * UTF16和UTF8转换对照表 * U+00000000 – U+000000...
5145 13