0

I am making a Python script that converts real-life dates into dates for a fantasy world.

However, I cannot represent years smaller than 1 or bigger than 9999 using the datetime module, and they may occasionally appear. Is there any way to represent these dates in Python?

I tried using the datetime module but it doesn't support years smaller than 1 or bigger than 9999.

starball
  • 20,030
  • 7
  • 43
  • 238
  • 1
    If you are using non-standard dates then you need to define your own data type. – PM 77-1 Jan 09 '23 at 00:56
  • They are legitimate real-life dates, just that they have a very strange range. For example, this day is year 4062 when converted to fake date. – Bohaska Jan 09 '23 at 01:07
  • 1
    You might find [BC dates in Python](https://stackoverflow.com/q/15857797/4996248) interesting. Some of the answers mention astronomy as a use-case for a more expansive approach to dates. – John Coleman Jan 09 '23 at 01:15

1 Answers1

0

Your case might be an unique case as it is not the common objective for most people using datetime module. You might have to do this manually, my suggestion is as follow:

  1. Define the rule of transformation/conversion from real-life date into fake date (between 1 - 9999)
  2. Write an algorithm to perform the transformation.

Hope it helps.

  • I already have a transformation/conversion rule for real-life date to fake date that works for output years between 1 - 9999, that's not what I'm asking for. – Bohaska Jan 09 '23 at 01:05