Julian dates question

B

Bit byte

How may I represent dates as Julian dates - I have seen code where
julian dates are represented as longs, and other where they are
represented as floats. Which is the correct representation?

Anyone knows where I can obtain a routine for converting:

1). Dates to/from julian representations
2). Date/time values to/from Julian representations
 
H

Hans Kesting

How may I represent dates as Julian dates - I have seen code where julian
dates are represented as longs, and other where they are represented as
floats. Which is the correct representation?

Anyone knows where I can obtain a routine for converting:

1). Dates to/from julian representations
2). Date/time values to/from Julian representations

I don't think there is a direct way, but see the various properties of
DateTime and TimeSpan. I think you can build it.

DateTime.DayOfYear to get the daynumber.
With a timespan (DateTime.Now - DateTime.Today) you can also get the
TotalMinutes (or smaller).

You can use AddDays to add any number of days to a given date.

Hans Kesting
 
M

mac

I am a complete C# newbie, so I may be misunderstanding Hans' post, but I
wanted to point out something:

A Julian date is actually the number of days (and fractional days) since
noon Jan. 1, 4713 BC.

Many people in the I.T. community for some reason call a date "Julian" when
it simply counts the number of days from the beginning of the year. For
instance, 7/13/2006 is sometimes represented in systems that lack a date
datatype as 2006193 (the 193rd day of 2006) I do not know the proper term
for this representation of a date, but it isn't a Julian date. I think
Han's method is geard toward this later representation.

Thanks,

Mac
 
F

Frans Bouma [C# MVP]

Bit said:
How may I represent dates as Julian dates - I have seen code where
julian dates are represented as longs, and other where they are
represented as floats. Which is the correct representation?

Anyone knows where I can obtain a routine for converting:

1). Dates to/from julian representations
2). Date/time values to/from Julian representations

the routine is basicly this:

long DateToJulian(int y, int m, int d)
{
return (1461 * (y + 4800 + (m - 14) / 12)) / 4 +
(367 * (m - 2 - 12 * ((m - 14) / 12))) / 12 -
(3 * ((y + 4900 + (m - 14) / 12) / 100)) / 4 +
d - 32075;
}

I found it on the web some time ago. Needed it in a lowlevel C app
once. In .NET you don't really need it, as DateTime has all you need :)

FB

--
------------------------------------------------------------------------
Lead developer of LLBLGen Pro, the productive O/R mapper for .NET
LLBLGen Pro website: http://www.llblgen.com
My .NET blog: http://weblogs.asp.net/fbouma
Microsoft MVP (C#)
------------------------------------------------------------------------
 
I

Ian Semmel

See http://www.vsg.cape.com/~pbaum/date/back.htm

I am a complete C# newbie, so I may be misunderstanding Hans' post, but I
wanted to point out something:

A Julian date is actually the number of days (and fractional days) since
noon Jan. 1, 4713 BC.

Many people in the I.T. community for some reason call a date "Julian" when
it simply counts the number of days from the beginning of the year. For
instance, 7/13/2006 is sometimes represented in systems that lack a date
datatype as 2006193 (the 193rd day of 2006) I do not know the proper term
for this representation of a date, but it isn't a Julian date. I think
Han's method is geard toward this later representation.

Thanks,

Mac
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top