id,tool_id,filename,language,content 15,3,epoch.py,py,"#!/usr/bin/env python3 """"""epoch — convert between unix timestamps and dates"""""" import sys from datetime import datetime, timezone def main(): inp = sys.argv[1] if len(sys.argv) > 1 else input().strip() try: ts = int(inp) dt = datetime.fromtimestamp(ts, tz=timezone.utc) print(dt.isoformat()) except ValueError: dt = datetime.fromisoformat(inp) print(int(dt.timestamp())) if __name__ == ""__main__"": main() " 16,3,epoch.sh,sh,"#!/bin/sh # epoch — convert between unix timestamps and dates if [ -z ""$1"" ]; then read -r input else input=""$1"" fi case ""$input"" in *[!0-9]*) # input is a date string, convert to epoch date -d ""$input"" +%s 2>/dev/null || date -j -f ""%Y-%m-%d %H:%M:%S"" ""$input"" +%s ;; *) # input is epoch, convert to date date -d ""@$input"" --iso-8601=seconds 2>/dev/null || date -r ""$input"" +%Y-%m-%dT%H:%M:%S%z ;; esac "