Skip to content

feat(calendar): natural language time parsing in event title#8505

Open
miaulalala wants to merge 2 commits into
mainfrom
feat/natural-language-time-parsing
Open

feat(calendar): natural language time parsing in event title#8505
miaulalala wants to merge 2 commits into
mainfrom
feat/natural-language-time-parsing

Conversation

@miaulalala

@miaulalala miaulalala commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds natural language time/date parsing to the event title field in both the popover (EditSimple) and full (EditFull) editors. When the user types a recognised time or date expression, a dismissible suggestion banner appears below the title input.

  • Apply (button or Enter key): sets the event time/date and strips the matched text from the title
  • Dismiss (button or Escape key): hides the banner without making changes

Supported patterns:

  • Time only: 2pm, 14:00, 9am
  • Time range: 10:00 - 14:00, 10am to 2pm
  • Date (→ all-day): July 23, 23.07.26, 07/23/2026
  • Date range (→ all-day): June 1 to June 3, June 1-3
  • Date + time: July 23 4pm, 14.08.2026 19:00
  • All day: all day, all-day
  • Relative: tomorrow, next Monday, this Friday, in 3 days, next week
  • Weekday + time: next Friday 14:00

Multi-language support via chrono-node locale routing based on getLanguage(): de, fr, es, it, nl, pt, ru, uk, sv, fi, ja, vi, zh-hans, zh-hant, with English fallback for unsupported locales.

Implementation:

  • src/services/naturalLanguageTimeParserService.js — parsing logic using chrono-node with a custom European DD.MM.YY parser prepended for priority
  • src/components/Editor/Properties/TimeSuggestion.vue — suggestion banner component
  • src/mixins/TimeSuggestionMixin.js — shared mixin consumed by both editor views
  • 94 unit tests covering all pattern types, stripping positions, locale handling, and relative expressions

Screenshot

image

AI disclosure

This PR was developed with assistance from Claude Code (claude-sonnet-4-6).

Test plan

  • Open a new event in the popover editor, type 2pm in the title → suggestion banner appears showing "Set time: 14:00"
  • Press Enter → time is set, "2pm" is removed from the title
  • Type all day → banner shows "Mark as all-day event", apply toggles all-day
  • Type June 1 to June 3 → banner shows date range, apply sets both dates as all-day
  • Type tomorrow 3pm → banner shows datetime, apply sets date and time
  • Type next Monday → banner shows date, apply sets all-day on that Monday
  • Press Escape → banner dismissed without changes
  • Repeat key flows in the full editor (EditFull)
  • With Nextcloud set to German, type 15. Juli → suggestion appears
  • Run unit tests: npm run test:unit

When a user types a time or date expression in the event title field,
a dismissible suggestion banner appears. Pressing Enter or clicking
Apply sets the event time/date and strips the matched text from the
title. Pressing Escape or clicking Dismiss hides the banner.

Supported patterns:
- Time only: "2pm", "14:00", "9am"
- Time range: "10:00 - 14:00", "10am to 2pm"
- Date (all-day): "July 23", "23.07.26", "07/23/2026"
- Date range (all-day): "June 1 to June 3", "June 1-3"
- Date + time: "July 23, 4pm", "14.08.2026 19:00"
- All day: "all day", "all-day"
- Relative: "tomorrow", "next Monday", "this Friday", "in 3 days"
- Weekday + time: "next Friday 14:00"

Multi-language support via chrono-node locale routing based on the
user's Nextcloud language setting (de, fr, es, it, nl, pt, ru, uk,
sv, fi, ja, vi, zh-hans, zh-hant, with English fallback).

The shared logic lives in TimeSuggestionMixin so both EditSimple and
EditFull stay in sync without duplication.

Assisted-by: ClaudeCode:claude-sonnet-4-6
Signed-off-by: Anna Larch <anna@nextcloud.com>
94 tests covering:
- Null/empty input
- All-day, time-only, time-range, date, date-range, datetime types
- European date format (DD.MM.YY) priority over built-in parser
- Relative expressions: tomorrow, next Monday, this Friday, in 3 days
- Weekday + time combos: next Friday 14:00
- Title stripping at leading, mid, and trailing positions
- Multi-language: de, fr, es, it, nl, ru, pt, sv, zh_CN with
  regional code normalisation and unsupported-language fallback

Assisted-by: ClaudeCode:claude-sonnet-4-6
Signed-off-by: Anna Larch <anna@nextcloud.com>
@codecov

codecov Bot commented Jun 15, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.15385% with 3 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/services/naturalLanguageTimeParserService.js 96.15% 3 Missing ⚠️

📢 Thoughts on this report? Let us know!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant