From 8c4f499b24a6a35657897ba6f29933031d9ae63b Mon Sep 17 00:00:00 2001 From: Intel A80486DX2-66 Date: Wed, 26 Jun 2024 22:38:55 +0300 Subject: [PATCH] add year_2038_bug.py --- python-programming/year_2038_bug.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 python-programming/year_2038_bug.py diff --git a/python-programming/year_2038_bug.py b/python-programming/year_2038_bug.py new file mode 100644 index 0000000..c53224d --- /dev/null +++ b/python-programming/year_2038_bug.py @@ -0,0 +1,14 @@ +#!/usr/bin/python3 + +# year_2038_bug.py +# +# Author: Intel A80486DX2-66 +# License: Unlicense + +from ctypes import c_int, sizeof +from datetime import datetime, timedelta + +BITS_IN_BYTE = 8 +MAX_INT_VALUE = max_value = 2 ** (sizeof(c_int) * BITS_IN_BYTE - 1) - 1 + +print((datetime(1970, 1, 1) + timedelta(seconds=MAX_INT_VALUE)).ctime())