We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 6ea7eb9 commit 2103f5fCopy full SHA for 2103f5f
1 file changed
tools/mail/pt.py
@@ -0,0 +1,25 @@
1
+# Copyright (c) Microsoft Corporation.
2
+# Licensed under the MIT License.
3
+
4
+"""Print the Date header of .eml files as a hex POSIX timestamp."""
5
6
+import email
7
+import email.utils
8
+import sys
9
10
11
+def main() -> None:
12
+ for path in sys.argv[1:]:
13
+ with open(path, "rb") as f:
14
+ msg = email.message_from_binary_file(f)
15
+ date_str = msg["Date"] or ""
16
+ parsed = email.utils.parsedate_tz(date_str)
17
+ if parsed is None:
18
+ hex_ts = "????????"
19
+ else:
20
+ hex_ts = f"{int(email.utils.mktime_tz(parsed)) * 1000 << 20:016x}"
21
+ print(f"{path}\t{date_str:<40}\t{hex_ts}")
22
23
24
+if __name__ == "__main__":
25
+ main()
0 commit comments