<commit_before>#!/usr/bin/python

import os
import sys
import argparse
import traceback
from datetime import datetime,timedelta,time as dtime
from decimal import Decimal

def ToUnixTime(dt):
    epoch = datetime.utcfromtimestamp(0)
    delta = datetime(dt) - epoch
    return delta.days*86400 + delta.seconds

def ToDateTime(dt):
    return datetime.utcfromtimestamp(float(dt))
    
def TimeOfDay(dt):
    dt = ToDateTime(dt)
    tod = dtime(dt.hour, dt.minute, dt.second, dt.microsecond)
    return tod

if __name__ == "__main__":
    # set up command line args
    parser = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter,\
                                     description='Time processing')
    parser.add_argument('infile', nargs='?', type=argparse.FileType('r'), default=sys.stdin)
    parser.add_argument('outfile', nargs='?', type=argparse.FileType('w'), default=sys.stdout)
    parser.add_argument('-c', '--column', type=int, default=0)
    parser.add_argument('-a', '--append', action='store_true', default=False, help='append result to columns')
    parser.add_argument('-f', '--function', choices=['ToUnixTime', 'ToDateTime', 'TimeOfDay'], default='ToDateTime')
    parser.add_argument('-d', '--delimiter', default=None)
    args = parser.parse_args()
    args.function = getattr(sys.modules[__name__], args.function)

    jdelim = args.delimiter if args.delimiter != None else ' '<commit_msg>fixed it up a bit<commit_after>#!/usr/bin/python

import os
import sys
import argparse
import traceback
from datetime import datetime,timedelta,time as dtime
from decimal import Decimal

def ToUnixTime(dt):
    epoch = datetime.utcfromtimestamp(0)
    delta = dt - epoch
    return delta.days*86400 + delta.seconds

def ToDateTime(dt):
    return datetime.utcfromtimestamp(dt)
    
def TimeOfDay(dt):
    tod = dtime(dt.hour, dt.minute, dt.second, dt.microsecond)
    return tod
    
def cToUnixTime(dt):
    return ToUnixTime(datetime.strptime(dt, args.format))
    
def cToDateTime(dt):
    return ToDateTime(float(dt)).strftime(args.format)
    
def cTimeOfDay(dt):
    return TimeOfDay(ToDateTime(float(dt))).strftime(args.format)

if __name__ == "__main__":
    # set up command line args
    parser = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter,\
                                     description='Time processing')
    parser.add_argument('infile', nargs='?', type=argparse.FileType('r'), default=sys.stdin)
    parser.add_argument('outfile', nargs='?', type=argparse.FileType('w'), default=sys.stdout)
    parser.add_argument('-c', '--column', type=int, default=0)
    parser.add_argument('-a', '--append', action='store_true', default=False, help='append result to columns')
    parser.add_argument('-f', '--function', choices=['ToUnixTime', 'ToDateTime', 'TimeOfDay'], default='ToDateTime')
    parser.add_argument('-o', '--format', default=None)
    parser.add_argument('-d', '--delimiter', default=None)
    args = parser.parse_args()
    args.function = getattr(sys.modules[__name__], 'c'+args.function)
    if not args.format:
        if args.function == cTimeOfDay:
            args.format = '%H:%M:%S.%f'
        else: 
            args.format = '%Y-%m-%d_%H:%M:%S.%f'

    jdelim = args.delimiter if args.delimiter != None else ' '
{'fraction_non_alphanumeric': 0.1450105517033464, 'fraction_numerical': 0.004220681338558939, 'mean_word_length': 3.981981981981982, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5784841', 'n_tokens_mistral': 1072, 'n_tokens_neox': 1047, 'n_words': 221}