Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Julian date

Julian date

Scheduled Pinned Locked Moved C / C++ / MFC
c++
11 Posts 6 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Vijjuuu

    Hi all , is there any function that converts this string str = "23/02/09 14:44:13" to julian date format in C or C++ . thanks in advance .

    CPalliniC Offline
    CPalliniC Offline
    CPallini
    wrote on last edited by
    #2

    Vijjuuuuuuuuu........... wrote:

    is there any function that converts this string str = "23/02/09 14:44:13" to julian date format in C or C++ .

    Yes (and it possibly returns 09034 for your input). :rolleyes:

    If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
    This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
    [My articles]

    In testa che avete, signor di Ceprano?

    V 1 Reply Last reply
    0
    • CPalliniC CPallini

      Vijjuuuuuuuuu........... wrote:

      is there any function that converts this string str = "23/02/09 14:44:13" to julian date format in C or C++ .

      Yes (and it possibly returns 09034 for your input). :rolleyes:

      If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
      This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
      [My articles]

      V Offline
      V Offline
      Vijjuuu
      wrote on last edited by
      #3

      Thanks for the reply , but is there any function to do that ?

      CPalliniC K 2 Replies Last reply
      0
      • V Vijjuuu

        Thanks for the reply , but is there any function to do that ?

        CPalliniC Offline
        CPalliniC Offline
        CPallini
        wrote on last edited by
        #4

        You can roll your own one. What are your doubts while doing that? I recall for you the needed steps (if you aren't using MFC or ATL). You have to:

        1. Parse the string to obtain day-of-month, month and year from the string.
        2. Convert day-of-month and month to day-of-year.
        3. Align properly year and day-of-year values in the resulting number.

        In the above task, only point(2) is a bit tricky because of leap years. Using MFC or ATL would make your life easier.

        If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
        This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
        [My articles]

        modified on Monday, February 23, 2009 4:11 AM

        In testa che avete, signor di Ceprano?

        1 Reply Last reply
        0
        • V Vijjuuu

          Hi all , is there any function that converts this string str = "23/02/09 14:44:13" to julian date format in C or C++ . thanks in advance .

          G Offline
          G Offline
          Garth J Lancaster
          wrote on last edited by
          #5

          it depends on what you mean by julian date - since the term is most often miss-used these days. If you mean 'the day number as a number starting counting from the 1st of Jan in the Current year', then you need to follow the advice of our trusted and esteemed colleague CPallini If you mean since an arbitrary point in time - such as is used by astronomers etc, ie 4713BC, then, part one of CPallini's response still applies, then you feed the results of the parse into something like :- http://www.silverglass.org/code/Date.html[^] 'g'

          V 1 Reply Last reply
          0
          • V Vijjuuu

            Hi all , is there any function that converts this string str = "23/02/09 14:44:13" to julian date format in C or C++ . thanks in advance .

            S Offline
            S Offline
            Stephen Hewitt
            wrote on last edited by
            #6

            One possible solution is to use Boost[^]'s Date_Time[^] library.

            Steve

            V 1 Reply Last reply
            0
            • V Vijjuuu

              Hi all , is there any function that converts this string str = "23/02/09 14:44:13" to julian date format in C or C++ . thanks in advance .

              D Offline
              D Offline
              David Crow
              wrote on last edited by
              #7

              Vijjuuuuuuuuu........... wrote:

              ...to julian date...

              Which one?

              "Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown

              "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

              1 Reply Last reply
              0
              • V Vijjuuu

                Thanks for the reply , but is there any function to do that ?

                K Offline
                K Offline
                ky_rerun
                wrote on last edited by
                #8

                just use scansf grab the constituent parts and throw it into a SYSTEMTIME struct. Just rember that scanf assumes int * and the systemtime struct is all word size objects.


                a programmer traped in a thugs body

                K 1 Reply Last reply
                0
                • K ky_rerun

                  just use scansf grab the constituent parts and throw it into a SYSTEMTIME struct. Just rember that scanf assumes int * and the systemtime struct is all word size objects.


                  a programmer traped in a thugs body

                  K Offline
                  K Offline
                  ky_rerun
                  wrote on last edited by
                  #9

                  DWORD Month,Day,Year,Hour,Minute,Second; //Initalize the values and the structure to zero Month = Day = Year = Hour = Minute = Second = 0; memset(&ST,0,sizeof(ST)); //Fix This use the stram reader so I can read the write size //Parse out the date with sscanf sscanf_s(Val.c_str(),"%d/%d/%d %d:%d:%d ",&Day,&Month,&Year,&Hour,&Minute, &Second); //reassign the values into the structure ST.wDay = (WORD) Day ; ST.wMonth = (WORD) Month ; ST.wYear = (WORD) Year ; ST.wHour = (WORD) Hour ; ST.wSecond = (WORD) Second; ST.wMinute = (WORD) Minute;


                  a programmer traped in a thugs body

                  1 Reply Last reply
                  0
                  • G Garth J Lancaster

                    it depends on what you mean by julian date - since the term is most often miss-used these days. If you mean 'the day number as a number starting counting from the 1st of Jan in the Current year', then you need to follow the advice of our trusted and esteemed colleague CPallini If you mean since an arbitrary point in time - such as is used by astronomers etc, ie 4713BC, then, part one of CPallini's response still applies, then you feed the results of the parse into something like :- http://www.silverglass.org/code/Date.html[^] 'g'

                    V Offline
                    V Offline
                    Vijjuuu
                    wrote on last edited by
                    #10

                    Thanks for replying me :)

                    1 Reply Last reply
                    0
                    • S Stephen Hewitt

                      One possible solution is to use Boost[^]'s Date_Time[^] library.

                      Steve

                      V Offline
                      V Offline
                      Vijjuuu
                      wrote on last edited by
                      #11

                      Thanks for replying me

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups