#!/usr/bin/env python

r"""
This module contains functions having to do with date time filter.
"""

from datetime import datetime


def convert_string_dateime(date_str, date_format, desired_format):
    r"""
    Return a date time formatted from a string datetime.

    Description of arguments(s):
    date_str            Date time string e.g 2021072418161
                        or list ["2021072418161", "20210723163401"]
    date_format         Date time pattern of the string date time
                        e.g '%Y%m%d%H%M%S'
    desired_format      User define format e.g '%m/%d/%Y - %H:%M:%S'
    """

    if isinstance(date_str, list):
        tmp_date = []
        for date in date_str:
            tmp_date.append(datetime.strptime(date, date_format).strftime(desired_format))
        return tmp_date
    else:
        return datetime.strptime(date_str, date_format).strftime(desired_format)

Add date time util module
Plugin: Add date time util module

Change-Id: I6ab1d8bb8df63b8590ce7800e60415d90ea3bad3
Signed-off-by: George Keishing <bef0a9ecac45fb57611777c8270153994e13fd2e@in.ibm.com>
