Git Product home page Git Product logo

Comments (4)

erajasekar avatar erajasekar commented on July 30, 2024

Finding start time of thithi should be very similar to calculating end. But the end time previous thithi will already give you start time of current thithi. So based on order of thithi's you can easily find starttime from end time of thithi.

from astrosoft.

sushiljic avatar sushiljic commented on July 30, 2024

I have tried the second approach,
Tracing the end time of previous thithi,i go to the previous day but i got into problems like
case 1. Some day, there might be elapse of thithi for eg
on 20th Dec,2018, current thithi is Thraiyodasi and its previous thithi must be Dwadasi but on sunrise,
it has Ekadasi.
case 2. Some time thithi can elongate upto 2 days, for that i might go back to again one day.
Below is the working code that i perform to find the thithi start.
But i thought if there would be some easy way to find start of thithi that would be very helpful.

    /*
    * calculate thithi starting date
    * */
    GregorianCalendar calStepperForDayBefore = (GregorianCalendar) currentDate.clone();
    while(panchangAtSunrise.getThithi().getStarting() == 0d){

        calStepperForDayBefore.add(Calendar.DAY_OF_MONTH,-1);
        calStepperForDayBefore = AstroUtil.atHourMinuteSecond(
                calStepperForDayBefore,
                AstroUtil.getSunRise(calStepperForDayBefore,place),
                false);

        Panchang panAtDayBefore = new Panchang(calStepperForDayBefore,person);

        if( panchangAtSunrise.getThithi().getThithi().getPreviousThithi() == panAtDayBefore.getThithi().getThithi() ){
            panchangAtSunrise.getThithi().setStarting(panAtDayBefore.getThithi().getEnding());
            panchangAtSunrise.getThithi().setStartingDate(panAtDayBefore.getThithi().getEndingDate());
        }
        else if(panchangAtSunrise.getThithi().getThithi().getPreviousThithi().getPreviousThithi() == panAtDayBefore.getThithi().getThithi()){
            // on DayBefore, there was two thithi
            // find panchang at end of that thithi
            double atDayBeforeAtThithiEnd = panAtDayBefore.getThithi().getEnding();
            GregorianCalendar atDayBeforeAtThithiEndCal = AstroUtil.atHourMinuteSecond(calStepperForDayBefore, atDayBeforeAtThithiEnd,true);
            Panchang panAtDayBeforeAtThithiEnd = new Panchang(
                    atDayBeforeAtThithiEndCal,
                    person);
            if(panAtDayBeforeAtThithiEnd.getThithi().getThithi() ==
                    panchangAtSunrise.getThithi().getThithi().getPreviousThithi()){
                panchangAtSunrise.getThithi().setStarting(panAtDayBeforeAtThithiEnd.getThithi().getEnding());
                panchangAtSunrise.getThithi().setStartingDate(panAtDayBeforeAtThithiEnd.getThithi().getEndingDate());
            }
            else{
                System.out.println("Should never happen");
            }
        }
    }

from astrosoft.

erajasekar avatar erajasekar commented on July 30, 2024

It's been several years since I worked on this code. So I don't remember all the calculation details to comment on it. Glad that you figured out some working solution.

from astrosoft.

sushiljic avatar sushiljic commented on July 30, 2024

Okay then let me close this issue
and if any better solution come up
it will post here.

from astrosoft.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.