By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,885 Members | 1,474 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,885 IT Pros & Developers. It's quick & easy.

Creating new custom calendars

P: n/a
I have been looking for information on creating new custom calendars; not the
control, but the class that manages dates and date calculations. The only
thing I've been able to find in any of the MS documentation or newsgroups is
that you _can_ derive custom calendars from System.Globablization.Calendar,
but not a word on what you would need to do to accomplish that. Has anyone
ever done or seen any custom calendar implementations? I'd appreciate any
help or pointers on this.
Oct 22 '08 #1
Share this Question
Share on Google+
1 Reply


P: n/a
You may consider looking at extending one of the custom calendars rather
than the abstract Calendar. You then don't need to override so many
methods. For example this class extends GregorianCalendar, making years
relative to 1981.

class ModernCalendar : GregorianCalendar
{
public override int GetYear(DateTime time)
{
return time.Year - 1981;
}
}

Then you could call it via:

static void Main(string[] args)
{
ModernCalendar mc = new ModernCalendar();
GregorianCalendar gc = new GregorianCalendar();

DateTime gcday = new DateTime(2008, 11, 19, gc);
Console.Out.WriteLine(gcday);
DateTime modday = new DateTime(
mc.GetYear(gcday), mc.GetMonth(gcday), mc.GetDayOfMonth(gcday), mc);
Console.Out.WriteLine(modday.ToString());

Console.Out.WriteLine("OK");
Console.In.ReadLine();
}

"Arthur Parker" <Ar**********@discussions.microsoft.comwrote in message
news:9A**********************************@microsof t.com...
>I have been looking for information on creating new custom calendars; not
the
control, but the class that manages dates and date calculations. The only
thing I've been able to find in any of the MS documentation or newsgroups
is
that you _can_ derive custom calendars from
System.Globablization.Calendar,
but not a word on what you would need to do to accomplish that. Has
anyone
ever done or seen any custom calendar implementations? I'd appreciate any
help or pointers on this.
Oct 23 '08 #2

This discussion thread is closed

Replies have been disabled for this discussion.