timetrack/cli.py
def ls(ctx, project, week, month):
    """Show tasks recorded between a certain time period"""

    driver = ctx.obj['DRIVER']

    if week:
        end = datetime.now()
        delta = timedelta(days=7)
        start = end - delta
        start_date = date(start.year, start.month, start.day)
        end_date = date(end.year, end.month, end.day)
    elif month:
        end = datetime.now()
        delta = timedelta(days=30)
        start = end - delta
        start_date = date(start.year, start.month, start.day)
        end_date = date(end.year, end.month, end.day)
    else:
        start_date = date.today()
        end_date = date.today()


    records = list(driver.get_filtered_entries(start_date, end_date, project))

    report_generate(records)

    today_str = date.today().strftime('%Y-%m-%d')

    today = [r for r in records if r['date']==today_str ]

    print("-----------")

    print("Time spent today: {}".format(
        human_time(day_spent(today))))
    print("Remaining time today: {}".format(
        human_time(day_remainder(today, working_hours=ctx.obj['CONFIG']['timetrack']['working_hours']))))
Show tasks recorded between a certain time period
Show tasks recorded between a certain time period
Show tasks recorded between a certain time period
def ls(ctx, project, week, month):
    driver = ctx.obj['DRIVER']
    if week:
        end = datetime.now()
        delta = timedelta(days=7)
        start = end - delta
        start_date = date(start.year, start.month, start.day)
        end_date = date(end.year, end.month, end.day)
    elif month:
        end = datetime.now()
        delta = timedelta(days=30)
        start = end - delta
        start_date = date(start.year, start.month, start.day)
        end_date = date(end.year, end.month, end.day)
    else:
        start_date = date.today()
        end_date = date.today()
    records = list(driver.get_filtered_entries(start_date, end_date, project))
    report_generate(records)
    today_str = date.today().strftime('%Y-%m-%d')
    today = [r for r in records if r['date']==today_str ]
    print("-----------")
    print("Time spent today: {}".format(
        human_time(day_spent(today))))
    print("Remaining time today: {}".format(
        human_time(day_remainder(today, working_hours=ctx.obj['CONFIG']['timetrack']['working_hours']))))
def ls ( ctx , project , week , month ) : driver = ctx . obj [ 'DRIVER' ] if week : end = datetime . now ( ) delta = timedelta ( days = 7 ) start = end - delta start_date = date ( start . year , start . month , start . day ) end_date = date ( end . year , end . month , end . day ) elif month : end = datetime . now ( ) delta = timedelta ( days = 30 ) start = end - delta start_date = date ( start . year , start . month , start . day ) end_date = date ( end . year , end . month , end . day ) else : start_date = date . today ( ) end_date = date . today ( ) records = list ( driver . get_filtered_entries ( start_date , end_date , project ) ) report_generate ( records ) today_str = date . today ( ) . strftime ( '%Y-%m-%d' ) today = [ r for r in records if r [ 'date' ] == today_str ] print ( "-----------" ) print ( "Time spent today: {}" . format ( human_time ( day_spent ( today ) ) ) ) print ( "Remaining time today: {}" . format ( human_time ( day_remainder ( today , working_hours = ctx . obj [ 'CONFIG' ] [ 'timetrack' ] [ 'working_hours' ] ) ) ) )
Show tasks recorded between a certain time period
Show tasks recorded between a certain time period
"""Show tasks recorded between a certain time period"""
ctx
project
week
month