From 7cd50eccf0aeaa4c8e5e11b34b4b49ac3de0aea7 Mon Sep 17 00:00:00 2001 From: Kyle Spearrin <kyle.spearrin@gmail.com> Date: Thu, 14 Dec 2017 13:24:26 -0500 Subject: [PATCH] swap dates if start > end --- src/Api/Controllers/EventsController.cs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/Api/Controllers/EventsController.cs b/src/Api/Controllers/EventsController.cs index 7309498f78..700fecaa95 100644 --- a/src/Api/Controllers/EventsController.cs +++ b/src/Api/Controllers/EventsController.cs @@ -74,9 +74,16 @@ namespace Bit.Api.Controllers } } - if(start.Value > end.Value || (end.Value - start.Value) > TimeSpan.FromDays(32)) + if(start.Value > end.Value) { - throw new BadRequestException("Invalid date range."); + var newEnd = start; + start = end; + end = newEnd; + } + + if((end.Value - start.Value) > TimeSpan.FromDays(367)) + { + throw new BadRequestException("Range too large."); } return new Tuple<DateTime, DateTime>(start.Value, end.Value);