def timestamp(format_string, blank = false)
      regexp = ''
      format_string.scan(/([^%]*)(?:%([A-Za-z%]))?/) do |literal, variable|
        regexp << Regexp.quote(literal)
        if variable
          if TIMESTAMP_PARTS.key?(variable)
            regexp << TIMESTAMP_PARTS[variable]
          else
            fail "Unknown variable: %#{variable}"
          end
        end
      end

      add_blank_option(Regexp.new(regexp), blank)
    end
def timestamp(format_string, blank = false)
      regexp = ''
      format_string.scan(/([^%]*)(?:%([A-Za-z%]))?/) do |literal, variable|
        regexp << Regexp.quote(literal)
        if variable
          if TIMESTAMP_PARTS.key?(variable)
            regexp << TIMESTAMP_PARTS[variable]
          else
            fail "Unknown variable: %#{variable}"
          end
        end
      end

      add_blank_option(Regexp.new(regexp), blank)
    end
Create a regular expression for a timestamp, generated by a strftime call.
 Provide the format string to construct a matching regular expression.
 Set blank to true to allow and empty string, or set blank to a string to set
 a substitute for the nil value.