# File lib/fpm/package/gem.rb, line 303
  def detect_source_date_from_changelog(installdir)
    name = self.name.sub("rubygem-", "") + "-" + self.version
    changelog = nil
    datestr = nil
    r1 = Regexp.new(P_RE_VERSION_DATE)
    r2 = Regexp.new(P_RE_DATE_VERSION)

    # Changelog doesn't have a standard name, so check all common variations
    # Sort this list using LANG=C, i.e. caps first
    [
      "CHANGELIST",
      "CHANGELOG", "CHANGELOG.asciidoc", "CHANGELOG.md", "CHANGELOG.rdoc", "CHANGELOG.rst", "CHANGELOG.txt",
      "CHANGES",   "CHANGES.md",   "CHANGES.txt",
      "ChangeLog", "ChangeLog.md", "ChangeLog.txt",
      "Changelog", "Changelog.md", "Changelog.txt",
      "changelog", "changelog.md", "changelog.txt",
    ].each do |changelogname|
      path = File.join(installdir, "gems", name, changelogname)
      if File.exist?(path)
        changelog = path
        File.open path do |file|
          file.each_line do |line|
            if line =~ /#{self.version}/
              [r1, r2].each do |r|
                if r.match(line)
                  datestr = $~[:date]
                  break
                end
              end
            end
          end
        end
      end
    end
    if datestr
      date = Date.parse(datestr)
      sec = date.strftime("%s")
      attributes[:source_date_epoch] = sec
      logger.debug("Gem %s has changelog date %s, setting source_date_epoch to %s" % [name, datestr, sec])
    elsif changelog
      logger.debug("Gem %s changelog %s did not have recognizable date for release %s" % [name, changelog, self.version])
    else
      logger.debug("Gem %s did not have changelog with recognized name" % [name])
      # FIXME: check rubygems.org?
    end
  end