jeremyw/stamp — pull request #14 by gurgeous (2012-12-04 18:38:51+00:00)
Title: simple timezone support

I took a stab at timezone support. It's pretty simple right now, and the regex only includes a few common timezone abbreviations. Feel free to edit.

I thought about adding support for +0900 as well, but I'd have to replicate your "before, time_example, after" logic in translate. You might want to try a parsing approach that make it easy to pull stuff out that crosses word boundaries (12:34, +0900, etc.) This isn't done but here's some example code:

```ruby
def translate(example)
substitutions = []

# replace the example time string with tokens while we parse
example = example.gsub(TIME_REGEXP) do |time_parts|
time_parts = $~.captures
substitutions << strftime_directives(time_parts) do |token, previous_part|
strftime_time_directive(token, previous_part)
end
"stamp_#{substitutions.length-1}"
end

# transform any date tokens to strftime directives
words = strftime_directives(example.split(/\b/)) do |token, previous_part|
strftime_date_directive(token, previous_part)
end
words = words.join

# now handle substitution tokens
words = words.gsub(/stamp_(\d+)/) do |sub_token|
substitutions[sub_token.to_i].join
end
end
```

Thanks for creating such a great gem!