Hi,
Is there a way to quickly apply all the Date/Time extentions to a custom tag?
Nuno
Developer forum
E-mail notifications
Assign Date/Time extentions
Posted on 12/11/2010 19:15:28
Replies
Posted on 12/11/2010 20:18:57
Hi Nuno,
The SetTag method on a Template V2 that accepts a date has code like this:
public void SetTag(string Name, DateTime Value)
{
if (Name.StartsWith("Global:") || this.HtmlHasPartialTag(Name))
{
this.SetTag(Name + "", Value.ToShortDateString());
this.SetTag(Name + ".Day", DateAndTime.DatePart(DateInterval.Day, Value, FirstDayOfWeek.Sunday, FirstWeekOfYear.Jan1));
this.SetTag(Name + ".Hour", DateAndTime.DatePart(DateInterval.Hour, Value, FirstDayOfWeek.Sunday, FirstWeekOfYear.Jan1));
....
}
}
For some reason, your tag name has to start with Global....
Cheers,
Imar
The SetTag method on a Template V2 that accepts a date has code like this:
public void SetTag(string Name, DateTime Value)
{
if (Name.StartsWith("Global:") || this.HtmlHasPartialTag(Name))
{
this.SetTag(Name + "", Value.ToShortDateString());
this.SetTag(Name + ".Day", DateAndTime.DatePart(DateInterval.Day, Value, FirstDayOfWeek.Sunday, FirstWeekOfYear.Jan1));
this.SetTag(Name + ".Hour", DateAndTime.DatePart(DateInterval.Hour, Value, FirstDayOfWeek.Sunday, FirstWeekOfYear.Jan1));
....
}
}
For some reason, your tag name has to start with Global....
Cheers,
Imar
Posted on 12/11/2010 21:34:46
BTW, turns out it doesn't have to start with Global. Apparently, the second condition evaluates to true....
Cheers,
Imar
Cheers,
Imar
Posted on 15/11/2010 15:52:00
Hi Imar,
That's what we came up with. It could be a good idea to have a special SetDateTimeTag that would do all of it automatically.
Thanks,
Nuno
Nicolai Høeg Pedersen
Posted on 15/11/2010 16:00:00
Template.SetTag has 6 overloads. One of them takes a value parameter as Date - that will automatically make the date time extensions.
Just make sure you pass the date as a Date object and not a string...
Just make sure you pass the date as a Date object and not a string...
Posted on 15/11/2010 16:05:00
Hi Nicolai,
Perfect. Thanks a lot.
Nuno
Perfect. Thanks a lot.
Nuno
You must be logged in to post in the forum