Age Tracker: Source CodeJuly 7, 2012
I was working on another app for the contest but had an idea for another one when I was asked a few times how old my daughter was. At her age we’re basically counting months so I figured, I would make an app to tell me exactly how old she is. While I was at it I would make it save mine and my wife’s birthdays as well.
I stated off making a class to calculate the years, months, days, hours, minuets, seconds between 2 dates and quickly realized that between leap years and other factors, rolling my own solution to this problem would be a long process. With that in mind, I went on the hunt for a class written in C# and was either compatible with Windows Phone (WP7) or was written in plain enough C# that I could copy it into a WP7 class and fix any errors.
After looking around and trying a few different solutions, I came across the Time Period Library for .NET written by Jani Giannoudis. Now to be honest, this library is overkill. But because the TimeSpan class included provides exactly what I need, I’m okay with that.
Along with a binary of Time Period Library for .NET, this solution uses some Windows Phone controls from Telerik. Several Telerik controls are used in this solution including RadDatePicker, RadTimePicker and RadDiagnostics. The use of the first 2 are obvious but the 3rd one is used to catch UnhandledExceptions and present the user with the option to send an email to the support email for the application. I use the option to include a Base64 encoded screenshot with the email.
To get the Time Period Library for .NET binary we need, do the following:
- Download the source from here.
- Unzip the source in a local folder.
- Open the “TimePeriod.WindowsPhone.sln” solution.
- Make sure the Solutions Configurations is set to “Release”.
- Press F6 to build the solution.
- Now go back to the folder with the source and open the “Pub” folder.
- In the “WindowsPhone.Release” folder you will find the “Itenso.TimePeriod.dll” file.
Now you can download the source for my solution. Once you open it, you will need to add references to the following Dlls:
- Itenso.TimePeriod.dll in the location it built above.