Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Birth Yama invalid #111

Open
sengiv opened this issue Jan 29, 2024 · 0 comments
Open

Birth Yama invalid #111

sengiv opened this issue Jan 29, 2024 · 0 comments

Comments

@sengiv
Copy link
Contributor

sengiv commented Jan 29, 2024

馃 having trouble coding "Birth Yama" number
below is the code....anybody got a clue, please chime in 馃檹
(AI has obvious failed me here 馃ぃ)

/// <summary>
/// yama works out to 2 hrs. 24 mts. of our modern time.
/// It is to be noted that the beginning of the day is
/// reckoned from Sun rise to Sun set in Hindu system. Similarly
/// night is reckoned from Sun set to Sun rise on the following
/// day, thus consisting of 24 hours for one day.
/// The timings of the five Yamas are the same during day
/// and night
/// for Pancha Pakshi
/// </summary>
public static BirthYama BirthYama(Time birthTime)
        {
      
            // Extract the time component from the DateTimeOffset
            DateTimeOffset dto = birthTime.GetLmtDateTimeOffset();
            TimeSpan inputTime = dto.TimeOfDay;

            // Parse the start and end times
            var sunriseStd = SunriseTime(birthTime).GetLmtDateTimeOffset();
            TimeSpan start = sunriseStd.TimeOfDay;
            var sunsetStd = SunsetTime(birthTime).GetLmtDateTimeOffset();
            TimeSpan end = sunsetStd.TimeOfDay;

            // Calculate the length of each piece
            //TimeSpan pieceLength = (end - start) / 5;
            TimeSpan pieceLength = TimeSpan.FromHours(2.4);

            // Find out which piece the input time falls under
            for (int i = 0; i < 5; i++)
            {
                TimeSpan yamaStartTime = start + pieceLength * i;
                TimeSpan yamaEndTime = start + pieceLength * (i + 1);

                if (inputTime >= yamaStartTime && inputTime <= yamaEndTime)
                {
                    return new BirthYama(i + 1, yamaStartTime, yamaEndTime);
                }

                Console.WriteLine($"{i + 1} -- {yamaStartTime} -- {yamaEndTime}");
                if (i == 4)
                {
                    Console.WriteLine("last");
                }
            }

            //if reach here than fail!
            //return new BirthYama(1, new TimeSpan(), new TimeSpan());

        }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant