RIOFuzzyTime
文件大小: unknow
源码售价: 5 个金币 积分规则     积分充值
资源说明:Calculates the time since/to a given NSDate. E.g. About 30 minutes ago, About a day ago or About 2 months from now.
About RIOFuzzyTime
==================

Calculates the time since/to a given NSDate. E.g. `About 30 minutes ago`, `About a day ago` or `About 2 months from now`.

The goal for this library is to support multiple languages. As of today it only supports English and Norwegian. If you want to contribute to the translations or the code, please feel free to contact me.


Installation
============

These steps are targeted for Xcode 4, but they may also work for earlier versions.


### 1 - Getting the library

1. Open Terminal.app
2. Navigate to your project's root folder (where the .xcodeproj-file is located)
3. Type `git init` (Skip this step if you opted for: Create local git repository for this project)
4. Type `git submodule add git://github.com/skohorn/RIOFuzzyTime.git Components/RIOFuzzyTime`
5. Type `git submodule update --init --recursive`


### 2 - Adding the library to Xcode

1. Drag the _RIOFuzzyTime.xcodeproj_ into your Xcode-project (either as a sub-project or as a new workspace)
2. Open the Build Settings in your project's settings
3. Add `-all_load` to the Other Linker Flags-setting
4. Add `Components` and enable Recursive in the User Header Search Paths-setting
5. Open the Build Phases in your project's settings
6. Add _RIOFuzzyTime.a_ in the Link Binary With Libraries-section
7. Add _RIOFuzzyTime.bundle_ in the Copy Bundle Resources-section


---


If you want a better explanation of each step, please check out [The state of iOS Open Source - and what to do about it!](http://blog.jayway.com/2011/05/16/the-state-of-ios-open-source-and-what-to-do-about-it/) from the awesome [Jayway Team Blog](http://blog.jayway.com/).


Examples of Usage
=================

Remember to import _RIOFuzzyTime.h_ before using any of these methods.


### NSDate category method

```obj-c
NSDate *now = [NSDate date];
NSLog(@"Fuzzy time: %@", [now fuzzyTimeString]);
```

Outputs:

```
Fuzzy time: Just now
```


### RIOFuzzyTime static method

```obj-c
NSLog(@"Fuzzy time: %@", [RIOFuzzyTime fuzzyTimeStringWithTimeInterval:-1234.0]);
```

Outputs:

```
Fuzzy time: About 20 minutes ago
```


Specification
=============

Time Singular form Limit Scale
0-59 seconds Just now 60 1
1-59 minutes About a minute ago 60*60 60
1-23 hours About an hour ago 60*60*24 60*60
1-6 days About a day ago 60*60*24*7 60*60*24
1-4 weeks About a week ago 60*60*24*365,25/12 60*60*24*7
1-11 months About a month ago 60*60*24*365,25 60*60*24*365,25/12
1-99 years About a year ago 60*60*24*365,25*100 60*60*24*365,25
It is important that the limit of one category is higher than or equal to the scale of the next category. For example: In 1 month there are approximately 30.4375 days (2629800 seconds). In 4 weeks there are only 28 days (2419200 seconds). To accommodate this I have set the limit for the week category to about 4.35 weeks == 1 month (2629800 seconds). Otherwise, an input of 29 days would have returned 0 months. License ======= This library is licensed under the Apache 2.0 license. See LICENSE for more details.

本源码包内暂不包含可直接显示的源代码文件,请下载源码包。