def parse_datetime(dtime: str):
    """
    Parse a datetime or period string from STAC request.

    :param dtime str: input datetime:
                        A date-time: "2018-02-12T23:20:50Z"
                        A period: "2018-02-12T00:00:00Z/2018-03-18T12:31:12Z"
                          or "2018-02-12T00:00:00Z/P1M6DT12H31M12S", the
                          former is not supported yet.
                      None is returned if None is inpue
    :return: start, end, equal to None if not defined
    """

    if not dtime:
        return None, None

    fields = dtime.split("/")
    assert len(fields) < 3 and fields, "Can't parse " + dtime
    start = fields[0]
    end = None
    if len(fields) == 2:
        end = fields[1]
    return start, end