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

? 歡迎來(lái)到蟲(chóng)蟲(chóng)下載站! | ?? 資源下載 ?? 資源專(zhuān)輯 ?? 關(guān)于我們
? 蟲(chóng)蟲(chóng)下載站

?? date.c

?? sqlite 3.3.8 支持加密的版本
?? C
?? 第 1 頁(yè) / 共 2 頁(yè)
字號(hào):
/*
** 2003 October 31
**
** The author disclaims copyright to this source code.  In place of
** a legal notice, here is a blessing:
**
**    May you do good and not evil.
**    May you find forgiveness for yourself and forgive others.
**    May you share freely, never taking more than you give.
**
*************************************************************************
** This file contains the C functions that implement date and time
** functions for SQLite.  
**
** There is only one exported symbol in this file - the function
** sqlite3RegisterDateTimeFunctions() found at the bottom of the file.
** All other code has file scope.
**
** $Id: date.c,v 1.25 2006/10/12 21:34:21 rmsimpson Exp $
**
** NOTES:
**
** SQLite processes all times and dates as Julian Day numbers.  The
** dates and times are stored as the number of days since noon
** in Greenwich on November 24, 4714 B.C. according to the Gregorian
** calendar system. 
**
** 1970-01-01 00:00:00 is JD 2440587.5
** 2000-01-01 00:00:00 is JD 2451544.5
**
** This implemention requires years to be expressed as a 4-digit number
** which means that only dates between 0000-01-01 and 9999-12-31 can
** be represented, even though julian day numbers allow a much wider
** range of dates.
**
** The Gregorian calendar system is used for all dates and times,
** even those that predate the Gregorian calendar.  Historians usually
** use the Julian calendar for dates prior to 1582-10-15 and for some
** dates afterwards, depending on locale.  Beware of this difference.
**
** The conversion algorithms are implemented based on descriptions
** in the following text:
**
**      Jean Meeus
**      Astronomical Algorithms, 2nd Edition, 1998
**      ISBM 0-943396-61-1
**      Willmann-Bell, Inc
**      Richmond, Virginia (USA)
*/
#include "sqliteInt.h"
#include "os.h"
#include <ctype.h>
#include <stdlib.h>
#include <assert.h>
#include <time.h>

#ifndef SQLITE_OMIT_DATETIME_FUNCS

/*
** A structure for holding a single date and time.
*/
typedef struct DateTime DateTime;
struct DateTime {
  double rJD;      /* The julian day number */
  int Y, M, D;     /* Year, month, and day */
  int h, m;        /* Hour and minutes */
  int tz;          /* Timezone offset in minutes */
  double s;        /* Seconds */
  char validYMD;   /* True if Y,M,D are valid */
  char validHMS;   /* True if h,m,s are valid */
  char validJD;    /* True if rJD is valid */
  char validTZ;    /* True if tz is valid */
};


/*
** Convert zDate into one or more integers.  Additional arguments
** come in groups of 5 as follows:
**
**       N       number of digits in the integer
**       min     minimum allowed value of the integer
**       max     maximum allowed value of the integer
**       nextC   first character after the integer
**       pVal    where to write the integers value.
**
** Conversions continue until one with nextC==0 is encountered.
** The function returns the number of successful conversions.
*/
static int getDigits(const char *zDate, ...){
  va_list ap;
  int val;
  int N;
  int min;
  int max;
  int nextC;
  int *pVal;
  int cnt = 0;
  va_start(ap, zDate);
  do{
    N = va_arg(ap, int);
    min = va_arg(ap, int);
    max = va_arg(ap, int);
    nextC = va_arg(ap, int);
    pVal = va_arg(ap, int*);
    val = 0;
    while( N-- ){
      if( !isdigit(*(u8*)zDate) ){
        goto end_getDigits;
      }
      val = val*10 + *zDate - '0';
      zDate++;
    }
    if( val<min || val>max || (nextC!=0 && nextC!=*zDate) ){
      goto end_getDigits;
    }
    *pVal = val;
    zDate++;
    cnt++;
  }while( nextC );
end_getDigits:
  va_end(ap);
  return cnt;
}

/*
** Read text from z[] and convert into a floating point number.  Return
** the number of digits converted.
*/
#define getValue sqlite3AtoF

/*
** Parse a timezone extension on the end of a date-time.
** The extension is of the form:
**
**        (+/-)HH:MM
**
** If the parse is successful, write the number of minutes
** of change in *pnMin and return 0.  If a parser error occurs,
** return 0.
**
** A missing specifier is not considered an error.
*/
static int parseTimezone(const char *zDate, DateTime *p){
  int sgn = 0;
  int nHr, nMn;
  while( isspace(*(u8*)zDate) ){ zDate++; }
  p->tz = 0;
  if( *zDate=='-' ){
    sgn = -1;
  }else if( *zDate=='+' ){
    sgn = +1;
  }else{
    return *zDate!=0;
  }
  zDate++;
  if( getDigits(zDate, 2, 0, 14, ':', &nHr, 2, 0, 59, 0, &nMn)!=2 ){
    return 1;
  }
  zDate += 5;
  p->tz = sgn*(nMn + nHr*60);
  while( isspace(*(u8*)zDate) ){ zDate++; }
  return *zDate!=0;
}

/*
** Parse times of the form HH:MM or HH:MM:SS or HH:MM:SS.FFFF.
** The HH, MM, and SS must each be exactly 2 digits.  The
** fractional seconds FFFF can be one or more digits.
**
** Return 1 if there is a parsing error and 0 on success.
*/
static int parseHhMmSs(const char *zDate, DateTime *p){
  int h, m, s;
  double ms = 0.0;
  if( getDigits(zDate, 2, 0, 24, ':', &h, 2, 0, 59, 0, &m)!=2 ){
    return 1;
  }
  zDate += 5;
  if( *zDate==':' ){
    zDate++;
    if( getDigits(zDate, 2, 0, 59, 0, &s)!=1 ){
      return 1;
    }
    zDate += 2;
    if( *zDate=='.' && isdigit((u8)zDate[1]) ){
      double rScale = 1.0;
      zDate++;
      while( isdigit(*(u8*)zDate) ){
        ms = ms*10.0 + *zDate - '0';
        rScale *= 10.0;
        zDate++;
      }
      ms /= rScale;
    }
  }else{
    s = 0;
  }
  p->validJD = 0;
  p->validHMS = 1;
  p->h = h;
  p->m = m;
  p->s = s + ms;
  if( parseTimezone(zDate, p) ) return 1;
  p->validTZ = p->tz!=0;
  return 0;
}

/*
** Convert from YYYY-MM-DD HH:MM:SS to julian day.  We always assume
** that the YYYY-MM-DD is according to the Gregorian calendar.
**
** Reference:  Meeus page 61
*/
static void computeJD(DateTime *p){
  int Y, M, D, A, B, X1, X2;

  if( p->validJD ) return;
  if( p->validYMD ){
    Y = p->Y;
    M = p->M;
    D = p->D;
  }else{
    Y = 2000;  /* If no YMD specified, assume 2000-Jan-01 */
    M = 1;
    D = 1;
  }
  if( M<=2 ){
    Y--;
    M += 12;
  }
  A = Y/100;
  B = 2 - A + (A/4);
  X1 = 365.25*(Y+4716);
  X2 = 30.6001*(M+1);
  p->rJD = X1 + X2 + D + B - 1524.5;
  p->validJD = 1;
  if( p->validHMS ){
    p->rJD += (p->h*3600.0 + p->m*60.0 + p->s)/86400.0;
    if( p->validTZ ){
      p->rJD -= p->tz*60/86400.0;
      p->validYMD = 0;
      p->validHMS = 0;
      p->validTZ = 0;
    }
  }
}

/*
** Parse dates of the form
**
**     YYYY-MM-DD HH:MM:SS.FFF
**     YYYY-MM-DD HH:MM:SS
**     YYYY-MM-DD HH:MM
**     YYYY-MM-DD
**
** Write the result into the DateTime structure and return 0
** on success and 1 if the input string is not a well-formed
** date.
*/
static int parseYyyyMmDd(const char *zDate, DateTime *p){
  int Y, M, D, neg;

  if( zDate[0]=='-' ){
    zDate++;
    neg = 1;
  }else{
    neg = 0;
  }
  if( getDigits(zDate,4,0,9999,'-',&Y,2,1,12,'-',&M,2,1,31,0,&D)!=3 ){
    return 1;
  }
  zDate += 10;
  while( isspace(*(u8*)zDate) || 'T'==*(u8*)zDate ){ zDate++; }
  if( parseHhMmSs(zDate, p)==0 ){
    /* We got the time */
  }else if( *zDate==0 ){
    p->validHMS = 0;
  }else{
    return 1;
  }
  p->validJD = 0;
  p->validYMD = 1;
  p->Y = neg ? -Y : Y;
  p->M = M;
  p->D = D;
  if( p->validTZ ){
    computeJD(p);
  }
  return 0;
}

/*
** Attempt to parse the given string into a Julian Day Number.  Return
** the number of errors.
**
** The following are acceptable forms for the input string:
**
**      YYYY-MM-DD HH:MM:SS.FFF  +/-HH:MM
**      DDDD.DD 
**      now
**
** In the first form, the +/-HH:MM is always optional.  The fractional
** seconds extension (the ".FFF") is optional.  The seconds portion
** (":SS.FFF") is option.  The year and date can be omitted as long
** as there is a time string.  The time string can be omitted as long
** as there is a year and date.
*/
static int parseDateOrTime(const char *zDate, DateTime *p){
  memset(p, 0, sizeof(*p));
  if( parseYyyyMmDd(zDate,p)==0 ){
    return 0;
  }else if( parseHhMmSs(zDate, p)==0 ){
    return 0;
  }else if( sqlite3StrICmp(zDate,"now")==0){
    double r;
    sqlite3OsCurrentTime(&r);
    p->rJD = r;
    p->validJD = 1;
    return 0;
  }else if( sqlite3IsNumber(zDate, 0, SQLITE_UTF8) ){
    getValue(zDate, &p->rJD);
    p->validJD = 1;
    return 0;
  }
  return 1;
}

/*
** Compute the Year, Month, and Day from the julian day number.
*/
static void computeYMD(DateTime *p){
  int Z, A, B, C, D, E, X1;
  if( p->validYMD ) return;
  if( !p->validJD ){
    p->Y = 2000;
    p->M = 1;
    p->D = 1;
  }else{
    Z = p->rJD + 0.5;
    A = (Z - 1867216.25)/36524.25;
    A = Z + 1 + A - (A/4);
    B = A + 1524;
    C = (B - 122.1)/365.25;
    D = 365.25*C;
    E = (B-D)/30.6001;
    X1 = 30.6001*E;
    p->D = B - D - X1;
    p->M = E<14 ? E-1 : E-13;
    p->Y = p->M>2 ? C - 4716 : C - 4715;
  }
  p->validYMD = 1;
}

/*
** Compute the Hour, Minute, and Seconds from the julian day number.
*/
static void computeHMS(DateTime *p){
  int Z, s;
  if( p->validHMS ) return;
  computeJD(p);
  Z = p->rJD + 0.5;
  s = (p->rJD + 0.5 - Z)*86400000.0 + 0.5;
  p->s = 0.001*s;
  s = p->s;
  p->s -= s;
  p->h = s/3600;
  s -= p->h*3600;
  p->m = s/60;
  p->s += s - p->m*60;
  p->validHMS = 1;
}

/*
** Compute both YMD and HMS
*/
static void computeYMD_HMS(DateTime *p){
  computeYMD(p);
  computeHMS(p);
}

/*
** Clear the YMD and HMS and the TZ
*/
static void clearYMD_HMS_TZ(DateTime *p){
  p->validYMD = 0;
  p->validHMS = 0;
  p->validTZ = 0;
}

/*
** Compute the difference (in days) between localtime and UTC (a.k.a. GMT)
** for the time value p where p is in UTC.
*/
static double localtimeOffset(DateTime *p){
  DateTime x, y;
  time_t t;
  x = *p;
  computeYMD_HMS(&x);
  if( x.Y<1971 || x.Y>=2038 ){
    x.Y = 2000;
    x.M = 1;
    x.D = 1;
    x.h = 0;
    x.m = 0;
    x.s = 0.0;
  } else {
    int s = x.s + 0.5;
    x.s = s;
  }
  x.tz = 0;
  x.validJD = 0;
  computeJD(&x);
  t = (x.rJD-2440587.5)*86400.0 + 0.5;
#ifdef HAVE_LOCALTIME_R
  {
    struct tm sLocal;
    localtime_r(&t, &sLocal);
    y.Y = sLocal.tm_year + 1900;
    y.M = sLocal.tm_mon + 1;
    y.D = sLocal.tm_mday;
    y.h = sLocal.tm_hour;
    y.m = sLocal.tm_min;
    y.s = sLocal.tm_sec;
  }
#else
  {
    struct tm *pTm;
    sqlite3OsEnterMutex();
    pTm = localtime(&t);
    y.Y = pTm->tm_year + 1900;
    y.M = pTm->tm_mon + 1;
    y.D = pTm->tm_mday;
    y.h = pTm->tm_hour;
    y.m = pTm->tm_min;
    y.s = pTm->tm_sec;
    sqlite3OsLeaveMutex();
  }
#endif
  y.validYMD = 1;
  y.validHMS = 1;
  y.validJD = 0;
  y.validTZ = 0;
  computeJD(&y);
  return y.rJD - x.rJD;
}

/*
** Process a modifier to a date-time stamp.  The modifiers are
** as follows:
**
**     NNN days
**     NNN hours
**     NNN minutes
**     NNN.NNNN seconds
**     NNN months
**     NNN years
**     start of month
**     start of year
**     start of week
**     start of day
**     weekday N
**     unixepoch
**     localtime
**     utc
**
** Return 0 on success and 1 if there is any kind of error.
*/
static int parseModifier(const char *zMod, DateTime *p){
  int rc = 1;
  int n;
  double r;
  char *z, zBuf[30];
  z = zBuf;
  for(n=0; n<sizeof(zBuf)-1 && zMod[n]; n++){
    z[n] = tolower(zMod[n]);
  }
  z[n] = 0;
  switch( z[0] ){
    case 'l': {
      /*    localtime
      **
      ** Assuming the current time value is UTC (a.k.a. GMT), shift it to
      ** show local time.
      */
      if( strcmp(z, "localtime")==0 ){
        computeJD(p);
        p->rJD += localtimeOffset(p);
        clearYMD_HMS_TZ(p);
        rc = 0;
      }
      break;
    }
    case 'u': {
      /*
      **    unixepoch
      **
      ** Treat the current value of p->rJD as the number of
      ** seconds since 1970.  Convert to a real julian day number.
      */
      if( strcmp(z, "unixepoch")==0 && p->validJD ){
        p->rJD = p->rJD/86400.0 + 2440587.5;
        clearYMD_HMS_TZ(p);
        rc = 0;
      }else if( strcmp(z, "utc")==0 ){
        double c1;
        computeJD(p);
        c1 = localtimeOffset(p);
        p->rJD -= c1;
        clearYMD_HMS_TZ(p);
        p->rJD += c1 - localtimeOffset(p);
        rc = 0;
      }
      break;
    }

?? 快捷鍵說(shuō)明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
精品久久久久久亚洲综合网| 看电影不卡的网站| 亚洲日本va午夜在线电影| 欧美极品美女视频| 国产丝袜美腿一区二区三区| 久久综合九色综合97婷婷女人| 欧美一卡二卡三卡四卡| 91麻豆精品国产91久久久更新时间 | 国产午夜精品美女毛片视频| 久久品道一品道久久精品| 国产日韩欧美综合一区| 中文一区二区完整视频在线观看| 国产欧美日韩麻豆91| 国产精品高潮久久久久无| 综合电影一区二区三区 | 亚洲精品乱码久久久久久久久 | 成人高清视频免费观看| 成人三级在线视频| 91在线高清观看| 欧美日韩中文字幕一区| 欧美一级二级在线观看| 亚洲精品在线电影| 欧美国产日韩在线观看| 亚洲黄色小说网站| 五月综合激情网| 久久精品免费观看| 成人高清视频在线观看| 在线亚洲+欧美+日本专区| 制服丝袜亚洲精品中文字幕| 日韩欧美激情四射| 中文字幕乱码一区二区免费| 亚洲人成亚洲人成在线观看图片| 洋洋av久久久久久久一区| 日本亚洲电影天堂| 国产一区二区导航在线播放| 91美女片黄在线观看91美女| 欧美精品久久99久久在免费线 | 免费成人美女在线观看.| 国产精品综合二区| 色综合久久综合| 欧美一区二区三区播放老司机| 久久久午夜精品理论片中文字幕| 中文字幕制服丝袜成人av| 一区二区欧美精品| 狠狠久久亚洲欧美| 在线亚洲人成电影网站色www| 日韩欧美一二区| 亚洲视频免费在线| 精品亚洲porn| 在线免费亚洲电影| 久久综合中文字幕| 亚洲电影在线播放| 从欧美一区二区三区| 欧美日韩一区二区不卡| 国产亚洲一区二区三区四区| 亚洲一区av在线| 从欧美一区二区三区| 91精品国产美女浴室洗澡无遮挡| 国产精品精品国产色婷婷| 日韩精品电影一区亚洲| www.av精品| 久久综合九色综合欧美就去吻 | 欧美在线观看视频在线| 国产丝袜美腿一区二区三区| 日本午夜一本久久久综合| 成人ar影院免费观看视频| 日韩精品中文字幕一区二区三区 | 国产成人精品一区二区三区网站观看| 欧美性猛交xxxx乱大交退制版| 日本一区二区免费在线| 免费亚洲电影在线| 欧美亚洲自拍偷拍| 国产精品丝袜一区| 国模无码大尺度一区二区三区| 欧美视频一区二区三区| 成人欧美一区二区三区视频网页| 久久99国产精品久久99果冻传媒| 欧美色综合网站| 亚洲黄色性网站| www.99精品| 国产欧美日韩不卡| 国产精品一区二区x88av| 91麻豆精品国产| 五月天中文字幕一区二区| 91免费视频网| 亚洲欧洲av在线| 成人夜色视频网站在线观看| 天天亚洲美女在线视频| 91影院在线观看| 中文字幕在线不卡一区| 国产成人在线影院| 精品国产乱码久久久久久夜甘婷婷| 五月激情六月综合| 欧美午夜电影一区| 亚洲一区二区精品视频| 在线免费精品视频| 亚洲一区二区中文在线| 91黄色免费版| 亚洲一二三区在线观看| 在线精品视频一区二区三四 | 大胆欧美人体老妇| 中文字幕精品一区二区三区精品| 国产福利91精品一区二区三区| 欧美不卡在线视频| 精品在线观看视频| 2020国产精品久久精品美国| 国产精一品亚洲二区在线视频| 久久免费偷拍视频| 粉嫩av亚洲一区二区图片| 日本一区二区在线不卡| 成人激情午夜影院| 一区二区三区中文免费| 在线观看欧美黄色| 视频一区二区三区入口| 欧美一区二区三级| 国产一区二三区| 国产精品网站在线播放| 成人激情开心网| 一区二区久久久久| 欧美丰满美乳xxx高潮www| 蜜臀久久99精品久久久画质超高清 | 欧美三级视频在线播放| 日韩av一区二区在线影视| 日韩精品高清不卡| 欧美不卡在线视频| 成人激情黄色小说| 亚洲一区二区三区视频在线播放| 欧美日本一道本在线视频| 另类欧美日韩国产在线| 国产精品视频一二三| 一本大道av一区二区在线播放| 亚洲综合在线五月| 日韩三级视频在线观看| 国产精品亚洲一区二区三区在线 | 国产在线精品免费| 中文字幕中文在线不卡住| 欧美日韩一区二区三区四区五区| 久久精品免费看| 国产精品久久久一本精品| 在线观看成人免费视频| 麻豆精品在线看| 国产精品亲子伦对白| 欧美在线999| 激情综合色丁香一区二区| 日本一区二区三区在线观看| 欧美熟乱第一页| 国产精品资源网站| 亚洲曰韩产成在线| 久久一日本道色综合| 91麻豆国产福利在线观看| 日本女优在线视频一区二区| 日本一二三不卡| 666欧美在线视频| 成人动漫视频在线| 青青草国产成人av片免费| 国产精品传媒入口麻豆| 日韩欧美亚洲国产另类| 91久久线看在观草草青青| 韩国女主播成人在线| 亚洲自拍都市欧美小说| 国产精品入口麻豆原神| 午夜精品福利视频网站| 国产精品天美传媒| 日韩欧美精品在线视频| 欧美体内she精视频| 国产不卡视频一区二区三区| 美女www一区二区| 亚洲欧美日韩成人高清在线一区| 精品国产乱码久久久久久久| 在线视频一区二区三区| 福利一区二区在线| 蜜桃av一区二区在线观看| 亚洲一区免费视频| 国产精品卡一卡二| 精品国产露脸精彩对白| 欧美色老头old∨ideo| 93久久精品日日躁夜夜躁欧美| 日本vs亚洲vs韩国一区三区二区| 亚洲另类中文字| 国产日产精品1区| 日韩一区二区高清| 欧美日韩精品免费观看视频| 91香蕉视频在线| 大尺度一区二区| 国产剧情在线观看一区二区| 日韩福利电影在线| 亚洲一区二区精品视频| 一区二区三区四区不卡在线 | 欧美日韩小视频| 91污在线观看| av一二三不卡影片| 成人毛片视频在线观看| 国产精品18久久久久久久网站| 男女性色大片免费观看一区二区| 亚洲国产美女搞黄色| 一区二区三区在线播放| 一区二区三区四区高清精品免费观看 | 欧美精品一二三四| 欧美亚洲自拍偷拍| 在线观看亚洲a|