[f-spot] Make sure year and month are in bounds for DateTime.DaysInMonth
- From: Ruben Vermeersch <rubenv src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [f-spot] Make sure year and month are in bounds for DateTime.DaysInMonth
- Date: Tue, 23 Nov 2010 08:44:15 +0000 (UTC)
commit 8a437dff2d5b6feec36e5156cade3e3301c76a65
Author: Tim Howard <timothy howard gmail com>
Date: Tue Nov 23 01:38:59 2010 -0500
Make sure year and month are in bounds for DateTime.DaysInMonth
https://bugzilla.gnome.org/show_bug.cgi?id=630646
src/Clients/MainApp/FSpot/TimeAdaptor.cs | 9 ++++++++-
1 files changed, 8 insertions(+), 1 deletions(-)
---
diff --git a/src/Clients/MainApp/FSpot/TimeAdaptor.cs b/src/Clients/MainApp/FSpot/TimeAdaptor.cs
index 86edd4a..e376a66 100644
--- a/src/Clients/MainApp/FSpot/TimeAdaptor.cs
+++ b/src/Clients/MainApp/FSpot/TimeAdaptor.cs
@@ -124,7 +124,14 @@ namespace FSpot {
int year = endyear - item/12;
int month = 12 - (item % 12);
- return new DateTime (year, month, DateTime.DaysInMonth (year, month)).AddDays (1.0).AddMilliseconds (-.1);
+ year = Math.Max(1, year);
+ year = Math.Min(year, 9999);
+ month = Math.Max(1, month);
+ month = Math.Min(month, 12);
+
+ int daysInMonth = DateTime.DaysInMonth(year, month);
+
+ return new DateTime (year, month, daysInMonth).AddDays (1.0).AddMilliseconds (-.1);
}
public override int IndexFromPhoto (IPhoto photo)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]