{"record":{"id":"97e5bee708b0a43b","repo":"ruby/ruby","slug":"no-time-information-in-date-inspect","errorCode":null,"errorMessage":"no time information in #{date.inspect}","messagePattern":"no time information in #(.+?)","errorType":"exception","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"lib/time.rb","lineNumber":203,"sourceCode":"        if off != 0 then\n          day -= off\n          if day < 1\n            mon -= 1\n            if mon < 1\n              year -= 1\n              mon = 12\n            end\n            day = month_days(year, mon)\n          end\n        end\n      end\n      return year, mon, day, hour, min, sec\n    end\n    private :apply_offset\n\n    def make_time(date, year, yday, mon, day, hour, min, sec, sec_fraction, zone, now)\n      if !year && !yday && !mon && !day && !hour && !min && !sec && !sec_fraction\n        raise ArgumentError, \"no time information in #{date.inspect}\"\n      end\n\n      off = nil\n      if year || now\n        off_year = year || now.year\n        off = zone_offset(zone, off_year) if zone\n      end\n\n      if yday\n        unless (1..366) === yday\n          raise ArgumentError, \"yday #{yday} out of range\"\n        end\n        mon, day = (yday-1).divmod(31)\n        mon += 1\n        day += 1\n        t = make_time(date, year, nil, mon, day, hour, min, sec, sec_fraction, zone, now)\n        diff = yday - t.yday\n        return t if diff.zero?","sourceCodeStart":185,"sourceCodeEnd":221,"githubUrl":"https://github.com/ruby/ruby/blob/0e5b888e1c355f3f728f2659f085820937dada48/lib/time.rb#L185-L221","documentation":"Time.parse feeds the string to Date._parse and passes the fragments to make_time. If every temporal component is nil (no year, yday, mon, day, hour, min, sec, or sec_fraction was recognized), it cannot construct any Time and raises ArgumentError 'no time information in <string.inspect>'. A string yielding only a zone name is not enough.","triggerScenarios":"Time.parse(\"\"); Time.parse(\"hello world\"); Time.parse(\"UTC\") (zone only); Time.parse(nil) goes through a different coercion; parsing a free-text field that happens to contain no recognizable date.","commonSituations":"Log lines whose date sits on a previous line; optional config/env fields that are blank; scraping where the selector grabbed the wrong element; user-entered notes fed into Time.parse.","solutions":["Pre-check recognition: Date._parse(str) and require a real component (e.g. :year, :mday, or :hour) before calling Time.parse","Rescue ArgumentError and use a fallback (nil or Time.now) with a targeted rescue, not a blanket one","Use a strict format when you control the input: Time.strptime(str, '%Y-%m-%d %H:%M:%S')","Fix the upstream extraction so the date substring actually reaches the parser"],"exampleFix":"# before\nts = Time.parse(line)              # free-text line with no date -> raises\n\n# after\nfrag = Date._parse(line)\nts = (frag[:year] || frag[:mday] || frag[:hour]) ? Time.parse(line) : nil","handlingStrategy":"validation","validationCode":"frag = Date._parse(candidate)\nhas_time = frag.slice(:year, :mday, :hour, :min, :sec).any? { |_, v| v }\nts = has_time ? Time.parse(candidate) : nil","typeGuard":null,"tryCatchPattern":"begin\n  Time.parse(candidate)\nrescue ArgumentError\n  nil  # or fallback_time\nend","preventionTips":["Require 'time' and pre-screen free text with Date._parse","Use strptime with an explicit format for machine-generated input","Blank-string inputs are not dates: validate presence first"],"tags":["ruby","time","parsing","date-parsing"],"backgroundTag":"unparseable-date-string","analyzedSha":"0e5b888e1c355f3f728f2659f085820937dada48","analyzedAt":"2026-08-21T14:25:43.473Z","schemaVersion":2},"datasetVersion":"2026-08-21T18:17:14.833Z"}