DateTime::Event::SolarTermDateTime Extension to Calculate Solar Terms | |
Download |
DateTime::Event::SolarTerm Ranking & Summary
Advertisement
- License:
- Perl Artistic License
- Price:
- FREE
- Publisher Name:
- Daisuke Maki
- Publisher web site:
- http://search.cpan.org/~dmaki/
DateTime::Event::SolarTerm Tags
DateTime::Event::SolarTerm Description
DateTime Extension to Calculate Solar Terms A lunar calendar has months based on the lunar cycle, which is approximately 29.5 days. This cycle does not match the cycle of the Sun, which is about 365 days.You can use leap months to better align the cycle as in the Chinese calendar, but that still means that months could be off by possibly one lunar month. This was unacceptable for agricultural purposes which is linked deeply with the season, which in turn is linked with the solar cycle.This is where solar terms are used. Regardless of what lunar month it is, you can tell the season using the solar terms.Solar terms are still used in some parts of Asia, especially China, where major holidays must be calculated based on these solar terms.SYNOPSIS use DateTime::Event::SolarTerm; my $major_term = DateTime::Event::SolarTerm->major_term(); my $dt0 = DateTime->new(...); my $next_major_term = $major_term->next($dt0); my $prev_major_term = $major_term->previous($dt0); my $dt1 = DateTime->new(...); my $dt2 = DateTime->new(...); my $span = DateTime::Span->new(start => $dt1, end => $dt2); my $set = $major_term->intersection($span); my $iter = $set->iterator(); while (my $dt = $iter->next) { print $dt->datetime, " "; } my $minor_term = DateTime::Event::SolarTerm->minor_term(); my $dt0 = DateTime->new(...); my $next_minor_term = $minor_term->next($dt0); my $prev_minor_term = $minor_term->previous($dt0); my $dt1 = DateTime->new(...); my $dt2 = DateTime->new(...); my $span = DateTime::Span->new(start => $dt1, end => $dt2); my $set = $minor_term->intersection($span); my $iter = $set->iterator(); while (my $dt = $iter->next) { print $dt->datetime, " "; } # if you just want to calculate a single major/minor term event my $dt = DateTime::Event::Lunar->major_term_after(datetime => $dt0); my $dt = DateTime::Event::Lunar->major_term_before(datetime => $dt0); my $dt = DateTime::Event::Lunar->minor_term_after(datetime => $dt0); my $dt = DateTime::Event::Lunar->minor_term_before(datetime => $dt0); my $index = DateTime::Event::SolarTerm->last_major_term_index(datetime => $dt); my $index = DateTime::Event::SolarTerm->last_minor_term_index(datetime => $dt); my $boolean = DateTime::Event::SolarTerm->no_major_term_on(datetime => $dt); # to get the next specific solar term use DateTime::Event::SolarTerm qw(DONGZHI); my $next = DateTime::Event::SolarTerm->next_term_at( datetime => $dt, longitude => DONGZHI ); my $prev = DateTime::Event::SolarTerm->prev_term_at( datetime => $dt, longitude => DONGZHI ); Requirements: · Perl
DateTime::Event::SolarTerm Related Software