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

Julian dates question

P: n/a
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

Jul 13 '06 #1
Share this Question
Share on Google+
4 Replies


P: n/a
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
Jul 13 '06 #2

P: n/a
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

"Hans Kesting" <ne***********@spamgourmet.comwrote in message
news:mn***********************@spamgourmet.com...
>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


Jul 14 '06 #3

P: n/a
Bit byte wrote:
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#)
------------------------------------------------------------------------
Jul 14 '06 #4

P: n/a
See http://www.vsg.cape.com/~pbaum/date/back.htm
mac wrote:
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

"Hans Kesting" <ne***********@spamgourmet.comwrote in message
news:mn***********************@spamgourmet.com...
>>>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



Jul 14 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.