<?xml version="1.0" encoding="UTF-8"?>
<codes type="array">
  <code>
    <code>  %a - The abbreviated weekday name (``Sun'')
  %A - The  full  weekday  name (``Sunday'')
  %b - The abbreviated month name (``Jan'')
  %B - The  full  month  name (``January'')
  %c - The preferred local date and time representation
  %d - Day of the month (01..31)
  %H - Hour of the day, 24-hour clock (00..23)
  %I - Hour of the day, 12-hour clock (01..12)
  %j - Day of the year (001..366)
  %m - Month of the year (01..12)
  %M - Minute of the hour (00..59)
  %p - Meridian indicator (``AM''  or  ``PM'')
  %S - Second of the minute (00..60)
  %U - Week  number  of the current year,
          starting with the first Sunday as the first
          day of the first week (00..53)
  %W - Week  number  of the current year,
          starting with the first Monday as the first
          day of the first week (00..53)
  %w - Day of the week (Sunday is 0, 0..6)
  %x - Preferred representation for the date alone, no time
  %X - Preferred representation for the time alone, no date
  %y - Year without a century (00..99)
  %Y - Year with century
  %Z - Time zone name
  %% - Literal ``%'' character</code>
    <created-at type="datetime">2008-11-13T00:39:39Z</created-at>
    <description>http://www.ruby-doc.org/core/classes/Time.html#M000236</description>
    <id type="integer">94</id>
    <language-id type="integer">42</language-id>
    <privated type="boolean">false</privated>
    <title>time format in ruby</title>
    <updated-at type="datetime">2008-11-13T00:39:39Z</updated-at>
    <user-id type="integer">7</user-id>
  </code>
  <code>
    <code># one method
def age
 ((Time.now - birthday)/(60*60*24)/365.2422).to_i
end

# second method
def birthday
    @birthday = Time.local( birth_year, birth_month, birth_day )
  end
  
  def age
    ((Time.now - birthday) / 1.year).to_i
  end 
</code>
    <created-at type="datetime">2008-09-19T17:59:29Z</created-at>
    <description></description>
    <id type="integer">65</id>
    <language-id type="integer">39</language-id>
    <privated type="boolean">false</privated>
    <title>age calculation</title>
    <updated-at type="datetime">2008-09-19T17:59:29Z</updated-at>
    <user-id type="integer">7</user-id>
  </code>
  <code>
    <code>require &quot;rubygems&quot;
require &quot;activesupport&quot;
require &quot;unicode&quot;

class String
  def as_time
    str = self.dup
    str.downcase!
    str.squish!
    str = Unicode.normalize_KD(self).gsub(/[^\x00-\x7F]/n,'')
    
    now = Time.now

    if str == 'hoje'
      Date.today.to_time
    elsif str == 'agora'
      Time.now
    elsif str == 'amanha'
      Date.tomorrow.to_time
    elsif str == 'ontem'
      Date.yesterday.to_time
    elsif str == 'anteontem'
      2.days.ago
    elsif str == 'depois de amanha'
      2.days.from_now
    elsif str =~ /^proxim[oa] (semana|dia|mes|ano)$/
      case $1
        when 'semana' then now.next_week
        when 'dia' then Date.tomorrow.to_time
        when 'mes' then now.next_month
        when 'ano' then now.next_year
      end
    elsif str =~ /^(mes|semana|ano) que vem/
      case $1
        when 'mes' then now.next_month
        when 'semana' then now.next_week
        when 'ano' then now.next_year
      end
    elsif str =~ /^(mes|semana|ano) passad[ao]/
      case $1
        when 'mes' then now.last_month
        when 'semana' then now.beginning_of_week
        when 'ano' then now.last_year
      end
    elsif str =~ /^de (tarde|manha|noite)/
      case $1
        when 'noite' then now.beginning_of_day + 20.hours
        when 'tarde' then now.beginning_of_day + 15.hours
        when 'manha' then now.beginning_of_day + 9.hours
      end
    elsif str =~ /^daqui h?a pouco/
      1.hour.from_now
    elsif str =~ /^daqui(?: h?a)? ([0-9]+) (dias?|mes(?:es)?|semanas?|anos?|horas?|minutos?)/
      num = $1.to_i
      interval = $2.gsub(/e?s$/, '')

      names = {
        'dia' =&gt; :day,
        'mes' =&gt; :month,
        'semana' =&gt; :week,
        'ano' =&gt; :year,
        'hora' =&gt; :hour,
        'minuto' =&gt; :minute
      }
      
      num.send(names[interval]).from_now
    end
  end
end</code>
    <created-at type="datetime">2008-07-02T00:19:29Z</created-at>
    <description></description>
    <id type="integer">9</id>
    <language-id type="integer">39</language-id>
    <privated type="boolean">false</privated>
    <title>Chronic-like in Portuguese</title>
    <updated-at type="datetime">2008-07-02T00:19:29Z</updated-at>
    <user-id type="integer">8</user-id>
  </code>
</codes>
