void Lunar2Solar() { long offset; int adj; Date *d; /* A solar day begins at 12 a.m. */ adj = (lunar.hour == 23)? -1 : 0; offset = Lunar2Day(&lunar); solar.weekday = (offset+ adj + SolarFirstDate.weekday) % 7; Day2Solar(offset + adj, &solar); solar.hour = lunar.hour; CalGZ(offset, &lunar, &gan, &zhi); jieAlert = JieDate(&solar, &lunar2); lunar2.day = lunar.day; lunar2.hour = lunar.hour; CalGZ(offset, &lunar2, &gan2, &zhi2); }
void Lunar2Solar(struct LibLunarContext *ctx, SSLunarSimpleDate *lunar) { long offset; int adj; if (ctx == NULL) { fprintf(stderr, "Lunar2Solar: ctx pointer cannot be NULL"); return; } /* A solar day begins at 12 a.m. */ adj = (ctx->_lunar.hour == 23)? -1 : 0; offset = Lunar2Day(ctx, &ctx->_lunar); ctx->_solar.weekday = (offset+ adj + SolarFirstDate.weekday) % 7; Day2Solar(ctx, offset + adj); ctx->_solar.hour = lunar->hour; CalGZ(offset, lunar, &ctx->_gan, &ctx->_zhi); jieAlert = JieDate(&ctx->_solar, &ctx->_lunar2); ctx->_lunar2.day = lunar->day; ctx->_lunar2.hour = lunar->hour; CalGZ(offset, &ctx->_lunar2, &ctx->_gan2, &ctx->_zhi2); }