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

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

?? dateops.cpp

?? This is a pgm can be used for astronomy
?? CPP
字號:
/*****************************************************************************\
 * DateOps.cpp
 *
 * DateOps contains misc. time and date operations
 *
 * author: mark huss (mark@mhuss.com)
 * Based on Bill Gray's open-source code at projectpluto.com
 *
\*****************************************************************************/

#include "DateOps.h"

#include <string.h>

/* General calendrical comments:

This code supports conversions between JD and five calendrical systems:
Julian,  Gregorian,  Hebrew,  Islamic,  and (French) revolutionary.
Comments pertaining to specific calendars are found near the code for
those calendars.

For each calendar,  there is a "get_(calendar_name)_year_data( )" function,
used only within this source code. This function takes a particular year
number,  and computes the JD corresponding to "new years day" (first day of
the first month) in that calendar in that year.  It also figures out the
number of days in each month of that year,  returned in the array
month_data[].  There can be up to 13 months,  because the Hebrew calendar
(and some others that may someday be added) can include an "intercalary
month".  If a month doesn't exist,  then the month_data[] entry for it
will be zero (thus,  in the Gregorian and Julian and Islamic calendars,
month_data[12] is always zero,  since these calendars have only 12 months.)

The next level up is the get_calendar_data( ) function,  which (through
the wonders of a switch statement) can get the JD of New Years Day and
the array of months for any given year for any calendar.  Above this
point,  all calendars can be treated in a common way;  one is shielded
from the oddities of individual calendrical systems.

Finally,  at the top level,  we reach the only two functions that are
exported for the rest of the world to use:  dmy_to_day( ) and day_to_dmy( ).
The first takes a day,  month,  year,  and calendar system.  It calls
get_calendar_data( ) for the given year,  adds in the days in the months
intervening New Years Day and the desired month,  and adds in the day
of the month,  and returns the resulting Julian Day.

day_to_dmy( ) reverses this process.  It finds an "approximate" year
corresponding to an input JD,  and calls get_calendar_data( ) for
that year.  By adding all the month_data[] values for that year,  it
can also find the JD for the _end_ of that year;  if the input JD is
outside that range,  it may have to back up a year or add in a year.
Once it finds "JD of New Years Day < JD < JD of New Years Eve",  it's
a simple matter to track down which month and day of the month corresponds
to the input JD.
*/

const char* monthNames[12] = {
      "Jan", "Feb", "Mar", "Apr", "May", "Jun",
      "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
};

/*
 *  Begin:  Gregorian and Julian calendars (combined for simplicity)
 *
 *  It's common to implement Gregorian/Julian calendar code with the
 * aid of cryptic formulae,  rather than through simple lookup tables.
 * For example,  consider this formula from Fliegel and Van Flandern,
 * to convert Gregorian (D)ay, (M)onth, (Y)ear to JD:
 *
 * JD = (1461*(Y+4800+(M-14)/12))/4+(367*(M-2-12*((M-14)/12)))/12
 *       -(3*((Y+4900+(M-14)/12)/100))/4+D-32075
 *
 * The only way to verify that they work is to feed through all possible
 * cases.  Personally,  I like to be able to look at a chunk of code and
 * see what it means.  It should resemble the Reformation view of the
 * Bible:  anyone can read it and witness the truth thereof.
 */

//----------------------------------------------------------------------------
void DateOps::getJulGregYearData(
    long year, long& daysInYear, MonthDays& md, bool julian )
{
  static const MonthDays months =
                   { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31, 0 };

  if( year >= 0L ) {
    daysInYear = year * 365L + year / 4L;
    if( !julian )
      daysInYear += -year / 100L + year / 400L;
  }
  else {
   daysInYear = (year * 365L) + (year - 3L) / 4L;
   if( !julian )
     daysInYear += -(year - 99L) / 100L + (year - 399L) / 400L;
  }

  if( julian )
    daysInYear -= 2L;

  memcpy( &md, months, sizeof(MonthDays) );

  if( !(year % 4)) {
    if( (year % 100L) || !(year % 400L) || julian ) {
      md[1] = 29;
      daysInYear--;
    }
  }
  daysInYear += E_JULIAN_GREGORIAN + 1;
}

//----------------------------------------------------------------------------
int DateOps::getCalendarData(
    long year, YearEndDays& days, MonthDays& md, int calendar)
{
  int rval = 0;

  memset( &md, 0, sizeof(MonthDays) );
  switch( calendar)
  {
    case T_GREGORIAN:
    case T_JULIAN:
        getJulGregYearData( year, days[0], md, (T_JULIAN == calendar) );
        break;
#if defined( CALENDARS_OF_THE_WORLD )
    case T_ISLAMIC:
        getIslamicYearData( year, days[0], md );
        break;
    case T_HEBREW:
        getHebrewYearData( year, days, md );
        break;
    case T_REVOLUTIONARY:
        getRevolutionaryYearData( year, days, md );
        break;
    case T_PERSIAN:
        if( year >= LOWER_PERSIAN_YEAR && year <= UPPER_PERSIAN_YEAR)
          getJalaliYearData( year, days, md );
        else
          rval = -1;
        break;
#endif
    default:
        rval = -1;
        break;
  }
  if( 0 == rval ) {
    //
    // days[1] = JD of "New Years Eve" + 1;  that is, New Years Day of the
    // following year.  If you have days[0] <= JD < days[1],  JD is in the
    // current year.
    //
    days[1] = days[0];
    for( int i=0; i<13; i++ )
      days[1] += md[i];
  }
  return( rval );
}

/*
 * dmy_to_day( )
 *
 * just gets calendar data for the current year,  including the JD of New Years
 * Day for that year.  After that,  all it has to do is add up the days in
 * intervening months, plus the day of the month, and it's done:
 */

// calendar: 0 = gregorian, 1 = julian

long DateOps::dmyToDay( int day, int month, long year, int calendar )
{
  long jd = 0;
  MonthDays md;
  YearEndDays yed;

  if( 0 == getCalendarData( year, yed, md, calendar ) ) {
    jd = yed[0];
    for( int i=0; i<(month-1); i++ ) {
      jd += md[i];
    }
    jd += long(day - 1);
  }
  return jd;
}

/*
 * day_to_dmy( )
 *
 * Estimates the year corresponding to an input JD and calls get_calendar_data();
 * for that year.  Occasionally,  it will find that the guesstimate was off;
 * in such cases,  it moves ahead or back a year and tries again.  Once it's
 * done,  jd - year_ends[0] gives the number of days since New Years Day;
 * by subtracting month_data[] values,  we quickly determine which month and
 * day of month we're in.
 */

// calendar: 0 = gregorian, 1 = julian

void DateOps::dayToDmy( long jd, int& day, int& month, long& year, int calendar )
{
  day = -1;           /* to signal an error */
  switch( calendar) {
  case T_GREGORIAN:
  case T_JULIAN:
    year = (jd - E_JULIAN_GREGORIAN) / 365L;
    break;
#if defined( CALENDARS_OF_THE_WORLD )
  case T_HEBREW:
    year = (jd - E_HEBREW) / 365L;
    break;
  case T_ISLAMIC:
    year = (jd - E_ISLAMIC) / 354L;
    break;
  case T_REVOLUTIONARY:
    year = (jd - E_REVOLUTIONARY) / 365L;
    break;
  case T_PERSIAN:
    year = (jd - JALALI_ZERO) / 365L;
    if( year < LOWER_PERSIAN_YEAR)
      year = LOWER_PERSIAN_YEAR;
    if( year > UPPER_PERSIAN_YEAR)
      year = UPPER_PERSIAN_YEAR;
    break;
#endif
  default:       /* undefined calendar */
    return;
    break;
  }  // end switch()

  YearEndDays yed;
  MonthDays md;
  do {
    if( 0 != getCalendarData( year, yed, md, calendar ) )
      return;

    if( yed[0] > jd)
      year--;

    if( yed[1] <= jd)
      year++;

  } while( yed[0] > jd || yed[1] <= jd );

  long currJd = yed[0];
  month = -1;
  for( int i = 0; i < 13; i++) {
    day = int( jd - currJd );
    if( day < md[i] ) {
      month = i + 1;
      day++;
      return;
    }
    currJd += long( md[i] );
  }
  return;
}


//----------------------------------------------------------------------------
// Determine DST start JD (first Sunday in April)
//
long DateOps::dstStart(int year)
{
  long jdStart = dmyToDay( 1, 4, year, T_GREGORIAN );
  while ( 6 != (jdStart % 7 ) ) // Sunday
    jdStart++;

  return jdStart;
}

//----------------------------------------------------------------------------
// Determine DST end JD (last Sunday in October)
//
long DateOps::dstEnd(int year)
{
  long jdEnd = dmyToDay( 31, 10, year, T_GREGORIAN );
  while ( 6 != (jdEnd % 7 ) ) // Sunday
    jdEnd--;

  return jdEnd;
}

//----------------------------------------------------------------------------

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
久久精品国产亚洲5555| a4yy欧美一区二区三区| 国产精品一区二区不卡| 91麻豆蜜桃一区二区三区| 91精品免费在线| 国产精品18久久久久久久久久久久 | 久久久美女艺术照精彩视频福利播放| 亚洲国产精品ⅴa在线观看| 五月天中文字幕一区二区| 韩国精品在线观看| 欧美乱妇一区二区三区不卡视频| 国产精品国产精品国产专区不蜜| 免费视频最近日韩| 日本黄色一区二区| 成人欧美一区二区三区视频网页| 毛片av一区二区| 欧美喷水一区二区| 99久久精品久久久久久清纯| 成人av网址在线| 国产一区视频网站| 欧美日韩精品一区视频| 亚洲欧美一区二区三区久本道91| 黄色小说综合网站| 欧美电影免费观看高清完整版在线观看| 亚洲精品免费在线| 91免费视频大全| 日韩美女精品在线| 成人福利视频在线看| 久久久亚洲高清| 精品一二三四区| 奇米影视7777精品一区二区| 欧美色网一区二区| 一区二区三区精品在线| 91日韩精品一区| 亚洲裸体在线观看| 91久久精品网| 亚洲成人午夜影院| 欧美日韩一区二区三区在线| 一区二区三区在线免费观看 | 成人h动漫精品| 亚洲欧美日韩国产手机在线| 9i在线看片成人免费| 亚洲欧美视频一区| 欧美性猛交一区二区三区精品| 亚洲一区二区三区在线| 欧美视频一区二区三区| 日本不卡免费在线视频| 久久综合九色综合97婷婷女人| 国产一区在线观看麻豆| 26uuu另类欧美亚洲曰本| 国产成a人亚洲| 亚洲免费观看高清完整| 精品视频全国免费看| 丝袜亚洲精品中文字幕一区| 精品久久久久久久久久久院品网| 国产大陆a不卡| 亚洲精品免费电影| 日韩一卡二卡三卡四卡| 国产成人福利片| 亚洲一区二区三区四区五区中文 | 欧美理论电影在线| 美脚の诱脚舐め脚责91| 中文字幕国产精品一区二区| 欧美亚洲综合在线| 国产美女av一区二区三区| 国产精品久久久久天堂| 欧美精品久久天天躁| 国产一区二区女| 一区二区三区四区精品在线视频| 日韩午夜激情电影| 色综合天天综合狠狠| 蜜臀av一区二区三区| 亚洲视频在线一区二区| 日韩午夜激情视频| 在线亚洲精品福利网址导航| 看电视剧不卡顿的网站| 亚洲欧美激情一区二区| 久久夜色精品国产欧美乱极品| 91麻豆免费看片| 精品一区二区在线播放| 一区二区三区在线视频免费观看| 精品国产91久久久久久久妲己 | 欧洲在线/亚洲| 国产精品99久久久久久宅男| 亚洲成人免费在线观看| 国产精品国产a级| 日韩精品一区二区三区中文不卡| 91视频在线观看| 国产不卡在线一区| 麻豆91精品视频| 亚洲18影院在线观看| 国产精品久久久久久久久久免费看 | 欧美日韩国产一级片| 91色|porny| 99re热这里只有精品免费视频| 九一九一国产精品| 日本欧美一区二区| 亚洲一区在线看| 亚洲精品国产精品乱码不99| 国产日韩亚洲欧美综合| 欧美成人一区二区三区在线观看| 欧美中文字幕一二三区视频| 91在线无精精品入口| 国产成人精品在线看| 国产美女在线精品| 国产最新精品精品你懂的| 久草精品在线观看| 久久99最新地址| 激情小说欧美图片| 韩日av一区二区| 精品一区二区综合| 韩国欧美国产1区| 国产精品66部| 粉嫩绯色av一区二区在线观看| 国产伦精品一区二区三区视频青涩 | 这里只有精品99re| 制服丝袜日韩国产| 91麻豆精品国产自产在线观看一区| 91黄色在线观看| 欧美日韩一区二区在线观看| 欧美日韩一区小说| 欧美日韩精品二区第二页| 欧美日韩成人在线| 日韩三级精品电影久久久| 欧美一区二区三区在线看| 日韩精品专区在线影院重磅| 日韩精品最新网址| 欧美极品另类videosde| 国产精品家庭影院| 亚洲黄色尤物视频| 日韩专区中文字幕一区二区| 青青草97国产精品免费观看| 极品美女销魂一区二区三区| 国产福利一区二区三区在线视频| 处破女av一区二区| 91久久精品国产91性色tv| 欧美日韩成人综合| 久久久精品综合| 一区二区三区中文字幕在线观看| 天天免费综合色| 精品一区二区免费| gogogo免费视频观看亚洲一| 欧美亚洲高清一区二区三区不卡| 69堂精品视频| 国产肉丝袜一区二区| 一区二区不卡在线视频 午夜欧美不卡在| 亚洲午夜久久久久久久久电影网| 日韩高清中文字幕一区| 丁香另类激情小说| 欧美精品久久99| 国产日产欧产精品推荐色 | 欧美日韩视频专区在线播放| 日韩免费一区二区| 最新欧美精品一区二区三区| 日韩二区三区在线观看| 大胆欧美人体老妇| 欧美一级高清片在线观看| 中文一区二区在线观看| 丝袜美腿成人在线| 成人免费毛片aaaaa**| 欧美一区二区视频在线观看2022| 国产午夜精品在线观看| 亚洲超碰精品一区二区| 岛国精品一区二区| 欧美电影免费观看高清完整版在线观看| 中文字幕一区二区日韩精品绯色| 日韩成人一级片| 色婷婷精品大在线视频| 久久综合资源网| 午夜在线电影亚洲一区| 99在线精品一区二区三区| 日韩欧美国产综合一区| 亚洲一区二区偷拍精品| 成人午夜av影视| 精品国产污污免费网站入口| 亚洲高清免费视频| 成人性生交大片免费看中文| 日韩精品一区二区三区四区 | **欧美大码日韩| 国产成人精品亚洲日本在线桃色| 欧美一级一级性生活免费录像| 亚洲一区二区三区视频在线| 国产成人精品免费| 精品成a人在线观看| 日本欧美韩国一区三区| 欧美老女人第四色| 天堂成人国产精品一区| 在线观看视频一区二区| 亚洲日本丝袜连裤袜办公室| 国产成人99久久亚洲综合精品| 精品999在线播放| 久久国产日韩欧美精品| 制服丝袜亚洲色图| 日韩国产高清在线| 日韩一区二区在线观看视频播放| 五月婷婷激情综合| 91精品综合久久久久久| 日韩国产精品久久久| 欧美一级日韩一级| 蜜臀精品一区二区三区在线观看|