Is there a way to keep the date present at power supply lack time?
The issue with improper shutdown1 is that logically, it cannot be predicted. At all. When the power is cut, the power is gone. There is no warning or few microseconds with some electricity left.
That's a physical fact. It is not subject to argument, some hidden loophole, etc. It is like gravity. There are of course things that can be done to mitigate the possibility (see footnote), but these all, without exception, require additional hardware.
Sans that, what you could do is implement your own service which:
- Writes the time to a file periodically, eg., every minute.
- At startup, reads that file (including some kind of sanity check in case the file is corrupted because the write was interrupted by the power cut) and sets the system time if there is no network connectivity, since if there is the time will be correctly set that way.
You'll have to experiment to supersede whatever it is that sets the date currently.
- This affects pretty much all electronic devices with a microprocessor, not just the Pi. However, it is less likely to happen to most of your ready-made end-consumer goods because of how they are made -- e.g., smartphones will shutdown cleanly before their battery is gone.