Heybo Blog

If you look at me when I'm talking, you'll see what I'm saying ... about Tech and .NET discoveries!

My Links

News

Story Categories

Archives

Post Categories

Image Galleries

Login

Blog Stats

Links

Personal Websites

Julian Calendar Dates with C#,

To use Julian Calendar Dates with C#, you can use something similar to what is below.


using System;
using System.Globalization;


public class SamplesJulian  {

   public static void Main()  {

      // Sets a DateTime to current Date in the Gregorian calendar.
      DateTime myDT = DateTime.Now;

      // Creates an instance of the JulianCalendar.
      JulianCalendar myJC = new JulianCalendar();

      // Displays the values of the DateTime.
      Console.WriteLine( myDT + " of the Gregorian calendar equals the following in the Julian calendar:" );
      DisplayJulian( myJC, myDT );

      // Adds two years and ten months.
      myDT = myCal.AddDays( myDT, 2 );
      myDT = myCal.AddMonths( myDT, 5 );

      // Displays the values of the DateTime.
      Console.WriteLine( "After adding two days and five months:" );
      DisplayJulian( myJC, myDT );

   }

   public static void DisplayJulian( Calendar myJC, DateTime myDT )  {
      Console.WriteLine( "   Era:        {0}", myJC.GetEra( myDT ) );
      Console.WriteLine( "   Year:       {0}", myJC.GetYear( myDT ) );
      Console.WriteLine( "   Month:      {0}", myJC.GetMonth( myDT ) );
      Console.WriteLine( "   DayOfYear:  {0}", myJC.GetDayOfYear( myDT ) );
      Console.WriteLine( "   DayOfMonth: {0}", myJC.GetDayOfMonth( myDT ) );
      Console.WriteLine( "   DayOfWeek:  {0}", myJC.GetDayOfWeek( myDT ) );
      Console.WriteLine();
   }

posted on Friday, February 27, 2004 7:00 AM

Feedback

No comments posted yet
Title  
Name  
Url
Comments   
Protected by Clearscreen.SharpHIPEnter the code you see: