This commit is contained in:
2025-08-30 10:25:01 +02:00
parent 79d048f2f8
commit 31deff9809
9 changed files with 703 additions and 3 deletions

134
README.md Normal file
View File

@@ -0,0 +1,134 @@
# Org2Ics - Bidirectional Org/iCalendar Converter
A C# console application that provides bidirectional conversion between .org diary files and .ics (iCalendar) format.
## Description
This tool converts between .org files containing diary entries and iCalendar (.ics) files. It supports:
- **Org to ICS**: Convert diary entries to all-day calendar events named "Chronolog"
- **ICS to Org**: Convert calendar events back to org diary format with proper date headers
## Features
- **Bidirectional conversion** between .org and .ics formats
- **Auto-detection** of input file format based on file extension
- **Org to ICS conversion**:
- Parses .org files with level 3 headings (***) containing dates in YYYY-MM-DD format
- Extracts diary content for each date entry
- Creates all-day events with the title "Chronolog"
- Includes diary content as event descriptions
- **ICS to Org conversion**:
- Parses standard .ics calendar files
- Extracts event dates and descriptions
- Organizes entries by year and month
- Creates proper org-mode structure with level 3 date headers
- **Proper character escaping** for both formats
- **Round-trip compatibility** for seamless conversion between formats
## Usage
```bash
dotnet run <input.org|input.ics> [output.ics|output.org]
```
### Parameters
- `input.org|input.ics`: Path to the input file (required)
- `.org` files will be converted to `.ics` format
- `.ics` files will be converted to `.org` format
- `output.ics|output.org`: Path to the output file (optional, auto-determined if not specified)
### Examples
```bash
# Convert diary.org to diary.ics
dotnet run diary.org
# Convert calendar.ics to calendar.org
dotnet run calendar.ics
# Specify custom output filename
dotnet run diary.org my-calendar.ics
dotnet run calendar.ics my-diary.org
# Round-trip conversion
dotnet run diary.org calendar.ics
dotnet run calendar.ics diary-restored.org
```
## File Format Support
### Org File Format (.org → .ics)
The converter expects .org files with the following structure:
```org
* My Diary
** Month Section
*** 2025-01-15
This is the diary content for January 15th, 2025.
It can span multiple lines and paragraphs.
*** 2025-01-16
Another diary entry for the next day.
** Another Section
*** 2025-02-01
February entry content here.
```
**Requirements:**
- Level 3 headings (starting with `***`) must contain dates in `YYYY-MM-DD` format
- Everything after a date heading until the next heading becomes the diary content for that date
- Non-date headings are ignored
### ICS File Format (.ics → .org)
The converter can parse standard iCalendar files and extracts:
- Event dates (both all-day and timed events)
- Event descriptions or summaries as diary content
- Events are organized chronologically and grouped by month
**Supported:**
- `DTSTART;VALUE=DATE:` (all-day events)
- `DTSTART:` (timed events - date portion used)
- `DESCRIPTION:` field content
- `SUMMARY:` field content (when no description available)
- Proper unescaping of iCalendar text formatting
## Output Formats
### Generated .ics Files (from .org)
- Standard iCalendar format (RFC 5545 compliant)
- All-day events spanning from the diary date to the next day
- Event title: "Chronolog"
- Event description: The diary content for that date
- Unique identifiers for each event
### Generated .org Files (from .ics)
- Proper org-mode structure with hierarchical headings
- Level 1: "Diary" (root heading)
- Level 2: Month and year groupings (e.g., "January 2025")
- Level 3: Individual date entries (e.g., "*** 2025-01-15")
- Content: Event descriptions properly formatted for org-mode
## Building
```bash
dotnet build
```
## Requirements
- .NET 8.0 or higher
- No additional dependencies required
## License
This project is provided as-is for educational and personal use.