1

The year 2021 is for me correct Year 9.

When I use:

sudo date --set="9-1-29 00:17:00.990"

I get

date: cannot set date: Invalid argument

Is there another way to set Year to 9?

6
  • What is the relation to the year 9? What you want can be done using a function where you create a function date2 and echo back the date as it is now but manipulated so it shows 9 (ie. something where 2021 -/- 2012 shows 9) It would for all other things still use 2021 but you would see 9 in command line.
    – Rinzwind
    Jan 29, 2021 at 0:28
  • @rinzwind The same question was asked and removed earlier, with religious screed. askubuntu.com/questions/1311827/…
    – popey
    Jan 29, 2021 at 0:37
  • wtf did I just read there @popey :X
    – Rinzwind
    Jan 29, 2021 at 0:41
  • 2
    Could you clarify, if you are actually trying to set your system clock to the past, OR if you are using a different calendar than the Gregorian Calendar? If it's the later, I think you are actually describing a date formatting issue. Jan 29, 2021 at 1:00
  • The relation is this. Lets say 21.12.2012 the era ended. And i am the so far the only one who counts the new era. So Year 2013 is Year 1, 2014 is Year 2,... So i am not trying to go to past. I am in same Year, but in the new era. In Lubuntu i was able to set numbers before MM,DD format instead of YYYY. But only for visibility on the desktop not actual date format in terminal. Yes it was so i made it personal not with explanation why there might be change of Year in global. Jan 29, 2021 at 5:34

3 Answers 3

4

Linux systems cannot have their system date set to a time before the UNIX epoch, which is 1 January 1970.

3
  • That is clear to me so far, but what if I wanted to be the first to use the years in the new era. Starting year 1 in 2013. Let's put it theoretically, it will be announced by a government decree, and then all OSes will have to change it. Jan 29, 2021 at 5:38
  • 1
    @MartinGaďourek if that happens we will get a module for that. There is a precedence: Linux supports the Hebrew calender.
    – Rinzwind
    Jan 29, 2021 at 8:27
  • 1
    If your question is, "will Linux find a way to deal with strange and unlikely local laws", the answer is, "yes, but not until they actually exist." It's not going to be changed to cater to every hypothetical situation.
    – grifferz
    Jan 29, 2021 at 10:34
4

No. The date in Linux is set starting from 00:00:00 UTC on 1 January 1970. You can't set the date before that time/day.

1
  • The idea is this. I have to wait until, for example, most governments realize that the years have been invalid since 2013. And are valid from year 1 in 2013. If it was announced globally, and only then would LINUX change it itself right? But there is no way to change it yourself. Jan 29, 2021 at 5:50
4

Based on your clarification in comments, it sounds like you are primarily interested in the presentation of time, rather than setting your clock to the year 9 AD in the calendar used by most of the world.

The time format used by the Linux kernel is not directly tied to the presentation of dates and times. Instead, it represents time as the number of seconds since the epoch. In the Gregorian calendar this is 1st January 1970.

If we were using your calendar representation, then the epoch would instead be 1st January in the year -42. Adding kernel time_t values to this date would give you the appropriate dates in your calendar representation.

Many programs rely on routines in the standard C library to convert kernel time values to the common Gregorian calendar values. One possible way to change how these programs work is to use the LD_PRELOAD environment variable to inject replacements for these routines that produce the desired output.

In fact, this is what the sdate package in Ubuntu does, although admittedly for humorous purposes (e.g. displaying all dates after March 2020 as part of that month, when run in COVID-19 mode). Maybe you could adapt that code to suit the representation you want?

4
  • I like that one. Totally useless but fun :D
    – Rinzwind
    Jan 29, 2021 at 8:28
  • Thank you for your explanation. I'll look into it. The new calendar will not have AD. I will not further develop why the Gregorian calendar should be invalid at this time. Jan 29, 2021 at 11:19
  • The only file i found with epoch years was this one on github sdate/libsdate.c But i don't know how to use this with library files .0 So this is the only result i like. So 2952. ledna 2013, 16:19:08 CET . So the world has had an invalid calendar for so many days. Jan 30, 2021 at 15:22
  • If you're using the sdate code base as a starting point, you'd want to replace the body of the septemberfy function. It might be enough to update it to subtract a constant from tm_year. Feb 11, 2021 at 13:36

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .