亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? time.c

?? * DEFINITION * This a set of math functions that deal with time. The functions accept * 4-digit
?? C
字號:
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 *
 *  Copyright (c) 2007 by Qu chun lei watt@vip.163.com
 *
 *  Filename:  TIME.C
 *  Module:    0404C
 *  Language:  ANSI C
 *  $Revision: 18 $
 *
 *  Math and conversion functions which operate on time values.  For details
 *  see TIME.H.
 *
 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

#ifndef TIME_C
#define TIME_C

/*------------------------*
 |  Include header files
 *------------------------*/

#include "time.h"

/*-------------*
 |  Constants
 *-------------*/

#define TIME_MAX  0xFFFF

/*-------------------------------*
 |  Private function prototypes
 *-------------------------------*/

#if TIME_OF_DAY_ADD || TIME_ADD
static TTime TimeAddMod(TTime t1, TTime t2, UINT8 modulus);
#endif
#if TIME_OF_DAY_SUBTRACT || TIME_SUBTRACT
static TTime TimeSubtractMod(TTime t1, TTime t2, UINT8 modulus);
#endif

#if TIME_OF_DAY_ADD || TIME_ADD || TIME_OF_DAY_SUBTRACT || TIME_SUBTRACT
static TTimeOfDay TimeOfDayCalculate(TTimeOfDay t1, TTime t2, 
    TTimeOfDayFormat tt, BOOLEAN addition);
static TTime TimeCalculate(TTime t1, TTime t2, BOOLEAN addition);
#endif


/*--------------------*
 |  Public functions
 *--------------------*/

/*---------------------------------------------------------------------------*
 |  TimeOfDayAdd
 |
 |  For details see TIME.H
 *---------------------------------------------------------------------------*/

#if TIME_OF_DAY_ADD
TTimeOfDay TimeOfDayAdd(TTimeOfDay t1, TTime t2, TTimeOfDayFormat tt)
{
   return TimeOfDayCalculate(t1, t2, tt, 1);
}
#endif


/*---------------------------------------------------------------------------*
 |  TimeOfDaySubtract
 |
 |  day value.
 |  For details see TIME.H
 *---------------------------------------------------------------------------*/

#if TIME_OF_DAY_SUBTRACT
TTimeOfDay TimeOfDaySubtract(TTimeOfDay t1, TTime t2, TTimeOfDayFormat tt)
{
   return TimeOfDayCalculate(t1, t2, tt, 0);
}
#endif


/*---------------------------------------------------------------------------*
 |  TimeAdd
 |
 |  For details see TIME.H
 *---------------------------------------------------------------------------*/

#if TIME_ADD
TTime TimeAdd(TTime t1, TTime t2)
{
   return TimeCalculate(t1, t2, 1);
}
#endif


/*---------------------------------------------------------------------------*
 |  TimeSubtract
 |
 |  For details see TIME.H
 *---------------------------------------------------------------------------*/

#if TIME_SUBTRACT
TTime TimeSubtract(TTime t1, TTime t2)
{
   return TimeCalculate(t1, t2, 0);
}
#endif


/*---------------------------------------------------------------------------*
 |  TimeCorrectFormat
 |
 |  For details see TIME.H
 *---------------------------------------------------------------------------*/

#if TIME_CORRECT_FORMAT
TTime TimeCorrectFormat(TTime timeValue)
{
   TTime result;
/* bcd digit check */
   if(((timeValue & 0xF000) > 0x9000) || ((timeValue & 0x0F00) > 0x0900) ||
      ((timeValue & 0x00F0) > 0x0090) || ((timeValue & 0x000F) > 0x0009))
   {
      result = TIME_ERROR;
   }
   else
   {   /* if 2 ls digits > 59, subtract 60, add 1 to 2 ms digits */
      if((timeValue & 0x00f0) > 0x0050)
      {
         timeValue -= 0x0060;
         timeValue += 0x0100;
         if((timeValue & 0x0f00) > 0x0900)
         {
            timeValue -= 0x0A00;
            timeValue += 0x1000;
         }
      }

      if((timeValue & 0xFF00) > 0x9900)   /* Check overflow in 2 MSD's */
         result = TIME_ERROR;
      else
         result = timeValue;
   }
   return(result);
}
#endif


/*---------------------------------------------------------------------------*
 |  TimeValid
 |
 |  For details see TIME.H
 *---------------------------------------------------------------------------*/

#if TIME_VALID
BOOLEAN TimeValid(TTime timeValue)
{
   BOOLEAN result;
/* bcd digit check, ls 2 digits must be <= 59 */
   if(((timeValue & 0xF000) > 0x9000) || ((timeValue & 0x0F00) > 0x0900) ||
      ((timeValue & 0x00F0) > 0x0050) || ((timeValue & 0x000F) > 0x0009))
   {
      result = FALSE;
   }
   else
   {
      result = TRUE;
   }

   return(result);
}
#endif


/*---------------------------------------------------------------------------*
 |  TimeOfDayValid
 |
 |  For details see TIME.H
 *---------------------------------------------------------------------------*/

#if TIME_OF_DAY_VALID
BOOLEAN TimeOfDayValid(TTimeOfDay timeValue, TTimeOfDayFormat tt)
{
   BOOLEAN result;
                              /* BCD digit check, ls 2 digits must be <= 59 */
   if(((timeValue & 0xF000) > 0x9000) || ((timeValue & 0x0F00) > 0x0900) ||
      ((timeValue & 0x00F0) > 0x0050) || ((timeValue & 0x000F) > 0x0009))
   {
      result = FALSE;
   }
   else
   {
      timeValue &= 0xFF00;             /* Range check */

      if(tt == TIME_12_HOUR)
      {
         if((timeValue < 0x0100) || (timeValue > 0x1200))
            result = FALSE;
         else
            result = TRUE;
      }
      else
      {
         if(timeValue > 0x2300)
            result = FALSE;
         else
            result = TRUE;
      }
   }

   return(result);
}
#endif


/*---------------------------------------------------------------------------*
 |  TimeToBinary
 |
 |  For details see TIME.H
 *---------------------------------------------------------------------------*/

#if TIME_TO_BINARY
UINT16 TimeToBinary(TTime bcdTime)
{
   UINT16 result;

   result = (bcdTime & 0x000f);
   result += (((bcdTime & 0x00F0)/0x0010)*10);
   result += (((bcdTime & 0x0F00)/0x0100)*60);
   result += (((bcdTime & 0xF000)/0x1000)*600);

   return(result);
}
#endif


/*---------------------------------------------------------------------------*
 |  TimeFromBinary
 |
 |  For details see TIME.H
 *---------------------------------------------------------------------------*/

#if TIME_FROM_BINARY
TTime TimeFromBinary(UINT16 binaryTime)
{
   TTime result;
   UINT16 scratch;

   scratch = binaryTime/600;
   result = (scratch * 0x1000);

   binaryTime -= (scratch * 600);
   scratch = binaryTime/60;
   result += (scratch * 0x0100);

   binaryTime -= (scratch * 60);
   scratch = binaryTime/10;
   result += (scratch * 0x0010);

   binaryTime -= (scratch * 10);
   result += binaryTime;

   return(result);
}
#endif

/*---------------------------------------------------------------------------*
 |  Time12ToBinary
 |
 |  For details see TIME.H
 *---------------------------------------------------------------------------*/

#if TIME_12_TO_BINARY
UINT16 Time12ToBinary(TTime bcdTime)
{
   UINT16 result;

   result = TimeToBinary(bcdTime);
   if(result >= 720)
      result -= 720;

   return(result);
}
#endif


/*---------------------------------------------------------------------------*
 |  Time12FromBinary
 |
 |  For details see TIME.H
 *---------------------------------------------------------------------------*/

#if TIME_12_FROM_BINARY
TTime Time12FromBinary(UINT16 binaryTime)
{
   return TimeFromBinary(binaryTime < 60 ? binaryTime + 720: binaryTime);
}
#endif


/*---------------------*
 |  Private functions
 *---------------------*/

/*---------------------------------------------------------------------------*
 |  TimeAddMod   result = t1 + t2
 |
 |  Add two bcd time values and return a time value.
 |
 |  On Entry:  t1 is the first time value to add
 |             t2 is the second time value to add
 |
 |  On Exit:   Returns the 4-digit sum
 *---------------------------------------------------------------------------*/

#if TIME_OF_DAY_ADD || TIME_ADD
static TTime TimeAddMod(TTime t1, TTime t2, UINT8 modulus)
{
   TTime result;
   UINT16 decimal, carry;
   UINT8 hour1, hour2;

   decimal = (t1 & 0xF) + (t2 & 0xF);        /* Low nibble */
   carry = decimal / 10;
   decimal %= 10;

   result = (t1 & 0xF0) + (t2 & 0xF0) + (carry*0x10);
   carry = result / 0x60;
   result = (result % 0x60) + decimal;       /* Add in low nibble */

   hour1 = (UINT8)(t1/0x100);                         /* Modulus check on high byte */
   hour2 = (UINT8)(t2/0x100);
   decimal = (hour1 & 0xF) + (hour2 & 0xF) + ((hour1/0x10) + (hour2/0x10))*10
            + carry;
   decimal %= modulus;
   result += (decimal % 10 + (decimal / 10) * 0x10)*0x100;

   return result;
}
#endif


/*---------------------------------------------------------------------------*
 |  TimeSubtractMod	result =  t1 - t2
 |
 |  Subtract time from a time  value and return a time value
 |  result = t1 - t2
 |
 |  On Entry:  t1 is the first time value to subtract
 |             t2 is the second time value to subtract
 |
 |  On Exit:   Returns the 4-digit difference
 *---------------------------------------------------------------------------*/

#if TIME_OF_DAY_SUBTRACT || TIME_SUBTRACT
static TTime TimeSubtractMod(TTime t1, TTime t2, UINT8 modulus)
{
   TTime result;
   UINT16 borrow, scratch;

/*-----------*
 |  Minutes
 *-----------*/

   if((result = (t1 & 0xF) - (t2 & 0xF)) > 9)
   {
      borrow = 0x10;
      result += 10;
   }
   else
      borrow = 0;

   if((scratch = (t1 & 0xF0) - (t2 & 0xF0) - borrow) > 0x50)
   {
      scratch += 0x60;
      borrow = 0x100;
   }
   else
      borrow = 0;
   result += scratch;                  /* Result now contains minutes */

/*---------*
 |  Hours
 *---------*/

   scratch =  ((t1&0xF000) / 0x10)*10 + (t1 & 0xF00) - borrow;
   scratch -= ((t2&0xF000) / 0x10)*10 + (t2 & 0xF00);
   while(scratch > (0x100 * modulus))
      scratch += (0x100 * modulus);
   scratch /= 0x100;
   scratch = scratch/10*0x10 + (scratch%10);
   scratch *= 0x100;
   result += scratch;

   return result;
}
#endif


#if TIME_OF_DAY_ADD || TIME_ADD || TIME_OF_DAY_SUBTRACT || TIME_SUBTRACT
/*---------------------------------------------------------------------------*
 |  TimeOfDayCalculate
 |  
 |  Perform math function requested on t1 and t2 and return the result.
 |  If addition then result =  t1 + t2, otherwise result =  t1 - t2
 |
 |  On Entry:  t1 is the first time of day value to calculate
 |             t2 is the second time of day value to calculate
 |
 |  On Exit:   Returns the result in BCD format
 *---------------------------------------------------------------------------*/

static TTimeOfDay TimeOfDayCalculate(TTimeOfDay t1, TTime t2, 
                                     TTimeOfDayFormat tt, BOOLEAN addition)
{
   TTimeOfDay result;
   UINT8 modulus;

   if(TimeOfDayValid(t1, tt) && TimeValid(t2))
   {
      if(tt == TIME_12_HOUR)           /* 1:00-12:00 -> 0:00-11:00 */
      {
         modulus = 12;
         t1 -= 0x0100;
         if((t1 & 0x0F00) > 0x0900)
            t1 -= 0x0600;
      }
      else
         modulus = 24;

      if(addition)
         result = TimeAddMod(t1, t2, modulus);
      else
         result = TimeSubtractMod(t1, t2, modulus);
      
      if(tt == TIME_12_HOUR)           /* 0:00-11:00 -> 1:00-12:00 */
      {
         result += 0x0100;
         if((result & 0x0F00) > 0x0900)
            result += 0x0600;
      }
   }
   else
      result = TIME_ERROR;

   return(result);
}
#endif


#if TIME_OF_DAY_ADD || TIME_ADD || TIME_OF_DAY_SUBTRACT || TIME_SUBTRACT
/*---------------------------------------------------------------------------*
 |  TimeCalculate
 |  
 |  Perform math function requested on t1 and t2 and return the result.
 |  If addition then result =  t1 + t2, otherwise result =  t1 - t2
 |
 |  On Entry:  t1 is the first time value to calculate
 |             t2 is the second time value to calculate
 |
 |  On Exit:   Returns the result in BCD format
 *---------------------------------------------------------------------------*/

static TTime TimeCalculate(TTime t1, TTime t2, BOOLEAN addition)
{
   TTime result;

   if(TimeValid(t1) && TimeValid(t2))
   {
      if(addition)
         result = TimeAddMod(t1, t2, (UINT8) TIME_MAX);
      else
         result = TimeSubtractMod(t1, t2, (UINT8) TIME_MAX);
      if(!TimeValid(result))
         result = TIME_ERROR;
   }
   else
      result = TIME_ERROR;

   return(result);
}
#endif

#endif

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
91国产丝袜在线播放| 五月综合激情婷婷六月色窝| 喷白浆一区二区| 欧美三区在线观看| 一区二区三区在线视频免费 | 国产·精品毛片| 精品国产99国产精品| 日本怡春院一区二区| 欧美年轻男男videosbes| 亚洲欧洲精品成人久久奇米网| 国产精品亚洲视频| 久久午夜电影网| 国产成人精品影视| 国产精品水嫩水嫩| 日本道免费精品一区二区三区| 亚洲欧洲三级电影| 91久久线看在观草草青青| 亚洲一区二区精品久久av| 91福利视频久久久久| 亚洲福利视频三区| 日韩一区二区不卡| 国产一区二区主播在线| 久久久精品人体av艺术| av中文字幕一区| 亚洲一卡二卡三卡四卡五卡| 欧美放荡的少妇| 国产米奇在线777精品观看| 中文字幕久久午夜不卡| 91捆绑美女网站| 亚洲成av人影院在线观看网| 91精品国产一区二区人妖| 偷拍自拍另类欧美| 精品久久久久香蕉网| 国产精品一级片在线观看| 亚洲欧洲一区二区三区| 91 com成人网| 国产剧情一区二区| 亚洲欧美激情一区二区| 日韩三级视频中文字幕| 成人免费av网站| 日日摸夜夜添夜夜添亚洲女人| 久久综合久久鬼色| 日本丰满少妇一区二区三区| 老汉av免费一区二区三区| 成人欧美一区二区三区1314| 欧美精品1区2区| 成人久久视频在线观看| 亚洲福利视频三区| 欧美激情一区二区三区四区| 欧美日韩一区二区三区视频| 国产精品亚洲一区二区三区在线| 一区二区视频在线看| 亚洲精品一区二区三区四区高清| 91网址在线看| 国产精品资源在线看| 亚洲一本大道在线| 国产精品盗摄一区二区三区| 欧美一卡2卡3卡4卡| 日本韩国一区二区三区视频| 国产真实乱对白精彩久久| 亚洲第一综合色| 中文字幕欧美日韩一区| 欧美人动与zoxxxx乱| 99精品热视频| 国产成人日日夜夜| 男人的j进女人的j一区| 一区二区三区中文字幕精品精品| 久久久亚洲国产美女国产盗摄| 欧美午夜电影网| 91丝袜美腿高跟国产极品老师| 激情五月播播久久久精品| 亚洲国产精品自拍| 亚洲美女偷拍久久| 久久综合给合久久狠狠狠97色69| 欧美日韩国产高清一区二区| 91在线无精精品入口| 成人综合日日夜夜| 国产精品一级黄| 美国三级日本三级久久99| 亚洲一区在线视频| 国产清纯白嫩初高生在线观看91 | 日本中文字幕一区二区视频| 亚洲视频一区二区在线| 中文字幕第一区第二区| 国产午夜精品久久久久久久| 欧美成人精品福利| 91麻豆精品国产无毒不卡在线观看| 色综合久久久久综合| av亚洲精华国产精华精华| 国产成人自拍网| 国产成人综合自拍| 国产麻豆欧美日韩一区| 国模冰冰炮一区二区| 国产精品亚洲午夜一区二区三区| 久久超碰97中文字幕| 黄色成人免费在线| 国产毛片精品国产一区二区三区| 国产一区 二区| 国产大陆a不卡| 99久久精品免费| 色综合色综合色综合| 欧美在线制服丝袜| 欧美久久久影院| 日韩女同互慰一区二区| 欧美大片在线观看一区二区| 精品国产91亚洲一区二区三区婷婷| 日韩精品一区二区三区蜜臀| 欧美不卡一区二区| 日韩免费在线观看| 久久久久国产精品人| 国产精品久久久久毛片软件| 亚洲六月丁香色婷婷综合久久 | 国产一区中文字幕| 成人毛片老司机大片| 色噜噜狠狠成人网p站| 欧美色图激情小说| 日韩美一区二区三区| 久久精品网站免费观看| 中文字幕中文字幕在线一区| 亚洲狠狠丁香婷婷综合久久久| 亚洲高清一区二区三区| 久久精工是国产品牌吗| 国产一区二区三区国产| 99久久免费视频.com| 7777精品伊人久久久大香线蕉最新版| 日韩视频在线永久播放| 国产精品三级久久久久三级| 卡一卡二国产精品| 丰满少妇久久久久久久| 精品视频一区二区三区免费| 26uuu久久综合| 一区二区三区在线观看动漫| 麻豆91精品视频| 99久久综合精品| 3d动漫精品啪啪一区二区竹菊| 久久久久国产免费免费 | 亚洲女同女同女同女同女同69| 亚洲图片欧美综合| 国产精品一二三四| 欧美日韩一区二区在线观看视频| 国产午夜亚洲精品不卡 | 亚洲视频综合在线| 美女尤物国产一区| 色乱码一区二区三区88| 精品国产a毛片| 五月天中文字幕一区二区| 成人激情开心网| 精品少妇一区二区三区视频免付费 | 国产精品99久久久久| 欧美视频精品在线| 日本一二三不卡| 狂野欧美性猛交blacked| 91麻豆精东视频| 日本一区二区三区在线观看| 日韩精品国产欧美| 日本电影亚洲天堂一区| 久久久午夜电影| 日本女优在线视频一区二区| 91丝袜美腿高跟国产极品老师 | 国产麻豆精品久久一二三| 欧美日韩激情一区| 最新热久久免费视频| 51久久夜色精品国产麻豆| 最新成人av在线| 国产精品亚洲一区二区三区妖精| 日韩一区二区在线播放| 亚洲一区在线观看免费| 99精品热视频| 国产精品免费看片| 韩国精品久久久| 91精品国产综合久久国产大片| 亚洲一区二区三区在线| 色婷婷综合久久久久中文一区二区 | 成人国产精品视频| 国产亚洲精品久| 成人免费毛片嘿嘿连载视频| 亚洲国产精品ⅴa在线观看| 国产成人99久久亚洲综合精品| 久久久久久影视| 成人激情综合网站| 中文字幕中文字幕在线一区| 91在线免费播放| 怡红院av一区二区三区| 欧美综合色免费| 日韩黄色免费网站| 亚洲精品一区二区精华| 国产二区国产一区在线观看| 中文字幕一区二区三区视频| 91美女蜜桃在线| 天天做天天摸天天爽国产一区| 日韩亚洲欧美成人一区| 国产电影一区二区三区| 中文字幕在线一区二区三区| 欧美性色黄大片| 久久国产综合精品| 国产欧美日韩另类一区| 欧美在线视频日韩| 六月丁香婷婷色狠狠久久| 亚洲国产精品av| 欧美日韩一区二区在线观看|