Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 26 additions & 2 deletions AbeckDev.DbTimetable.Mcp/Services/TimeTableService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,32 @@ public async Task<string> GetStationBoardAsync(
CancellationToken cancellationToken = default)
{
// Format: yyMMddHHmm (e.g., 2511051830 for 2025-11-05 18:30)
var dateParam = date?.ToString("yyMMdd") ?? DateTime.UtcNow.ToString("yyMMdd");
var hourParam = date?.ToString("HH") ?? DateTime.UtcNow.ToString("HH");
// If date is provided by user, use it directly (user is expected to provide German time)
// If not provided, get current time in German timezone
DateTime effectiveTime;
if (date.HasValue)
{
effectiveTime = date.Value;
}
else
{
try
{
var tz = TimeZoneInfo.FindSystemTimeZoneById("Europe/Berlin");
effectiveTime = TimeZoneInfo.ConvertTimeFromUtc(DateTime.UtcNow, tz);
}
catch (TimeZoneNotFoundException)
{
effectiveTime = DateTime.Now; // fallback to local time if timezone not found
}
catch (InvalidTimeZoneException)
{
effectiveTime = DateTime.Now; // fallback to local time if timezone invalid
Comment thread
abeckDev marked this conversation as resolved.
Comment thread
abeckDev marked this conversation as resolved.
}
}

var dateParam = effectiveTime.ToString("yyMMdd");
var hourParam = effectiveTime.ToString("HH");

using var request = new HttpRequestMessage(HttpMethod.Get, $"plan/{evaNo}/{dateParam}/{hourParam}");
request.Headers.Add("DB-Client-Id", _config.ClientId);
Expand Down
4 changes: 2 additions & 2 deletions AbeckDev.DbTimetable.Mcp/Tools.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public async Task<string> GetFullStationChanges(
[Description("Get station board (departures and arrivals) for a specific station in hourly slices. Returns XML data with train schedules.")]
public async Task<string> GetStationBoard(
[Description("EVA station number (e.g., 8000105 for Frankfurt Hauptbahnhof)")] string evaNo,
[Description("Date and time in format 'yyyy-MM-dd HH:mm' (UTC). Leave empty for current time.")] string? dateTime = null)
[Description("Date and time in format 'yyyy-MM-dd HH:mm' (German Time). Leave empty for current time.")] string? dateTime = null)
{
try
{
Expand Down Expand Up @@ -119,7 +119,7 @@ public async Task<string> GetStationBoard(
public async Task<string> FindTrainConnections(
[Description("Starting station name or EVA number (e.g., 'Frankfurt Hbf' or '8000105')")] string stationA,
[Description("Destination station name or EVA number (e.g., 'Berlin Hbf' or '8011160')")] string stationB,
[Description("Date and time in format 'yyyy-MM-dd HH:mm' (UTC). Leave empty for current time.")] string? dateTime = null)
[Description("Date and time in format 'yyyy-MM-dd HH:mm' (German Time). Leave empty for current time.")] string? dateTime = null)
{
try
{
Expand Down