Exactly what the title says. If I try to it gives me a ValueError for the year value but I'd like to have a datetime with year 0. Is there any way to do this?
Asked
Active
Viewed 1.2k times
3
-
4There is no such year as year zero, what's the problem you are trying to solve? – SingleNegationElimination Jul 17 '13 at 20:44
-
In the real world there certainly is a year such as 0. The time between when we start the calendar and the first New Years after that is year 0. Like how the 20th century represents the years starting with 1900. – avorum Jul 18 '13 at 11:21
-
1ER... actually we started the current, [Gregorian](http://en.wikipedia.org/wiki/Gregorian_calendar) calendar on the year 1582; Correctly representing dates before that will require some explanation of what you need those dates to mean. – SingleNegationElimination Jul 18 '13 at 12:03
-
The Gregorian calendar was invented during that time period but it recognizes dates starting from the year christ was born. Before that, we have BC. Is -1 right before 1? No, there has to be a 0 in there somewhere. – avorum Jul 18 '13 at 12:09
-
1"Year zero does not exist in the Anno Domini system usually used to number years in the Gregorian calendar and in its predecessor, the Julian calendar. In this system, the year 1 BC is followed by AD 1." - from [https://en.wikipedia.org/wiki/Year_zero]. Which calendar are you trying to use? what sort of date are you trying to represent. – SingleNegationElimination Jul 18 '13 at 12:20
-
1Weird, my understanding of it was incorrect then. I was always under the understanding that there was a year 0. My bad. I generally assume that number lines don't skip 0. – avorum Jul 18 '13 at 12:35
-
@IfLoop it does actually make sense to have year 0 in the Gregorian calendar. https://en.wikipedia.org/wiki/Proleptic_Gregorian_calendar – Heinrich Hartmann Jul 14 '14 at 11:43
-
I've run into the same issue when trying to convert some old Matlab timestamps (days since Jan 0, 0000)! frustrating. – David Hagan Nov 12 '15 at 14:43
2 Answers
4
from the docs
The datetime module exports the following constants:
datetime.MINYEAR The smallest year number allowed in a date or datetime object. MINYEAR is 1.
datetime.MAXYEAR The largest year number allowed in a date or datetime object. MAXYEAR is 9999.

Joran Beasley
- 110,522
- 12
- 160
- 179
-
you could always write your own class ... but it probably would not be trivial – Joran Beasley Jul 17 '13 at 20:47
-
@JoranBeasley - maybe not exactly trivial, but it shouldn't be too hard to write a class that takes the existing datetime and just offsets the year by 1... Of course that would completely screw up leap years/days/seconds, etc... so, yeah... it wouldn't be all that easy... – twalberg Jul 17 '13 at 20:49
-
1yeah I started to write one for him and quickly got over my head for the ammt of time i was willing to commit to this answer – Joran Beasley Jul 17 '13 at 20:53
-
This is absolutely hilarious! So by this did the year zero just got removed from existence? Jezus never born?? why are we still celebrating Christmas?? – Flip Vernooij Jan 12 '16 at 08:47
-
3This follows the Gregorian calendar. Year 1 AD started just after year 1 BC ended. There never was a year 0. Does it make sense? Well, not much less than anything else about the calendar. – Domino Oct 23 '17 at 18:30
0
I don't think there is any way to do this. datetime.datetime.min says 1 is the min value for year.

Jon Kiparsky
- 7,499
- 2
- 23
- 38