CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 11 of 11
  1. #1
    Join Date
    Jan 2008
    Posts
    98

    How to convert a Julian date to regular date and time?

    Like
    2455224.7439457 = 01/28/2010 at 07:51:16,
    I've do the google, for my first language is not English, so I may miss something,
    It's even better if there's some pseudocode for the algorithm.
    Actually I concern the time precision more!
    Please do me a favor, give me some link,thanks in advance!
    Last edited by fantasy1215; January 27th, 2010 at 09:48 PM.

  2. #2
    Join Date
    Feb 2005
    Posts
    2,160

    Re: How to convert a Julian date to regular date and time?

    A quick search of codeguru finds this post from 2001:

    http://www.codeguru.com/forum/showthread.php?t=38906

    two of the links are dead, but this one:

    http://wwwmacho.mcmaster.ca/JAVA/JD.html

    has included javascript that looks pretty straight forward:

    Code:
    <SCRIPT LANGUAGE="JavaScript">
    <!-- Hide script from old browsers
    
    function compute(form) {
       var y = parseFloat(form.year.value)
       var m = parseFloat(form.month.value)
       var d = parseFloat(form.day.value)
       var uh = parseFloat(form.uth.value)
       var um = parseFloat(form.utm.value)
       var us = parseFloat(form.uts.value)
    
       var extra = 100.0*y + m - 190002.5
       var rjd = 367.0*y
       rjd -= Math.floor(7.0*(y+Math.floor((m+9.0)/12.0))/4.0)
       rjd += Math.floor(275.0*m/9.0) 
       rjd += d
       rjd += (uh + (um + us/60.0)/60.)/24.0
       rjd += 1721013.5
       rjd -= 0.5*extra/Math.abs(extra)
       rjd += 0.5
       form.result.value = rjd
    }
     // end hiding script from old browsers -->
    </SCRIPT>

  3. #3
    Join Date
    Dec 2008
    Posts
    144

    Re: How to convert a Julian date to regular date and time?

    You can find an algorithm here:
    http://mathforum.org/library/drmath/view/51907.html

    Or see the source code of the page here:
    http://www.onlineconversion.com/julian_date.htm

  4. #4
    Join Date
    Jan 2008
    Posts
    98

    Re: How to convert a Julian date to regular date and time?

    First Thanks for your guys' reply.
    hoxsiew 's reply is about converting regular date to Julian date.
    And
    Nikitozz 's reply http://mathforum.org/library/drmath/view/51907.html
    This algorithm only supply converting Julian date to regular date, but no regular time,
    I'd concern about converting Julian date to regular time too.
    Please!

  5. #5
    Join Date
    Apr 2000
    Location
    Belgium (Europe)
    Posts
    4,626

    Re: How to convert a Julian date to regular date and time?

    If you know the base of the julian date, you can easily convert the float value to a FILETIME structure. Then use the API functions to convert to anything you want.
    FileTimeToSystemTime() would let you convert the FILETIME to a SYSTEMTIME which has the separate date/time components.

  6. #6
    Join Date
    Feb 2005
    Posts
    2,160

    Re: How to convert a Julian date to regular date and time?

    Quote Originally Posted by fantasy1215 View Post
    First Thanks for your guys' reply.
    hoxsiew 's reply is about converting regular date to Julian date.
    The code is very straightforward. I don't know anything about javascript and it seemed obvious to me. I assumed you could figure it out given all the clues in that snippit. If you want someone to write the whole thing for you, hire a freelancer.

  7. #7
    Join Date
    Aug 2008
    Posts
    112

    Re: How to convert a Julian date to regular date and time?

    Quote Originally Posted by hoxsiew View Post
    The code is very straightforward. I don't know anything about javascript and it seemed obvious to me. I assumed you could figure it out given all the clues in that snippit. If you want someone to write the whole thing for you, hire a freelancer.
    If you don't kown anything about javascript, it won't be a problem at all.
    javascript is seeminly a compulsory part to make a complete beautiful website but js software are available out there for free, you need not worry about this.
    Software engineering is about not to reinvent the wheel, we appreciate all library writers who contribute their efforts to making the code nicely. Reverse engineering works out in the same school of thoughts when people need to modify or improve already made "soft copies" !
    Hmmm, If some javascript professional sits around listening to what I am talking, he will envy and get angry soon. But I am glad to be sure of his selfishness for the misconstruction simply over what people could do...
    hi,,,

  8. #8
    Join Date
    May 2002
    Location
    Lindenhurst, NY
    Posts
    867

    Re: How to convert a Julian date to regular date and time?

    Quote Originally Posted by Khiem View Post
    Hmmm, If some javascript professional sits around listening to what I am talking, he will envy and get angry soon.
    Assuming he can actually understand what you're saying.

  9. #9
    Join Date
    Feb 2005
    Posts
    2,160

    Re: How to convert a Julian date to regular date and time?

    I just left it alone. I wasn't sure what he was saying, but it was hardly germane to the topic.

  10. #10
    Join Date
    Jan 2008
    Posts
    98

    Re: How to convert a Julian date to regular date and time?

    Quote Originally Posted by OReubens View Post
    If you know the base of the julian date, you can easily convert the float value to a FILETIME structure. Then use the API functions to convert to anything you want.
    FileTimeToSystemTime() would let you convert the FILETIME to a SYSTEMTIME which has the separate date/time components.
    Hi guys, I really don't understand Julian date well, Will you be kind to show me converting from Julian time to regular time part?

  11. #11
    Join Date
    Apr 2000
    Location
    Belgium (Europe)
    Posts
    4,626

    Re: How to convert a Julian date to regular date and time?

    A 'julian' date is simply a number that counts a number of days (or another timing base, some count seconds, or count milliseconds). And this counts starts at some moment in time.

    If you know what the timing base is, and the starting point, you can easily convert from one julian system to another. FILETIME is a julian system counting 100ns intervals since 1 jan 1601.
    Converting from your format to FILETIME should only be a matter of a multiply or divide and an add. I don't know what your julian system uses as interval or starting point, so can't provide any actual code.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured