Example #1
0
void Solar2Lunar(struct LibLunarContext *ctx,
                 SSLunarSimpleDate *solar)
{
    
    long offset;
    
    if (ctx == NULL) {
        fprintf(stderr, "Soloar2Lunar: ctx pointer cannot be NULL");
        return;
    }

    if (!libLunarCheckYearRange(solar->year)) {
            fprintf(stderr, "Solar2Lunar: the year provide exceeds lib's ablility.");
            return;
    }
            
    
    offset = Solar2Day(solar);
    solar->weekday = (offset + SolarFirstDate.weekday) % 7;
    
    /* A lunar day begins at 11 p.m. */
    if (solar->hour == 23)
        offset++;
    
    Day2Lunar(ctx, offset);
    ctx->_lunar.hour = solar->hour;
    CalGZ(offset, &ctx->_lunar, &ctx->_gan, &ctx->_zhi);
    
    jieAlert = JieDate(solar, &ctx->_lunar2);
    ctx->_lunar2.day = ctx->_lunar.day;
    ctx->_lunar2.hour = ctx->_lunar.hour;
    CalGZ(offset, &ctx->_lunar2, &ctx->_gan2, &ctx->_zhi2);
}
Example #2
0
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);
}
Example #3
0
void Solar2Lunar()
{

    long offset;
    Date *d;

    offset = Solar2Day(&solar);
    solar.weekday = (offset + SolarFirstDate.weekday) % 7;

    /* A lunar day begins at 11 p.m. */
    if (solar.hour == 23)
        offset++;

    Day2Lunar(offset, &lunar);
    lunar.hour = solar.hour;
    CalGZ(offset, &lunar, &gan, &zhi);

    jieAlert = JieDate(&solar, &lunar2);
    lunar2.day = lunar.day;
    lunar2.hour = lunar.hour;
    CalGZ(offset, &lunar2, &gan2, &zhi2);
}
Example #4
0
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);
}