0

Many people know Linux time is stored in Seconds since 1970. This time field explodes around the year 2032 and can no longer be used. I'm considering writing a new app that tracks the time a file was last read in Android 7.1.1 which is using Linux Kernel 3.18.

I haven't done any time (date) related programming / record keeping yet and I'm wondering if there is a new format of 64-bit integers or something I can use now. I would write backwards compatability function to the current 32-bit Seconds field currently used in Ubuntu.

Note this isn't a question about Android which is off-topic. I'll be developing my bash script in Ubuntu using Linux 4.14 or 5.3 which accesses Linux 3.18 used in Android via USB.

I know the time Linux blows up is still 19 years away, but I like to future-proof my stuff without having to change it later or to at least make future code changes easier. As I've been coding for over 30 years chances are good I'll still love doing it 20 years from now.

Some examples from Wikipedia:

  • Windows: 1 January 1601 to 14 September 30,828
  • Unix and POSIX: 1 January 1970 to AD 292,277,026,596

I think the Unix and POSIX format to the year 292 billion will outlive the sun which means we'll move off the earth by then and have a new calendar anyway. Plus odds are good my programs will be obsolete 292 billion years from now.

Where can I find the standard for future Linux Time format? Or at least the short list of proposed standards?

2

1 Answer 1

2

Where can I find the standard for future Linux Time format?

$ cat xx.c
#include <stdio.h>
#include <time.h>
#include <sys/stat.h>

    void
main(void) {
    auto time_t t;
    auto struct stat s;
    printf("%d %d\n", (int)sizeof(t), (int)sizeof(s.st_mtime));
}

$ cc xx.c && ./a.out
8 8

Type (time_t) is already 8 bytes, corresponding to what you list as the "Unix and POSIX" standard.

What makes you think Linux needs to define a new standard?

2
  • What exactly are the upper and lower boundaries of an 8-byte type_t – it’s signed I suppose? Is this a 32 or 64 bit OS where you tried this? Isn’t it (still?) different for 32 bit? What about 32 bit binaries, ioctl() calls and inode timestamps? Filesystems like ext3 and even ext4 use a 32-bit type_t.
    – dessert
    Sep 21, 2019 at 5:55
  • @dessert, yes there are very many existing systems where timestamps are stored in only 32 bits, and yes they are going to break in 2038 if they aren't changed. Even worse, many of them are permanently embedded systems that can't be changed. But the question wasn't about that, it was about finding a new standard. Sep 21, 2019 at 11:54

You must log in to answer this question.

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