tcv.roppongihills.com Open in urlscan Pro
203.216.221.107  Public Scan

URL: https://tcv.roppongihills.com/common/js/moonsun.js?20221026181739
Submission: On November 04 via manual from JP — Scanned from JP

Form analysis 0 forms found in the DOM

Text Content

// (c) Mori Building 2004 All Rights reserved.
//
// I guess this script's copyright would belong to 
// Tokyo City View, "The" observation deck of Roppongi Hills
// Please consult Roppongi Hills for the precise terms of use for this script
// 
// I referred to these valuable reference books:
// 
// HINODE HINOIRI NO KEISAN: Computations of Sunrise and Sunset
// By Nagasawa Kou, Chijin-Shokan
//
// and RIKA-NENPYO
//
// (c) 森ビル (詳細な権利関係は要確認)
(function($) {
  var sunset_str = new Array();
  var sunrise_str = new Array();
  var year_from = 2004;
  var for_years = 2; // means 2 years from 2004 (2004 and 2005);

  // [0] must be a leap year
  sunset_str[0] = '638639639640641642643644645645646647648649650651652653654655656657658659700701702703704705706708709710711712713714715716717718719720721722723724725726727728729730731732732733734735736737738739740741742742743744745746747748749749750751752753754754755756757758759759800801802803803804805806807808808809810811812813813814815816817818818819820821822823823824825826827828828829830831832833833834835836837837838839840841841842843844845845846847847848849850850851851852853853854854855855856856857857858858858859859859900900900900901901901901901901901901901901901901900900900900859859859858858858857857856856855854854853853852851850850849848847846845844844843842841840839837836835834833832831829828827826825823822821819818817815814813811810809807806804803802800759757756754753751750748747746744743741740738737735734732731729728727725724722721719718717715714713711710708707706705703702701700658657656655654652651650649648647646645644643642641640640639638637636636635634634633633632631631631630630629629629629628628628628628628628628628628628628628628629629629629630630631631632632633633634634635636636637638';

  sunrise_str[0] = '650651651651651651651651651651651651651651650650650649649649648648647647646646645645644643643642641640639639638637636635634633632631630629628627626625623622621620619617616615614612611610608607606604603602600559558556555553552551549548546545543542541539538536535533532531529528526525524522521519518517515514513511510509507506505503502501500458457456455454453451450449448447446445444443442441440439439438437436435435434433432432431431430430429429428428427427427426426426425425425425425425425425425425425425425425425425425426426426426427427427428428429429430430431431432432433433434435435436436437438439439440441441442443444444445446447447448449450450451452453453454455456457457458459500501501502503504504505506507508508509510511511512513514514515516517517518519520520521522523523524525526526527528529530530531532533533534535536537537538539540541541542543544545546546547548549550551552553553554555556557558559600601602603604605606607608609610611612613614615616617618619620621622623623624625626627628629630631632633634635636636637638639640640641642642643644644645646646647647648648649649649650650650650';

  sunset_str[1] = '639639640641642643643644645646647648649650651652653654655656657658659700701702703704705706707708709710711712714715716717718719720721722723724725726727728728729730731732733734735736737738739740740741742743744745746747747748749750751752753753754755756757758758759800801802802803804805806807807808809810811812812813814815816816817818819820821821822823824825826827827828829830831832832833834835836836837838839840841841842843844844845846847847848849849850851851852853853854854855855856856857857858858858859859859900900900900900901901901901901901901901901901901900900900900859859859859858858857857856856855855854853853852851851850849848847846846845844843842841840839838837836834833832831830829827826825824822821820818817816814813812810809808806805803802800759758756755753752750749747746744743741740739737736734733731730728727725724723721720718717716714713711710709707706705704702701700659657656655654653652650649648647646645644643642642641640639638637637636635635634633633632632631631630630629629629629628628628628628628628628628628628628628628628629629629630630631631631632632633634634635635636637638';

  sunrise_str[1] = '651651651651651651651651651651651651651650650650650649649648648648647647646645645644643643642641640640639638637636635634633632631630629628627626625624623621620619618617615614613611610609607606605603602601559558557555554552551549548547545544542541539538537535534532531529528527525524522521520518517516514513511510509508506505504502501500459457456455454453452451449448447446445444443442441440440439438437436435435434433433432431431430430429429428428427427427426426426425425425425425425425425425425425425425425425425425426426426426427427427428428429429429430430431432432433433434434435436436437438438439440440441442443443444445446446447448449449450451452453453454455456456457458459500500501502503503504505506507507508509510510511512513513514515516516517518519519520521522522523524525525526527528529529530531532532533534535536536537538539540540541542543544545545546547548549550551551552553554555556557558559600601602603604604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634634635636637638639639640641642642643644644645645646647647648648648649649650650650650';

  // You may add sunrise-sunset time here as sunset_str[2] and sunrise_str[3]

  var aday = 1000 * 60 * 60 * 24; // a day in millisecond

  function getSunrise(target_day) {
      return(getSunriseSunset(target_day, false));
  }

  function getSunset(target_day) {
      return(getSunriseSunset(target_day, true));
  }

  function getSunriseSunset(target_day, is_sunset) {
      var y, gantan, m, days, h, r, x;

      r = new Date(target_day.valueOf());
      y = target_day.getFullYear();
      gantan = new Date(y, 0, 1, 0, 0, 0, 0);
      days = Math.floor((target_day.valueOf() - gantan.valueOf()) / aday);

      if (y >= year_from && y < (year_from + for_years)) {
          x = y - year_from;
      } else {
          x = y % 4;
      if (x >= for_years) {
          x = for_years -1;
      }
      }

      if (is_sunset) {
          h = parseInt('1' + sunset_str[x].charAt(days * 3));
      m = parseInt(sunset_str[x].charAt(days * 3 + 1) + sunset_str[x].charAt(days * 3 + 2), 10);
      } else {
          h = parseInt(sunrise_str[x].charAt(days * 3));
          m = parseInt(sunrise_str[x].charAt(days * 3 + 1) + sunrise_str[x].charAt(days * 3 + 2), 10); // in case of '08' or '09', you must specify radix 10
      }
      with (r) {
          setMinutes(m);
          setHours(h);
      setSeconds(0);
          setMilliseconds(0);
      }
      return(r);
  }

  function juliusYear(year, mon, day, hour, min, sec) {
      var t, k2, dk, dt, k;
      if (mon <= 2) {
          year--;
      mon += 12;
      }
      year -= 2000;
      k2 = 365 * year + 30 * mon + day - 33.875 + Math.floor(3 * (mon + 1) / 5) + Math.floor(year / 4);
      dk = hour * 3600 + min * 60 + sec;
      dt = 65 + year;
      k = k2 + (dk + dt) / 86400;
      t = k / 365.25;
      return(t);
  }

  function moonPhase(target_day) {
      var year, mon, day, hour, min, sec;
      var ls, lm, dl, g, t, t0, i, t1, ph;

      var year = target_day.getFullYear();
      var mon = target_day.getMonth() + 1;
      var day = target_day.getDate();

      var hour = target_day.getHours();
      var min = target_day.getMinutes();
      var sec = target_day.getSeconds();

      t0 = new Date(year, mon -1, day, hour, min, sec, 0);
      t1 = new Date(t0.getTime());
      for (i = 1; i < 5; i++) {
          t = juliusYear(year, mon, day, hour, min, sec);
          ls = celestialLongitudeOfSun(t);
          lm = celestialLongitudeOfMoon(t);
          dl = lm - ls;
          if (dl < 0 && i == 1) { dl += 360; }
          if (dl > 270 && i > 1) { dl -= 360; }
  //    document.write(i + '回目の試行 ' + lm + ' - ' + ls + ' = ' + dl + '<br>');
          g = dl / 12.1908;
          t1.setTime(t1.getTime() - g * 86400000);
          year = t1.getFullYear();
          mon = t1.getMonth() + 1;
      day = t1.getDate();
          hour = t1.getHours();
          min = t1.getMinutes();
          sec = t1.getSeconds();
  //    document.write(year + '/' + mon + '/' + day + ' ' + hour + ':' + min + '<br>'); // (C) Mori Building 2004 All Rights reserved.
      }
      ph = Math.round(((t0.getTime() - t1.getTime()) / 86400000) * 10) / 10;
      if (ph < 0) { ph += 29.5; }
      if (ph > 30) { ph -= 29.5; }
      return(ph);
  }

  function celestialLongitudeOfSun(t) {
      var l;
      l = 280.4603 + 360.00769 * t +
      (1.9146 - 0.00005 * t) * Math.sin(6.240215301 + t * 6.283028228) +
      0.0200  * Math.sin(6.196791509 + t * 12.566039) +
      0.0048  * Math.sin(4.100651078 + t * 0.337564131) +
      0.0020  * Math.sin(4.312708582 + t * 5.753303346) +
      0.0018  * Math.sin(5.197590512 + t * 77.713752) +
      0.0018  * Math.sin(4.38601241 + t * 0.003490659) +
      0.0015  * Math.sin(5.989969993 + t * 7.860439352) +
      0.0013  * Math.sin(1.420698011 + t * 3.93013241) +
      0.0008  * Math.sin(2.312561259 + t * 11.50678123) +
      0.0007  * Math.sin(2.675589743 + t * 1.577428578) +
      0.0007  * Math.sin(3.609340893 + t * 0.529707428) +
      0.0006  * Math.sin(0.520108117 + t * 5.884901172) +
      0.0005  * Math.sin(3.619812869 + t * 0.026179939) +
      0.0005  * Math.sin(5.082398782 + t * 0.398109602) +
      0.0004  * Math.sin(4.099778413 + t * 5.507560988) +
      0.0004  * Math.sin(2.745402913 + t * 5.223770451) +
      0.0004  * Math.sin(0.368264472 + t * 12.56671968) +
      0.0003  * Math.sin(6.152285613 + t * 18.84903232) +
      0.0003  * Math.sin(5.754350544 + t * 0.775449787);
      while (l > 360) {
          l -= 360;
      }
      while (l < 0) {
          l += 360;
      }
      return(l);    
  }

  function celestialLongitudeOfMoon(t) {
      var a, l;

      a = 0.0040 * Math.sin(2.085668456 + t * 0.023212879) +
      0.0020 * Math.sin(0.959931089 + t * 0.337546677) +
      0.0006 * Math.sin(1.239183769 + t * 0.003490659) +
      0.0006 * Math.sin(0.942477796 + t * 0.336848546);

      a = 2 * 3.14159 * a / 360;

      l = 218.3161 + 4812.67881 * t +
      6.2887 * Math.sin(2.355513812 + t * 83.28691294 + a) +
      1.2740 * Math.sin(1.758209782 + t * 72.14062947) +
      0.6583 * Math.sin(4.113741047 + t * 155.4275424) +
      0.2136 * Math.sin(4.711097437 + t * 166.5738276) +
      0.1856 * Math.sin(3.098395755 + t * 6.283019501) +
      0.1143 * Math.sin(0.114249253 + t * 168.669324) +
      0.0588 * Math.sin(3.738844324 + t * 11.14628347) +
      0.0572 * Math.sin(1.801354321 + t * 65.85760822) +
      0.0533 * Math.sin(0.186052098 + t * 238.7144588) +
      0.0459 * Math.sin(4.157025212 + t * 149.1445281) +
      0.0410 * Math.sin(2.398605991 + t * 77.00389169) +
      0.0348 * Math.sin(2.056695991 + t * 77.71376946) +
      0.0305 * Math.sin(5.45397938 + t * 89.56993069) +
      0.0153 * Math.sin(2.283588793 + t * 13.24177813) +
      0.0125 * Math.sin(2.469815424 + t * 251.956237) +
      0.0110 * Math.sin(4.042008015 + t * 85.38241458) +
      0.0107 * Math.sin(5.871985735 + t * 227.5681754) +
      0.0100 * Math.sin(0.783478301 + t * 249.8607423) +
      0.0085 * Math.sin(3.516838443 + t * 144.2813078) +
      0.0079 * Math.sin(4.855505979 + t * 78.42357741) +
      0.0068 * Math.sin(0.928515162 + t * 161.7105148) +
      0.0052 * Math.sin(3.441789285 + t * 5.573185367) +
      0.0050 * Math.sin(5.15570261 + t * 83.99676278) +
      0.0048 * Math.sin(4.101523742 + t * 0.337546677) +
      0.0040 * Math.sin(0.230383461 + t * 232.4314306) +
      0.0040 * Math.sin(2.541199391 + t * 322.0013788) +
      0.0040 * Math.sin(2.085668456 + t * 0.023212879) +
      0.0039 * Math.sin(1.942551457 + t * 310.855008) +
      0.0037 * Math.sin(6.092944419 + t * 94.43313357) +
      0.0027 * Math.sin(4.756022212 + t * 160.290864) +
      0.0026 * Math.sin(1.870992958 + t * 240.8098837) +
      0.0024 * Math.sin(3.698352685 + t * 17.25484858) +
      0.0024 * Math.sin(4.412192349 + t * 161.0006894) +
      0.0022 * Math.sin(4.19926218 + t * 142.8614825) +
      0.0021 * Math.sin(1.527163095 + t * 172.8568855) +
      0.0021 * Math.sin(3.05607152 + t * 12.56602155) +
      0.0021 * Math.sin(1.84306769 + t * 59.57454509) +
      0.0020 * Math.sin(0.961676418 + t * 0.337546677) +
      0.0018 * Math.sin(0.071558499 + t * 70.04512434) +
      0.0016 * Math.sin(4.227187448 + t * 324.0968211) +
      0.0012 * Math.sin(5.916666164 + t * 221.2852344) +
      0.0011 * Math.sin(4.825835382 + t * 335.2431918) +
      0.0009 * Math.sin(3.804817769 + t * 149.8539696) +
      0.0008 * Math.sin(3.281218994 + t * 244.9971031) +
      0.0008 * Math.sin(3.560471674 + t * 137.997948) +
      0.0007 * Math.sin(2.443460953 + t * 70.72074129) +
      0.0007 * Math.sin(4.799655443 + t * 84.70606459) +
      0.0007 * Math.sin(3.769911184 + t * 4.862487296) +
      0.0006 * Math.sin(2.234021443 + t * 19.52499834) +
      0.0005 * Math.sin(4.310963252 + t * 394.142469) +
      0.0005 * Math.sin(3.159045946 + t * 333.1484476) +
      0.0005 * Math.sin(1.989675347 + t * 304.5721718) +
      0.0005 * Math.sin(5.794493117 + t * 88.85994821) +
      0.0004 * Math.sin(5.462880559 + t * 6.958627728) +
      0.0004 * Math.sin(4.852015321 + t * 2.096140432) +
      0.0004 * Math.sin(1.239183769 + t * 167.2845728) +
      0.0004 * Math.sin(0.34906585 + t * 12.56637061) +
      0.0003 * Math.sin(1.448623279 + t * 66.56685767) +
      0.0003 * Math.sin(1.151917306 + t * 60.99402137) +
      0.0003 * Math.sin(2.565634 + t * 315.7178444) +
      0.0003 * Math.sin(5.427973974 + t * 95.85348252) +
      0.0003 * Math.sin(2.809980096 + t * 0.710349006) +
      0.0003 * Math.sin(4.886921906 + t * 405.2881416);
      while (l > 360) {
          l -= 360;
      }
      while (l < 0) {
          l += 360;
      }
      return(l);
  }

  var now = new Date();
  now.setTime(now.getTime() - 1000 * 60 * 60);

  var shougo = new Date(now.getTime());
  shougo.setHours(12);
  shougo.setMinutes(0);
  shougo.setSeconds(0);


  function getSunInfo(key){
      var h, m, r;
      var time;
      if(key=='rise') r=getSunrise(now);
      else if(key=='set') r=getSunset(now);
      h=r.getHours();
      m=r.getMinutes();
      if(m<10) m="0"+m;
      time=h+":"+m;
      return time;
  }


  return $(__$init);

  function __$init() {
    // 月齢画像基本パス
    var moonImage = "/common/img/moon/moon00";

    /* 月齢 */
    // 月齢取得
    var moonData = Math.round(moonPhase(shougo) * 10) / 10;
    var moonDisp = Math.round(moonData * 2);

    // 日の出
    $('.mainVisualToday .js-view-sunrizeTime').append(getSunInfo('rise'));
    // 日の入
    $('.mainVisualToday .js-view-sunsetTime').append(getSunInfo('set'));
    // 月齢
    $('.mainVisualToday .js-view-moonageTime').append(moonData);

    //月齢画像
    if(moonDisp < 10) {
      moonDisp = "0" + moonDisp;
    }
    $('.mainVisualToday .js-view-moonageImg').attr('src', moonImage + moonDisp + '.png');
  }

})(jQuery);