Library for subverting current date and time to a given application.
Preload this library to a program that calls time(2) or gettimeofday(2) functions if you need to make it think that it's not the current date but a different one.
Set one of these environment variables:
If both variables are set, then FAKE_TIME_OFFSET has a precedence.
To convert a given time to <sec-since-epoch> use:
$ date -d "2000-01-01 12:13:14" +%s
946725194
$ date
Wed Sep 24 14:41:20 CEST 2003
$ FAKE_TIME_OFFSET=-86400 LD_PRELOAD=./libfaketime.so date
Tue Sep 23 14:41:20 CEST 2003
$ FAKE_TIME_START=946725194 LD_PRELOAD=./libfaketime.so date
Sat Jan 1 12:13:14 CET 2000
On ELF systems it is possible to let the library print a help
when invoked directly from the command line, i.e.
$ ./libfaketime.so libfaketime.so - Library for subverting current time. [...]
For this to work you must know your runtime linker at the time of compilation. The approach used in my Makefile is to build a dummy program, extract its .interp section to a separate file and finally put the content of this file to ld-so.h header.
This was tested on different linux architectures with different names of runtime linkers, e.g. /lib/ld-linux.so.2 on i386, /lib64/ld-linux-x86-64.so.2 on AMD64, /lib/ld.so.1 on S390, /lib/lib64.so.1 on S390x, etc.
Please see the Makefile below for details on how is ld-so.h generated.
Thanks to Andreas Thienemann for clock_gettime(3) support