date conversion issues with last day of year.

Clovertech Forums Read Only Archives Cloverleaf Cloverleaf date conversion issues with last day of year.

  • Creator
    Topic
  • #48348
    Jennifer Johnson
    Participant

      Has anyone written any tcl that converts and calculates a new date accounting for end of year be it a leap year or otherwise?

      I am taking a date, converting it to a julian date, adding a specified amount of days then converting it back. It works fine except for end of year and I’m not sure how to tackle that one.

      Correction. I can make this work during a normal year with 365 days but am not sure how to calculate the leap year with 366 days.

    Viewing 2 reply threads
    • Author
      Replies
      • #58379
        Charlie Bursell
        Participant

          You are making something hard that should be easier.  Read up on the Tcl clock command.  It will do that for you plus take care of leap years, etc.

          For example:

          set dt [clock format [clock scan “10:34:30 PM 3 days”]

        • #58380
          gricelda lopez
          Participant

            I found another way to add the days. Instead of using the julian date I am just adding days to my IF statement. So far it works, it will need to test it out a little more using different dates but it works so far.

                      if [string equal $juliant_day “Fri”] {

                      set dt [clock format [clock scan “3 days”] -format %y%m%d]

                              echo jult date= $dt

                     } elseif [string equal $juliant_day “Sat”] {

                     set dt [clock format [clock scan “2 days”] -format %y%m%d]

                  echo jult date= $dt

                     } else {

            set dt [clock format [clock scan “1 days”] -format %y%m%d]

                              echo jult date= $dt

                         }

          • #58381
            gricelda lopez
            Participant

              Sorry Jennifer, I posted my resolution to your post instead of mine! ah!

          Viewing 2 reply threads
          • The forum ‘Cloverleaf’ is closed to new topics and replies.