Repository: pimutils/khal

Issue:
How to display the hour in ikhal (+ is there a dicussion forum for basic question)
Hello again. I'm sorry to bother the issue with a rather basic question. I want to output event with their hour time with `ikhal`. I could do it with the command:

```
khal list --format "{title} {start-time-full}"
```
I tried to modify the conf file in several ways without success:

```
[calendars]

  [[private]]
    path = /path/to/calendar/
    type = calendar
    color = dark green

[locale]
timeformat = %H:%M
dateformat = %d/%m/%Y
longdateformat = %d/%m/%Y
datetimeformat = %d/%m/%Y %H:%M
longdatetimeformat = %d/%m/%Y %H:%M

[default]
default_calendar = private
```
I tried to read the doc [here](https://khal.readthedocs.io/en/latest/usage.html#) and [there](https://khal.readthedocs.io/en/latest/configure.html) but unfortunately could not find how to implement the answer

More generally is there a dicussion forum for basic questions as this one?

Many thanks in advance



Comments:

Patch:
diff --git a/CHANGELOG.rst b/CHANGELOG.rst
index 2c26869..7ba8e17 100644
--- a/CHANGELOG.rst
+++ b/CHANGELOG.rst
@@ -16,6 +16,8 @@ not released
 * CHANGE ikhal: tab (and shift tab) jump from the events back to the calendar
 * NEW Add symbol for events with at least one alarm
 * FIX URL can now be set/updated from ikhal
+* FIX Imported events without an end or duration will now last one day if
+   `DTSTART` is a date (as per RFC) or one hour if it is a datetime.
 
 0.10.3
 ======
diff --git a/khal/icalendar.py b/khal/icalendar.py
index a35fd2f..22eee2e 100644
--- a/khal/icalendar.py
+++ b/khal/icalendar.py
@@ -413,8 +413,9 @@ def sanitize_timerange(dtstart, dtend, duration=None):
 
     if dtend is None and duration is None:
         if isinstance(dtstart, dt.datetime):
-            dtstart = dtstart.date()
-        dtend = dtstart + dt.timedelta(days=1)
+            dtend = dtstart + dt.timedelta(hours=1)
+        else:
+            dtend = dtstart + dt.timedelta(days=1)
     elif dtend is not None:
         if dtend < dtstart:
             raise ValueError('The event\'s end time (DTEND) is older than '
@@ -424,7 +425,10 @@ def sanitize_timerange(dtstart, dtend, duration=None):
                 "Event start time and end time are the same. "
                 "Assuming the event's duration is one hour."
             )
-            dtend += dt.timedelta(hours=1)
+            if isinstance(dtstart, dt.datetime):
+                dtend += dt.timedelta(hours=1)
+            else:
+                dtend += dt.timedelta(days=1)
 
     return dtstart, dtend
 


Test patch:
diff --git a/tests/backend_test.py b/tests/backend_test.py
index f966464..07f5b94 100644
--- a/tests/backend_test.py
+++ b/tests/backend_test.py
@@ -564,11 +564,13 @@ def test_no_dtend():
     """test support for events with no dtend"""
     db = backend.SQLiteDb([calname], ':memory:', locale=LOCALE_BERLIN)
     db.update(_get_text('event_dt_no_end'), href='event_dt_no_end', calendar=calname)
-    events = db.get_floating(
-        dt.datetime(2016, 1, 16, 0, 0), dt.datetime(2016, 1, 17, 0, 0))
+    events = db.get_localized(
+        BERLIN.localize(dt.datetime(2016, 1, 16, 0, 0)),
+        BERLIN.localize(dt.datetime(2016, 1, 17, 0, 0)),
+    )
     event = list(events)[0]
-    assert event[2] == dt.date(2016, 1, 16)
-    assert event[3] == dt.date(2016, 1, 17)
+    assert event[2] == BERLIN.localize(dt.datetime(2016, 1, 16, 8, 0))
+    assert event[3] == BERLIN.localize(dt.datetime(2016, 1, 16, 9, 0))
 
 
 event_rdate_period = """BEGIN:VEVENT
diff --git a/tests/khalendar_utils_test.py b/tests/khalendar_utils_test.py
index cbe35d7..ed81e88 100644
--- a/tests/khalendar_utils_test.py
+++ b/tests/khalendar_utils_test.py
@@ -791,8 +791,8 @@ class TestSanitize:
     def test_noend_datetime(self):
         vevent = _get_vevent(noend_datetime)
         vevent = icalendar_helpers.sanitize(vevent, berlin, '', '')
-        assert vevent['DTSTART'].dt == dt.date(2014, 8, 29)
-        assert vevent['DTEND'].dt == dt.date(2014, 8, 30)
+        assert vevent['DTSTART'].dt == BERLIN.localize(dt.datetime(2014, 8, 29, 8))
+        assert vevent['DTEND'].dt == BERLIN.localize(dt.datetime(2014, 8, 29, 9))
 
     def test_duration(self):
         vevent = _get_vevent_file('event_dtr_exdatez')