{"id":15002876,"url":"https://github.com/batiati/dateoffset","last_synced_at":"2025-05-07T06:46:19.032Z","repository":{"id":39163947,"uuid":"383945640","full_name":"batiati/dateoffset","owner":"batiati","description":"Modifies the system time for a single application or container.","archived":false,"fork":false,"pushed_at":"2021-07-08T12:28:08.000Z","size":3,"stargazers_count":4,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-10-12T07:21:06.768Z","etag":null,"topics":["datetime","docker","intercept-calls","jemalloc","libfaketime","mssql","mssqlserver"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"unlicense","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/batiati.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-07-07T23:12:42.000Z","updated_at":"2023-02-16T07:14:12.000Z","dependencies_parsed_at":"2022-09-11T17:41:50.963Z","dependency_job_id":null,"html_url":"https://github.com/batiati/dateoffset","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/batiati%2Fdateoffset","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/batiati%2Fdateoffset/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/batiati%2Fdateoffset/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/batiati%2Fdateoffset/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/batiati","download_url":"https://codeload.github.com/batiati/dateoffset/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225084290,"owners_count":17418374,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["datetime","docker","intercept-calls","jemalloc","libfaketime","mssql","mssqlserver"],"created_at":"2024-09-24T18:53:32.546Z","updated_at":"2024-11-17T19:49:27.815Z","avatar_url":"https://github.com/batiati.png","language":"C","readme":"# Lib dateoffset\n\n### Modifies the system time for a single application or container through Linux syscall\n\n## 1. What is it\n\n_Lib dateoffset_ provides a very simple way to run a single application or container with a different date, without changing the system clock.\n\nIt's useful for testing and debugging code that are time-dependant, like databases, certificates, and all sort of business logic that involves dates.\n\n## 2. Motivation\n\nIf you are looking for a portable and full featured solution, you might opt for the excellent [libfaketime](https://github.com/wolfcw/libfaketime).\n\nUnfortunately the way [libfaketime](https://github.com/wolfcw/libfaketime) works [clash with some applications](https://github.com/wolfcw/libfaketime/issues/130) using [jemalloc](http://jemalloc.net/) as memory allocator, which apperas to be the case of [Microsoft SQL Server for Linux](https://hub.docker.com/_/microsoft-mssql-server) and many other applications.\n\n_Lib dateoffset_ solves it by eliminating memory allocations caused by `dlsym` and directly calls Linux `clock_gettime` syscall.\n\nI strongly suggest you to try [libfaketime](https://github.com/wolfcw/libfaketime) first before using this one.\n\n## 3. Usage\n\nJust like [libfaketime](https://github.com/wolfcw/libfaketime), the basic way of running any command/program with _Lib dateoffset_ is getting it loaded by system's linker using the environment variable `LD_PRELOAD`.\n\nHowever, unlike [libfaketime](https://github.com/wolfcw/libfaketime), _Lib dateoffset_ is much more limitted and has just one way to define the date, through the environment variable `DATE_OFFSET` with the start date in epoch format (seconds since 1970-01-01 00:00:00 UTC). You can use the command [date](https://man7.org/linux/man-pages/man1/date.1.html) to convert a date in format `yyyy-MM-dd` to seconds.\n\nExamples:\n\na) Setting the environment variables\n\n```bash\nexport LD_PRELOAD=/path/to/dateoffset.so\nexport DATE_OFFSET=$(date -d \"2012/12/21 12:00:00\" '+%s')\n# (now run any command you want) #\n```\n\nb) Or it can be done by specifying it on the command line itself:\n\n```bash\nLD_PRELOAD=/path/to/dateoffset.so \\\nDATE_OFFSET=$(date -d \"2019-10-30 00:00:00\" '+%s') \\\n# your_command_here #\n```\n\nc) Changing just the date, but keeping the time unchanged\n\n```bash\nLD_PRELOAD=/path/to/dateoffset.so \\\nDATE_OFFSET=$(($(date -d \"2016-10-12\" '+%s') + ($(date '+%s') % (24*60*60)))) \\\n# your_command_here #\n```\n\nd) Dockerfile\n\n```Dockerfile\nENV LD_PRELOAD=/path/to/dateoffset.so\nENV DATE_OFFSET=2090-07-04\nENTRYPOINT [\"/my-app\"]\n```\n\n## License\n\n* This project is a free and unencumbered software released into the public domain. Plese visit [unlicense.org](https://unlicense.org/) for more details.\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbatiati%2Fdateoffset","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbatiati%2Fdateoffset","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbatiati%2Fdateoffset/lists"}