Jump to content

Mayan calendar: Difference between revisions

m
Minor alteration to coding.
m (Minor code improvements.)
m (Minor alteration to coding.)
Line 310:
const std::vector<std::string> Haab = { "Pop", "Wo'", "Sip", "Sotz'", "Sek", "Xul", "Yaxk'in", "Mol",
"Ch'en", "Yax", "Sak'", "Keh", "Mak", "K'ank'in", "Muwan", "Pax", "K'ayab", "Kumk'u", "Wayeb'" };
 
 
int32_t positive_modulus(const int32_t& base, const int32_t& modulus) {
const int32_t result = base % modulus;
return ( result < 0 ) ? result + modulus : result;
}
 
std::chrono::sys_days create_date(const std::string& iso_date) {
Line 329 ⟶ 335:
std::string tzolkin(const std::chrono::sys_days& gregorian) {
const int32_t days_between = ( gregorian - CREATION_TZOLKIN ).count();
int32_t remainder = positive_modulus(days_between %, 13);
remainder += ( remainder <= 9 ) ? 4 : -9;
int32_treturn indexstd::to_string(remainder) =+ (" " + Tzolkin[positive_modulus(days_between - 1 ) %, 20)];
if ( index < 0 ) {
index += 20;
}
return std::to_string(remainder) + " " + Tzolkin[index];
}
 
std::string haab(const std::chrono::sys_days& gregorian) {
const int32_t days_between = ( gregorian - ZERO_HAAB ).count();
int32_t remainder = positive_modulus(days_between %, 365);
ifconst (std::string month = Haab[positive_modulus(remainder <+ 01, 20) {];
remainder += 365;
}
const std::string month = Haab[ ( remainder + 1 ) / 20 ];
const int32_t day_of_month = remainder % 20 + 1;
return ( day_of_month < days_per_mayan_month(month) ) ?
Line 352 ⟶ 351:
std::string long_count(const std::chrono::sys_days& gregorian) {
int32_t days_between = ( gregorian - CREATION_TZOLKIN ).count() + 13 * 360 * 400;
const int32_t baktun = positive_modulus(days_between / (, 360 * 400 );
days_between = days_between % ( 360 * 400 );
const int32_t katun = days_between / ( 20 * 360 );
894

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.