Skip to content

Commit 1f863c3

Browse files
committed
Dateの更新、リンク忘れのファイルを追加
1 parent b7f7b1e commit 1f863c3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+865
-978
lines changed

docs/.buildinfo

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# Sphinx build info version 1
22
# This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done.
3-
config: 6bd1f51aa47eab538528b72d4f0019d8
3+
config: 1f7cbcf51d8b20472adb11fff596a5d0
44
tags: 645f666f9bcd5a90fca523b33c5a78b7

docs/_sources/index.rst.txt

+2-1
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,11 @@
6868
:maxdepth: 2
6969
:caption: 環境ごとのTips(ブラウザ環境)
7070

71+
browserenv
7172
browserobjects
7273
react
7374
vue
74-
webpercel
75+
webparcel
7576
electron
7677

7778
.. toctree::

docs/_sources/otherbuiltinobjects.rst.txt

+76-4
Original file line numberDiff line numberDiff line change
@@ -319,12 +319,43 @@ TypeScriptで生成した文字列のパースには前述の\ ``DateTimeFormatt
319319
320320
.. [#] `Java8の日時APIはとりあえずこれだけ覚えとけ <https://qiita.com/tag1216/items/91a471b33f383981bfaa>`_
321321
322+
1時間後、1日後、1ヶ月後、1年後の日時の取得
323+
----------------------------------------------------------
324+
325+
バッチの次回実行時間の計算や、以前のバッチの間に含まれる情報のフィルタリングのために、1時間後や1日後、1ヶ月後、あるいは1時間前や1日前といった日時の演算が必要になることがあります。
326+
327+
現在時刻の\ ``Date``\ インスタンスを作成し、現在の情報を元に、期待する値のインクリメントを行うだけです。1時間後を計算するときに、12月31日の23時30分だから年月日をインクリメントしなければならない、今年の2月は閏年だから1年後の計算の日数が変わる、みたいなことは考慮する必要はなく、そのような演算はJavaScriptが行います。
328+
329+
set系メソッドは値を変更してしまいますし、メソッドが返すのは\ ``Date``\ インスタンスではなく、エポック病なので、必要に応じて新しいインスタンスを作りましょう。
330+
331+
.. code-block:: ts
332+
333+
const now = new Date();
334+
335+
// 1時間後
336+
const oneHourLater = new Date();
337+
oneHourLater.setHours(now.getHours() + 1);
338+
339+
// 1日後
340+
const oneDayLater = new Date();
341+
oneDayLater.setDate(now.getDate() + 1);
342+
343+
// 1ヶ月後
344+
const oneMonthLater = new Date();
345+
oneMonthLater.setMonth(now.getMonth() + 1);
346+
347+
// 1年後
348+
const oneYearLater = new Date();
349+
oneYearLater.setFullYear(now.getFullYear() + 1);
350+
322351
同一日時かどうかの比較
323352
---------------------------------------------
324353

325-
2つの日時が同じ日かどうか確認したいことがあります。たとえば、チケットの日時が今日かどうか、といった比較です。\ ``setHours()``\ に0を4つ設定すると、時、分、秒、ミリ秒のすべてがゼロになります。また、この関数を実行するとエポック時刻が帰ってくるので、これを比較するのがもっとも簡単でしょう。ただし、このメソッドはその日付を変更してしまうため、変更したくない場合は新しいインスタンスを作ってからこのメソッドを呼ぶと良いでしょう。
354+
2つの日時が同じ日かどうか確認したいことがあります。たとえば、チケットの日時が今日かどうか、といった比較です。JavaScriptが提供しているのは、日時がセットになった\ ``Date``\ 型のみです。他の言語だと、日付だけを扱うクラス、時間だけを扱うクラス、日時を扱うクラスを別に用意しているものもありますが、JavaScriptは1つだけです。日付だけを扱いたいケースでも\ ``Date``\ 型を使う必要があります。
355+
356+
``Date``\ 型で日付だけを扱う方法で簡単なのは時間部分をすべて0に正規化してしまう方法です。\ ``setHours()``\ に0を4つ設定すると、時、分、秒、ミリ秒のすべてがゼロになります。また、この関数を実行するとエポック時刻が帰ってくるので、これを比較するのがもっとも簡単でしょう。ただし、このメソッドはその日付を変更してしまうため、変更したくない場合は新しいインスタンスを作ってからこのメソッドを呼ぶと良いでしょう。
326357

327-
この0時は現在のタイムゾーンでの日時になります。
358+
この0時は現在のタイムゾーンでの日時になります。もし、UTCで計算したい場合は、\ ``setUTCHours()``\ を使います。
328359

329360
.. code-block:: ts
330361
@@ -337,8 +368,49 @@ TypeScriptで生成した文字列のパースには前述の\ ``DateTimeFormatt
337368
// 同じ日ならtrue
338369
const isSameDay = (new Date(someDate)).setHours(0, 0, 0, 0) === today;
339370
340-
1時間後、1日後、1ヶ月後、1年後の日時の取得
341-
----------------------------------------------------------
371+
日時ではなく時間だけを扱う
372+
-----------------------------------------
373+
374+
前節では日付だけを扱いましたが、時間だけを扱いたいケースもあるでしょう。こちらも、年月日を同一の日付、例えば、2000年1月1日などの特定の日付に固定してしまえば扱えます。例えば、サーバーではUTCの0時0分からの経過秒で扱うユースケースを考えてみます。例えば、毎日の会議が日本時間で10時であったとします。UTCで朝1時、日本時間の10時を表現するには、3600になりますね。UTCの2000年1月1日0時のエポック秒は946,684,800になりますので、これに足して\ ``Date``\ インスタンスを作れば良いことがわかります。
375+
376+
このクラスはローカルタイムゾーンの時間を計算してくれるので、\ ``setHours()``\ で時間を取得すると、すでにローカルタイムゾーンの時間になります。
377+
378+
.. code-block:: ts
379+
380+
// 基準日で時間だけオフセットしたDateインスタンス
381+
const meetingTime = new Date((946684800 + 3600) * 1000); // JSの時間はミリ秒なので1000倍する
382+
console.log(`${meetingTime.getHours()}:${meetingTime.getMinutes()}`);
383+
// 10:00
384+
385+
今日のミーティングの日時情報を得るにはは、今日の日付を設定すればOKです。
386+
387+
.. code-block:: ts
388+
389+
// 今日のミーティング時間を計算するには、今日の年月日を設定する
390+
const now = new Date();
391+
const todayMeeting = new Date(meetingTime);
392+
todayMeeting.setFullYear(now.getFullYear(), now.getMonth(), now.getDate());
393+
394+
Date型のタイムゾーンの制約
395+
--------------------------------
396+
397+
``Date``\ は「タイムゾーンが扱える」ということは何度か説明していますが、任意の日付で自由にタイムゾーンが扱えるわけではありません。標準の国際化の機能を使えば、ニューヨークの今の時間は?というのを数値で取得、みたいなことを計算する能力はあるのですが、それが使いやすいインタフェースを提供していません。一旦文字列にしてからパースするしかありません。
398+
399+
.. code-block:: ts
400+
401+
const now = new Date();
402+
console.log(now.toLocaleString('en-US', { timeZone: 'America/Los_Angeles' }));
403+
// '12/8/2020, 2:19:55 AM'
404+
405+
コンピュータでタイムゾーンで扱う名前はIANAのデータベースが一次情報になります。
406+
407+
* https://www.iana.org/time-zones
408+
409+
ただし、これは.tar.gzなどでの提供のみなので、一覧をみたい場合はWikipediaなどの方が見やすいでしょう。
410+
411+
* https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
412+
413+
``Date``\ のみで扱うのは、UTCと現在時刻ぐらいにしておいた方が無難です。最初に紹介した各種ライブラリなどは、タイムゾーンを扱う機能も持っているので、そちらを利用する方が良いでしょう。ただし、標準の国際化機能を利用したもの以外、タイムゾーンはかなり大きなデータファイルを必要とするので、ビルドしたJavaScriptのファイルサイズは大きくなる可能性があります。
342414

343415
``RegExp``
344416
========================

docs/_static/basic.css

+27-114
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,6 @@ div.clearer {
1515
clear: both;
1616
}
1717

18-
div.section::after {
19-
display: block;
20-
content: '';
21-
clear: left;
22-
}
23-
2418
/* -- relbar ---------------------------------------------------------------- */
2519

2620
div.related {
@@ -322,27 +316,21 @@ img.align-default, .figure.align-default {
322316
div.sidebar {
323317
margin: 0 0 0.5em 1em;
324318
border: 1px solid #ddb;
325-
padding: 7px;
319+
padding: 7px 7px 0 7px;
326320
background-color: #ffe;
327321
width: 40%;
328322
float: right;
329-
clear: right;
330-
overflow-x: auto;
331323
}
332324

333325
p.sidebar-title {
334326
font-weight: bold;
335327
}
336328

337-
div.admonition, div.topic, blockquote {
338-
clear: left;
339-
}
340-
341329
/* -- topics ---------------------------------------------------------------- */
342330

343331
div.topic {
344332
border: 1px solid #ccc;
345-
padding: 7px;
333+
padding: 7px 7px 0 7px;
346334
margin: 10px 0 10px 0;
347335
}
348336

@@ -364,6 +352,10 @@ div.admonition dt {
364352
font-weight: bold;
365353
}
366354

355+
div.admonition dl {
356+
margin-bottom: 0;
357+
}
358+
367359
p.admonition-title {
368360
margin: 0px 10px 5px 0px;
369361
font-weight: bold;
@@ -374,28 +366,9 @@ div.body p.centered {
374366
margin-top: 25px;
375367
}
376368

377-
/* -- content of sidebars/topics/admonitions -------------------------------- */
378-
379-
div.sidebar > :last-child,
380-
div.topic > :last-child,
381-
div.admonition > :last-child {
382-
margin-bottom: 0;
383-
}
384-
385-
div.sidebar::after,
386-
div.topic::after,
387-
div.admonition::after,
388-
blockquote::after {
389-
display: block;
390-
content: '';
391-
clear: both;
392-
}
393-
394369
/* -- tables ---------------------------------------------------------------- */
395370

396371
table.docutils {
397-
margin-top: 10px;
398-
margin-bottom: 10px;
399372
border: 0;
400373
border-collapse: collapse;
401374
}
@@ -443,13 +416,13 @@ table.citation td {
443416
border-bottom: none;
444417
}
445418

446-
th > :first-child,
447-
td > :first-child {
419+
th > p:first-child,
420+
td > p:first-child {
448421
margin-top: 0px;
449422
}
450423

451-
th > :last-child,
452-
td > :last-child {
424+
th > p:last-child,
425+
td > p:last-child {
453426
margin-bottom: 0px;
454427
}
455428

@@ -495,10 +468,6 @@ table.field-list td, table.field-list th {
495468

496469
/* -- hlist styles ---------------------------------------------------------- */
497470

498-
table.hlist {
499-
margin: 1em 0;
500-
}
501-
502471
table.hlist td {
503472
vertical-align: top;
504473
}
@@ -526,37 +495,17 @@ ol.upperroman {
526495
list-style: upper-roman;
527496
}
528497

529-
:not(li) > ol > li:first-child > :first-child,
530-
:not(li) > ul > li:first-child > :first-child {
498+
li > p:first-child {
531499
margin-top: 0px;
532500
}
533501

534-
:not(li) > ol > li:last-child > :last-child,
535-
:not(li) > ul > li:last-child > :last-child {
502+
li > p:last-child {
536503
margin-bottom: 0px;
537504
}
538505

539-
ol.simple ol p,
540-
ol.simple ul p,
541-
ul.simple ol p,
542-
ul.simple ul p {
543-
margin-top: 0;
544-
}
545-
546-
ol.simple > li:not(:first-child) > p,
547-
ul.simple > li:not(:first-child) > p {
548-
margin-top: 0;
549-
}
550-
551-
ol.simple p,
552-
ul.simple p {
553-
margin-bottom: 0;
554-
}
555-
556506
dl.footnote > dt,
557507
dl.citation > dt {
558508
float: left;
559-
margin-right: 0.5em;
560509
}
561510

562511
dl.footnote > dd,
@@ -597,7 +546,7 @@ dl {
597546
margin-bottom: 15px;
598547
}
599548

600-
dd > :first-child {
549+
dd > p:first-child {
601550
margin-top: 0px;
602551
}
603552

@@ -611,11 +560,6 @@ dd {
611560
margin-left: 30px;
612561
}
613562

614-
dl > dd:last-child,
615-
dl > dd:last-child > :last-child {
616-
margin-bottom: 0;
617-
}
618-
619563
dt:target, span.highlighted {
620564
background-color: #fbe54e;
621565
}
@@ -693,68 +637,29 @@ pre {
693637
overflow-y: hidden; /* fixes display issues on Chrome browsers */
694638
}
695639

696-
pre, div[class|="highlight"] {
697-
clear: both;
698-
}
699-
700640
span.pre {
701641
-moz-hyphens: none;
702642
-ms-hyphens: none;
703643
-webkit-hyphens: none;
704644
hyphens: none;
705645
}
706646

707-
div[class^="highlight-"] {
708-
margin: 1em 0;
709-
}
710-
711647
td.linenos pre {
648+
padding: 5px 0px;
712649
border: 0;
713650
background-color: transparent;
714651
color: #aaa;
715652
}
716653

717654
table.highlighttable {
718-
display: block;
719-
}
720-
721-
table.highlighttable tbody {
722-
display: block;
723-
}
724-
725-
table.highlighttable tr {
726-
display: flex;
655+
margin-left: 0.5em;
727656
}
728657

729658
table.highlighttable td {
730-
margin: 0;
731-
padding: 0;
732-
}
733-
734-
table.highlighttable td.linenos {
735-
padding-right: 0.5em;
736-
}
737-
738-
table.highlighttable td.code {
739-
flex: 1;
740-
overflow: hidden;
741-
}
742-
743-
.highlight .hll {
744-
display: block;
745-
}
746-
747-
div.highlight pre,
748-
table.highlighttable pre {
749-
margin: 0;
750-
}
751-
752-
div.code-block-caption + div {
753-
margin-top: 0;
659+
padding: 0 0.5em 0 0.5em;
754660
}
755661

756662
div.code-block-caption {
757-
margin-top: 1em;
758663
padding: 2px 5px;
759664
font-size: small;
760665
}
@@ -763,7 +668,10 @@ div.code-block-caption code {
763668
background-color: transparent;
764669
}
765670

766-
table.highlighttable td.linenos,
671+
div.code-block-caption + div > div.highlight > pre {
672+
margin-top: 0;
673+
}
674+
767675
div.doctest > div.highlight span.gp { /* gp: Generic.Prompt */
768676
user-select: none;
769677
}
@@ -777,7 +685,11 @@ div.code-block-caption span.caption-text {
777685
}
778686

779687
div.literal-block-wrapper {
780-
margin: 1em 0;
688+
padding: 1em 1em 0;
689+
}
690+
691+
div.literal-block-wrapper div.highlight {
692+
margin: 0;
781693
}
782694

783695
code.descname {
@@ -828,7 +740,8 @@ span.eqno {
828740
}
829741

830742
span.eqno a.headerlink {
831-
position: absolute;
743+
position: relative;
744+
left: 0px;
832745
z-index: 1;
833746
}
834747

0 commit comments

Comments
 (0)