if the above SetTag method is passed a DateTime.MinValue it will throw an exception.
It would be great if you handle this edge case in the Template Class.
/Kenneth
Developer forum
E-mail notifications
Template.SetTag(string Name, DateTime Value)
Kenneth Radoor
Posted on 24/11/2011 16:02:23
Replies
Morten Snedker
Posted on 28/11/2011 10:21:00
Hi Kenneth,
Any reason for not just casting your DateTime value to at string?
/Snedker
Any reason for not just casting your DateTime value to at string?
/Snedker
Nicolai Høeg Pedersen
Posted on 28/11/2011 11:46:45
1000 reasons Morten.
Then dates will not be rendered using the regional settings of the website, you would not have all the date extensions and a lot of other stuff!
Then dates will not be rendered using the regional settings of the website, you would not have all the date extensions and a lot of other stuff!
Nicolai Høeg Pedersen
Posted on 28/11/2011 11:47:05
Thats just 2 reasons - I know :-)
Kenneth Radoor
Posted on 28/11/2011 11:57:51
Yes, because then its not a date anymore, and i don´t get all the nice date-tags :)
The exeption is thrown in a relative new extention you have made in the SetTag(datetime), .SortableOffset.
If i give that method an input of DateTime.MinValue, then the offset will be an hour before the beginning of time :)
So as I see it there is 2 options.
Either we as developers have to go through all of our code and in every place where there is a possibility that the date will be minvalue, tests for it and then either cast the date to a string or take the DateTimeOffset into account.
or you could in the API test for it with a simple if statement, and just return the MinValue in that case.
In my humble opinion stuff like this has to be handled ind the API.
/Kenneth
The exeption is thrown in a relative new extention you have made in the SetTag(datetime), .SortableOffset.
If i give that method an input of DateTime.MinValue, then the offset will be an hour before the beginning of time :)
So as I see it there is 2 options.
Either we as developers have to go through all of our code and in every place where there is a possibility that the date will be minvalue, tests for it and then either cast the date to a string or take the DateTimeOffset into account.
or you could in the API test for it with a simple if statement, and just return the MinValue in that case.
In my humble opinion stuff like this has to be handled ind the API.
/Kenneth
Nicolai Høeg Pedersen
Posted on 28/11/2011 13:49:09
This post has been marked as an answer
I've made a fix in the API.
Votes for this answer: 0
Kenneth Radoor
Posted on 28/11/2011 17:16:56
Great
Thanks
/Kenneth
Thanks
/Kenneth
You must be logged in to post in the forum