随笔 - 25, 文章 - 0, 评论 - 6, 引用 - 0
数据加载中……

获取农历年、时辰


void CCalendar::FormatLunarYear(WORD iYear, char* pBuffer)
{    
    char szText1[] = "甲乙丙丁戊己庚辛壬癸";
    char szText2[] = "子丑寅卯辰巳午未申酉戌亥";
    char szText3[] = "鼠牛虎免龙蛇马羊猴鸡狗猪";

    memcpy(pBuffer,   szText1+((iYear-4)%10)*2, 2);
    memcpy(pBuffer+2, szText2+((iYear-4)%12)*2, 2);
    pBuffer[4]=' ';
    memcpy(pBuffer+5, szText3+((iYear-4)%12)*2, 2);
    strcpy(pBuffer+7, "年");
}

void CCalendar::FormatLunarHour(WORD iHour, char *pBuffer)
{
    char szText[] = "子丑寅卯辰巳午未申酉戌亥";
    int nIndex = (iHour + 1) / 2;
    if (12 == nIndex && 23 == iHour)
    {
        nIndex = 0;
    }
    memcpy(pBuffer, szText+nIndex*2, 2);
    strcpy(pBuffer+2, "时");
}

posted on 2014-08-26 23:28 chenjt3533 阅读(232) 评论(0)  编辑 收藏 引用 所属分类: C/C++


只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理