Bug #15160
closedArgumentError: year too big to marshal
Description
I encountered the problem, that marshaling a Time object does not always work.
Try run following commands in irb that will raise an error:
Marshal.dump(Time.new(1900))
#Traceback (most recent call last):
# 3: from (irb):35
# 2: from (irb):35:in `dump'
# 1: from (irb):35:in `_dump'
#ArgumentError (year too big to marshal: 1899 UTC)
Marshal.dump(Time.new(1899))
#Traceback (most recent call last):
# 3: from (irb):37
# 2: from (irb):37:in `dump'
# 1: from (irb):37:in `_dump'
#ArgumentError (year too big to marshal: 1898 UTC)
Following commands will work fine:
Marshal.dump(Time.new(1901))
# => "\x04\bIu:\tTime\r\xF7/\x00\x80\x00\x00\x00\x00\a:\voffseti\x02\x10\x0E:\tzoneI\"\bCET\x06:\x06EF"
Marshal.dump(Date.new(1899))
# => "\x04\bU:\tDate[\vi\x00i\x03@\xD8$i\x00i\x00i\x00f\f2299161"
I'm in timezone CEST (UTC+2).
I tested it at MacOS High Sierra (10.13.6 (17G65)) and Ubuntu 16.04.5 LTS (GNU/Linux 4.4.0-135-generic x86_64) with two Ruby versions:
- ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-darwin17]
- ruby 2.6.0preview2 (2018-05-31 trunk 63539) [x86_64-darwin17]
I expect that all Time objects can be marshaled, even if they are prior 1900.
Updated by nobu (Nobuyoshi Nakada) about 6 years ago
- Tracker changed from Bug to Feature
- ruby -v deleted (
ruby 2.6.0preview2 (2018-05-31 trunk 63539) [x86_64-darwin17]) - Backport deleted (
2.3: UNKNOWN, 2.4: UNKNOWN, 2.5: UNKNOWN)
This is a limit of current marshal format of Time
, not a bug.
This is a patch to extend the limit, but it has a little problem on marshal data compatibility.
$ ./ruby -e 'Marshal.dump(Time.new(1900), STDOUT)'|ruby -e 'p Marshal.load(STDIN)'
67436-01-01 00:00:00 +0900
Dumped out-of-range Time
with this patch will be loaded as the distant future, when loaded in old ruby.
Updated by Dirk (Dirk Meier-Eickhoff) about 6 years ago
- Tracker changed from Feature to Bug
- Backport set to 2.3: UNKNOWN, 2.4: UNKNOWN, 2.5: UNKNOWN
Updated by nobu (Nobuyoshi Nakada) over 5 years ago
- Status changed from Open to Closed
Applied in changeset git|e690df1f1ef4f791295448f9192d6e027400ee72.
Marshal distant past/future
[Feature #15160]