Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #find creation date by id from @iAiyko
- from datetime import datetime
- time_formats = [
- {"max": 2760000, "value": 60000, "name": "minute", "past": "a minute ago", "future": "in a minute"},
- {"max": 7200000, "value": 3600000, "name": "hour", "past": "an hour ago", "future": "in an hour"},
- {"max": 5184000000, "value": 86400000, "name": "day", "past": "yesterday", "future": "tomorrow"},
- {"max": 24192000000, "value": 604800000, "name": "week", "past": "last week", "future": "in a week"},
- {"max": 28512000000, "value": 2592000000, "name": "month", "past": "last month", "future": "in a month"}
- ]
- def format_time(t, e, n, i, h, b):
- s = round(abs(t) / e)
- if b:
- return h if s <= 1 else f"in {s} {n}s"
- return i if s <= 1 else f"{s} {n}s ago"
- def relative_time(date):
- now = datetime.now()
- diff = (now - date).total_seconds() * 1000
- if abs(diff) < 60000:
- return "just now"
- for time_format in time_formats:
- if abs(diff) < time_format["max"]:
- return format_time(
- diff, time_format["value"], time_format["name"],
- time_format["past"], time_format["future"], diff < 0
- )
- return format_time(diff, 31536000000, "year", "last year", "in a year", diff < 0)
- def interpolate_value(t, e):
- return t, datetime.fromtimestamp(e)
- ids = [
- (1000000, 1380326400), (2768409, 1383264000), (7679610, 1388448000), (11538514, 1391212800),
- (15835244, 1392940000), (23646077, 1393459200), (38015510, 1393632000), (44634663, 1399334400),
- (46145305, 1400198400), (54845238, 1411257600), (63263518, 1414454400), (101260938, 1425600000),
- (101323197, 1426204800), (103151531, 1433376000), (103258382, 1432771200), (109393468, 1439078400),
- (111220210, 1429574400), (112594714, 1439683200), (116812045, 1437696000), (122600695, 1437782400),
- (124872445, 1439856000), (125828524, 1444003200), (130029930, 1441324800), (133909606, 1444176000),
- (143445125, 1448928000), (148670295, 1452211200), (152079341, 1453420000), (157242073, 1446768000),
- (171295414, 1457481600), (181783990, 1460246400), (222021233, 1465344000), (225034354, 1466208000),
- (278941742, 1473465600), (285253072, 1476835200), (294851037, 1479600000), (297621225, 1481846400),
- (328594461, 1482969600), (337808429, 1487707200), (341546272, 1487782800), (352940995, 1487894400),
- (369669043, 1490918400), (400169472, 1501459200), (616816630, 1529625600), (681896077, 1532821500),
- (727572658, 1543708800), (796147074, 1541371800), (925078064, 1563290400), (928636984, 1581513420),
- (1054883348, 1585674420), (1057704545, 1580393640), (1145856008, 1586342040), (1227964864, 1596127860),
- (1382531194, 1600188120), (1658586909, 1613148540), (1660971491, 1613329440), (1692464211, 1615402500),
- (1719536397, 1619293500), (1721844091, 1620224820), (1772991138, 1617540360), (1807942741, 1625520300),
- (1893429550, 1622040000), (1972424006, 1631669400), (1974255900, 1634000000), (2030606431, 1631992680),
- (2041327411, 1631989620), (2078711279, 1634321820), (2104178931, 1638353220), (2120496865, 1636714020),
- (2123596685, 1636503180), (2138472342, 1637590800), (3318845111, 1618028800), (4317845111, 1620028800),
- (5162494923, 1652449800), (5186883095, 1648764360), (5304951856, 1656718440), (5317829834, 1653152820),
- (5318092331, 1652024220), (5336336790, 1646368100), (5362593868, 1652024520), (5387234031, 1662137700),
- (5396587273, 1648014800), (5409444610, 1659025020), (5416026704, 1660925460), (5465223076, 1661710860),
- (5480654757, 1660926300), (5499934702, 1662130740), (5513192189, 1659626400), (5522237606, 1654167240),
- (5537251684, 1664269800), (5559167331, 1656718560), (5568348673, 1654642200), (5591759222, 1659025500),
- (5608562550, 1664012820), (5614111200, 1661780160), (5666819340, 1664112240), (5684254605, 1662134040),
- (5684689868, 1661304720), (5707112959, 1663803300), (5756095415, 1660925940), (5772670706, 1661539140),
- (5778063231, 1667477640), (5802242180, 1671821040), (5853442730, 1674866100), (5859878513, 1673117760),
- (5885964106, 1671081840), (5982648124, 1686941700), (6020888206, 1675534800), (6032606998, 1686998640),
- (6057123350, 1676198350), (6058560984, 1686907980), (6101607245, 1686830760), (6108011341, 1681032060),
- (6132325730, 1692033840), (6182056052, 1687870740), (6279839148, 1688399160), (6306077724, 1692442920),
- (6321562426, 1688486760), (6364973680, 1696349340), (6386727079, 1691696880), (6429580803, 1692082680),
- (6527226055, 1690289160), (6813121418, 1698489600), (6865576492, 1699052400), (6925870357, 1701192327), (6944368668, 1726144496), (7682429075, 1725539696), (8000499714, 1745152496), (7798375391, 1745411696), (7321742406, 1726835696), (7538420552, 1723379696), (7745089650, 1745584496)
- ]
- ids.sort(key=lambda x: x[0])
- def find_date(user_id):
- for i in range(1, len(ids)):
- if ids[i - 1][0] <= user_id <= ids[i][0]:
- prev = ids[i - 1]
- curr = ids[i]
- ratio = (user_id - prev[0]) / (curr[0] - prev[0])
- interpolated_timestamp = int(prev[1] + ratio * (curr[1] - prev[1]))
- return interpolate_value("~", interpolated_timestamp)
- if user_id <= 1000000:
- return interpolate_value("<", 1380326400)
- return interpolate_value(">", 1745584496)
- def creation(user_id):
- result = find_date(user_id)
- if result:
- comparison, date = result
- approx = "Approximately " if comparison == "~" else "After " if comparison == ">" else "Before "
- return f"{approx}{date.strftime('%Y-%m-%d')} ({relative_time(date)})"
- return "Invalid User ID"
Advertisement
Add Comment
Please, Sign In to add comment