<commit_before># human_date

`human_date` allows you to display times and dates in a human format.

```ruby
date = Date.current # 2012-08-28

human_date(date) # Today
human_date(time + 1.day) # Tomorrow
human_date(time - 1.day) # Yesterday
human_date(time - 2.days) # Aug 26
human_date(time - 1.year) # Aug 28, 2011

# it works with times, too

time = Time.now # 2012-08-28 17:20:54

human_time(time) # 5:20 pm
human_time(time - 1.day) # Yesterday
# ...
```

`human_date` provides you with 5 states for your Time/Date objects:

- `today` displays `Today` for Date and time for Time (`5:20 pm`)

- `tomorrow` displays: `Tomorrow`

- `yesterday` displays: `Yesterday`

- `current_year` displays the month and the day: `Aug 26`

- `other_year` displays the month, the day and the year: `Aug 28, 2011`

The default values can be overwriten in the locale file. See the I18n section for details.

## Installation

Add this line to your application's Gemfile:

    gem 'human_date'

And then execute:

    $ bundle

Or install it yourself as:

    $ gem install human_date

## Usage

- `human_date` for human dates

- `human_time` for human times

- `human_time_tag` generates HTML5 `<time>` tag

### Date examples
```ruby
date = Date.current
# 2012-08-28

human_date(date)
# Today

human_time_tag(date)
# <time datetime="2012-08-28">Today</time><commit_msg>Fix another typo in README<commit_after># human_date

`human_date` allows you to display times and dates in a human format.

```ruby
date = Date.current # 2012-08-28

human_date(date) # Today
human_date(date + 1.day) # Tomorrow
human_date(date - 1.day) # Yesterday
human_date(date - 2.days) # Aug 26
human_date(date - 1.year) # Aug 28, 2011

# it works with times, too

time = Time.now # 2012-08-28 17:20:54

human_time(time) # 5:20 pm
human_time(time - 1.day) # Yesterday
# ...
```

`human_date` provides you with 5 states for your Time/Date objects:

- `today` displays `Today` for Date and time for Time (`5:20 pm`)

- `tomorrow` displays: `Tomorrow`

- `yesterday` displays: `Yesterday`

- `current_year` displays the month and the day: `Aug 26`

- `other_year` displays the month, the day and the year: `Aug 28, 2011`

The default values can be overwriten in the locale file. See the I18n section for details.

## Installation

Add this line to your application's Gemfile:

    gem 'human_date'

And then execute:

    $ bundle

Or install it yourself as:

    $ gem install human_date

## Usage

- `human_date` for dates

- `human_time` for times

- `human_time_tag` generates HTML5 `<time>` tag

### Date examples
```ruby
date = Date.current
# 2012-08-28

human_date(date)
# Today

human_time_tag(date)
# <time datetime="2012-08-28">Today</time>
{'fraction_non_alphanumeric': 0.11690714021457639, 'fraction_numerical': 0.051054384017758046, 'mean_word_length': 3.943327239488117, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4163802', 'n_tokens_mistral': 1064, 'n_tokens_neox': 923, 'n_words': 323}