How to use the memacs.lib.orgformat.OrgFormat function in memacs

To help you get started, we’ve selected a few memacs examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github novoid / Memacs / memacs / lib / orgformat.py View on Github external
def strdatetimeiso8601(datetime_string):
        """
        returns a date string in org format
        i.e.: * 
        @param date-string: has to be a str
                            in following format: YYYY-MM-DDTHH.MM.SS or
                                                 YYYY-MM-DDTHH.MM
        """
        assert datetime_string.__class__ == str
        tuple_date = OrgFormat.datetimetupeliso8601(datetime_string)
        return OrgFormat.date(tuple_date, show_time=True)
github novoid / Memacs / memacs / lib / orgformat.py View on Github external
def strdatetime(datetime_string, inactive=False):
        """
        returns a date string in org format
        i.e.: * 
        @param date-string: has to be a str in
                           following format: YYYY-MM-DD HH:MM
        @param inactive: (boolean) True: use inactive time-stamp; else use active
        """
        assert datetime_string.__class__ == str
        try:
            tuple_date = time.strptime(datetime_string, "%Y-%m-%d %H:%M")
        except ValueError as e:
            raise TimestampParseException(e)
        if inactive:
            return OrgFormat.inactive_date(tuple_date, show_time=True)
        else:
            return OrgFormat.date(tuple_date, show_time=True)
github novoid / Memacs / memacs / lib / orgformat.py View on Github external
def fix_struct_time_wday(tuple_date):
        """
        returns struct_time timestamp with correct day of week
        @param struct_time with possible false day of week
        """

        assert tuple_date.__class__ == time.struct_time

        datetimestamp = OrgFormat.struct_time_to_datetime(tuple_date)

        return time.struct_time([datetimestamp.year,
                                 datetimestamp.month,
                                 datetimestamp.day,
                                 datetimestamp.hour,
                                 datetimestamp.minute,
                                 datetimestamp.second,
                                 datetimestamp.weekday(),
                                 0, 0])
github novoid / Memacs / memacs / lib / orgformat.py View on Github external
"""
        returns a date(time) range string in org format
        if both parameters do not contain time information,
        utcrange is same as daterange, else it is same as datetimerange.

        @param begin,end: has to be a a time.struct_time
        """

        if begin_tupel.tm_sec == 0 and \
                begin_tupel.tm_min == 0 and \
                begin_tupel.tm_hour == 0 and \
                end_tupel.tm_sec == 0 and \
                end_tupel.tm_min == 0 and \
                end_tupel.tm_hour == 0:

            return OrgFormat.daterange(begin_tupel, end_tupel)
        else:
            return OrgFormat.datetimerange(begin_tupel, end_tupel)
github novoid / Memacs / memacs / lib / orgformat.py View on Github external
assert deltahours.__class__ in (int, float)
        assert orgtime.__class__ == str

        # first time-stamp: range_components.groups(0)[0]
        # second time-stamp: range_components.groups(0)[10]
        range_components = re.match(
            OrgFormat.ORGMODE_TIMESTAMP_RANGE_REGEX, orgtime)

        if range_components:
            return OrgFormat.datetime(
                OrgFormat.orgmode_timestamp_to_datetime(
                    range_components.groups(0)[0]) +
                datetime.timedelta(0, 0, 0, 0, 0, deltahours)) + \
                "-" + \
                OrgFormat.datetime(
                    OrgFormat.orgmode_timestamp_to_datetime(
                        range_components.groups(0)[10]) +
                    datetime.timedelta(0, 0, 0, 0, 0, deltahours))
        else:
            return OrgFormat.datetime(OrgFormat.orgmode_timestamp_to_datetime(orgtime) +
                                      datetime.timedelta(0, 0, 0, 0, 0, deltahours))
github novoid / Memacs / memacs / lib / orgformat.py View on Github external
def strdate(date_string, inactive=False):
        """
        returns a date string in org format
        i.e.: * 
        @param date-string: has to be a str in following format:  YYYY-MM-DD
        @param inactive: (boolean) True: use inactive time-stamp; else use active
        """
        assert date_string.__class__ == str
        tuple_date = OrgFormat.datetupeliso8601(date_string)
        if inactive:
            return OrgFormat.inactive_date(tuple_date, show_time=False)
        else:
            return OrgFormat.date(tuple_date, show_time=False)