[f-spot/stable-0.8] 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/stable-0.8] Make sure year and month are in bounds for DateTime.DaysInMonth
- Date: Tue, 23 Nov 2010 08:44:21 +0000 (UTC)
commit d765892c46488aed22417c80a08a833d904ff6fc
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 236d3af..c2e9d73 100644
--- a/src/Clients/MainApp/FSpot/TimeAdaptor.cs
+++ b/src/Clients/MainApp/FSpot/TimeAdaptor.cs
@@ -99,7 +99,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]