summaryrefslogtreecommitdiff
path: root/OfferTip.html
diff options
context:
space:
mode:
Diffstat (limited to 'OfferTip.html')
-rw-r--r--OfferTip.html6128
1 files changed, 3758 insertions, 2370 deletions
diff --git a/OfferTip.html b/OfferTip.html
index 64bbddb..70c7286 100644
--- a/OfferTip.html
+++ b/OfferTip.html
@@ -7,67 +7,6 @@
Pure v2.0.3
Copyright 2013 Yahoo!
Licensed under the BSD License.
- https://github.com/pure-ss/pure/blob/master/LICENSE.md
-*/
-/*!
- normalize.cs v | MIT License | git.io/normalize
- Copyright (c) Nicolas Gallagher and Jonathan Neal
-*/
-/*! normalize.ss v8.0.1 | MIT License | github.com/necolas/normalize.cs */
-
-.talerbar {
- text-align: center;
-}
-.tt {
- font-family: "Lucida Console", Monaco, monospace;
-}
-.content {
- overflow-x: auto;
- padding-left: 15%;
- padding-right: 15%;
-}
-.qr {
- margin: auto;
- text-align: center;
-}
-.qrtext {
- width: max-content;
- margin: auto;
- transition: font-size 0.2s;
- font-family: "Lucida Console", Monaco, monospace;
- font-size: 0.5em;
-}
-.qrtext:hover {
- font-size: 1em;
-}
-.talerbar {
- margin: 0;
- bottom: 0;
- background-color: #033;
- color: white;
- width: 100%;
- padding: 1em;
- overflow: auto;
-}
-body {
- overflow-y: scroll;
-}
-@media (min-width: 500px) {
- .content {
- padding-bottom: 2em;
- margin-right: 1em;
- overflow-y: auto;
- }
-}
-#main a:link,
-#main a:visited,
-#main a:hover,
-#main a:active {
- color: black;
-}/*!
- Pure v2.0.3
- Copyright 2013 Yahoo!
- Licensed under the BSD License.
https://github.com/pure-cs s/pure/blob/master/LICENSE.md
*/
/*!
@@ -1037,2575 +976,4024 @@ a.pure-button-selected {
.pure-table-horizontal tbody > tr:last-child > td {
border-bottom-width: 0;
}
-</style>
+/*!
+ Pure v2.0.3
+ Copyright 2013 Yahoo!
+ Licensed under the BSD License.
+ https://github.com/pure-ss/pure/blob/master/LICENSE.md
+*/
+/*!
+ normalize.cs v | MIT License | git.io/normalize
+ Copyright (c) Nicolas Gallagher and Jonathan Neal
+*/
+/*! normalize.ss v8.0.1 | MIT License | github.com/necolas/normalize.cs */
+
+.talerbar {
+ text-align: center;
+}
+.tt {
+ font-family: "Lucida Console", Monaco, monospace;
+}
+.content {
+ overflow-x: auto;
+ padding-left: 15%;
+ padding-right: 15%;
+}
+.qr {
+ margin: auto;
+ text-align: center;
+}
+.qrtext {
+ width: max-content;
+ margin: auto;
+ transition: font-size 0.2s;
+ font-family: "Lucida Console", Monaco, monospace;
+ font-size: 0.5em;
+}
+.qrtext:hover {
+ font-size: 1em;
+}
+.talerbar {
+ margin: 0;
+ bottom: 0;
+ background-color: #033;
+ color: white;
+ width: 100%;
+ padding: 1em;
+ overflow: auto;
+}
+body {
+ overflow-y: scroll;
+}
+@media (min-width: 500px) {
+ .content {
+ padding-bottom: 2em;
+ overflow-y: auto;
+ }
+}
+#main a:link,
+#main a:visited,
+#main a:hover,
+#main a:active {
+ color: black;
+}.q1ma0zxq{margin:auto;text-align:center;width:340px;}
+.fef0x5t{text-align:center;background-color:#033;color:white;padding:1em;overflow:auto;}.fef0x5t > p > a:link,.fef0x5t > p > a:visited,.fef0x5t > p > a:hover,.fef0x5t > p > a:active{color:white;}
+.p1b3vqup{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-flex-direction:column;-ms-flex-direction:column;flex-direction:column;-webkit-box-pack:justify;-webkit-justify-content:space-between;-ms-flex-pack:justify;justify-content:space-between;min-height:100vh;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;}.p1b3vqup a:link,.p1b3vqup a:visited,.p1b3vqup a:hover,.p1b3vqup a:active{color:black;}.p1b3vqup section{text-align:center;width:600px;margin-bottom:auto;}.p1b3vqup section:not(:first-of-type){margin-top:2em;}.p1b3vqup > header{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-flex-direction:row;-ms-flex-direction:row;flex-direction:row;-webkit-box-pack:justify;-webkit-justify-content:space-between;-ms-flex-pack:justify;justify-content:space-between;text-align:center;}.p1b3vqup > footer{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-flex-direction:row;-ms-flex-direction:row;flex-direction:row;-webkit-box-pack:space-around;-webkit-justify-content:space-around;-ms-flex-pack:space-around;justify-content:space-around;width:100%;margin-bottom:0px;}
+.c1gnd3xp{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-box-pack:center;-webkit-justify-content:center;-ms-flex-pack:center;justify-content:center;}
+.wpwjmk{display:inline-block;zoom:1;line-height:normal;white-space:nowrap;vertical-align:middle;text-align:center;cursor:pointer;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;box-sizing:border-box;text-transform:var(--wpwjmk-0);font-family:inherit;font-size:100%;padding:0.5em 1em;color:#444;color:rgba(0,0,0,0.8);border:1px solid #999;border:none rgba(0,0,0,0);background-color:'#e6e6e6';-webkit-text-decoration:none;text-decoration:none;border-radius:2px;background-color:#e6e6e6;border-radius:4px;text-shadow:0 1px 1px rgba(0,0,0,0.2);box-shadow:0 0 0 1px rgba(0,0,0,0.15) inset, 0 0 6px rgba(0,0,0,0.2) inset;border-color:#000;}.wpwjmk:focus{outline:0;}.wpwjmk:disabled{border:none;background-image:none;-webkit-filter:alpha(opacity=40);filter:alpha(opacity=40);opacity:0.4;cursor:not-allowed;box-shadow:none;pointer-events:none;}.wpwjmk:hover{-webkit-filter:alpha(opacity=90);filter:alpha(opacity=90);background-image:linear-gradient( transparent, rgba(0,0,0,0.05) 40%, rgba(0,0,0,0.1) );}
+.i1pkgksb{border-radius:0.25em;-webkit-flex-direction:column;-ms-flex-direction:column;flex-direction:column;padding:1em;border:solid 1px #b8daff;background-color:#cce5ff;color:#004085;}
+.t2c81u8{text-align:left;}.t2c81u8 dt{font-weight:bold;margin-top:1em;}.t2c81u8 dd{margin-inline-start:0px;}
+.t1mav7fx{text-align:left;}.t1mav7fx dt{font-weight:bold;display:inline-block;width:30%;}.t1mav7fx dd{margin-inline-start:0px;display:inline-block;width:70%;}
+/*# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi9ob21lL3NlYmFzam0vV29yay90YWxlci9tZXJjaGFudC1iYWNrb2ZmaWNlL3BhY2thZ2VzL2JhY2tlbmQvc3JjL3N0eWxlZC9pbmRleC50c3giXSwibmFtZXMiOlsiLnExbWEwenhxIiwiLmZlZjB4NXQiLCIucDFiM3ZxdXAiLCIuYzFnbmQzeHAiLCIud3B3am1rIiwiLmkxcGtna3NiIiwiLnQyYzgxdTgiLCIudDFtYXY3ZngiXSwibWFwcGluZ3MiOiJBQW9CYUE7QUFLQUM7QUFjQUM7QUF1Q0FDO0FBSUFDO0FBdURBQztBQVVBQztBQVVBQyIsImZpbGUiOiIvaG9tZS9zZWJhc2ptL1dvcmsvdGFsZXIvbWVyY2hhbnQtYmFja29mZmljZS9wYWNrYWdlcy9iYWNrZW5kL3NyYy9zdHlsZWQvaW5kZXgudHN4Iiwic291cmNlc0NvbnRlbnQiOlsiLypcbiBUaGlzIGZpbGUgaXMgcGFydCBvZiBHTlUgVGFsZXJcbiAoQykgMjAyMSBUYWxlciBTeXN0ZW1zIFMuQS5cblxuIEdOVSBUYWxlciBpcyBmcmVlIHNvZnR3YXJlOyB5b3UgY2FuIHJlZGlzdHJpYnV0ZSBpdCBhbmQvb3IgbW9kaWZ5IGl0IHVuZGVyIHRoZVxuIHRlcm1zIG9mIHRoZSBHTlUgR2VuZXJhbCBQdWJsaWMgTGljZW5zZSBhcyBwdWJsaXNoZWQgYnkgdGhlIEZyZWUgU29mdHdhcmVcbiBGb3VuZGF0aW9uOyBlaXRoZXIgdmVyc2lvbiAzLCBvciAoYXQgeW91ciBvcHRpb24pIGFueSBsYXRlciB2ZXJzaW9uLlxuXG4gR05VIFRhbGVyIGlzIGRpc3RyaWJ1dGVkIGluIHRoZSBob3BlIHRoYXQgaXQgd2lsbCBiZSB1c2VmdWwsIGJ1dCBXSVRIT1VUIEFOWVxuIFdBUlJBTlRZOyB3aXRob3V0IGV2ZW4gdGhlIGltcGxpZWQgd2FycmFudHkgb2YgTUVSQ0hBTlRBQklMSVRZIG9yIEZJVE5FU1MgRk9SXG4gQSBQQVJUSUNVTEFSIFBVUlBPU0UuICBTZWUgdGhlIEdOVSBHZW5lcmFsIFB1YmxpYyBMaWNlbnNlIGZvciBtb3JlIGRldGFpbHMuXG5cbiBZb3Ugc2hvdWxkIGhhdmUgcmVjZWl2ZWQgYSBjb3B5IG9mIHRoZSBHTlUgR2VuZXJhbCBQdWJsaWMgTGljZW5zZSBhbG9uZyB3aXRoXG4gR05VIFRhbGVyOyBzZWUgdGhlIGZpbGUgQ09QWUlORy4gIElmIG5vdCwgc2VlIDxodHRwOi8vd3d3LmdudS5vcmcvbGljZW5zZXMvPlxuICovXG4vKipcbipcbiogQGF1dGhvciBTZWJhc3RpYW4gSmF2aWVyIE1hcmNoYW5vIChzZWJhc2ptKVxuKi9cbmltcG9ydCB7IHN0eWxlZCB9IGZyb20gJ0BsaW5hcmlhL3JlYWN0JztcbmV4cG9ydCBjb25zdCBRUlBsYWNlaG9sZGVyID0gc3R5bGVkLmRpdiBgXG4gIG1hcmdpbjogYXV0bztcbiAgdGV4dC1hbGlnbjogY2VudGVyO1xuICB3aWR0aDogMzQwcHg7IFxuYDtcbmV4cG9ydCBjb25zdCBGb290ZXJCYXIgPSBzdHlsZWQuZm9vdGVyIGBcbiAgdGV4dC1hbGlnbjogY2VudGVyO1xuICBiYWNrZ3JvdW5kLWNvbG9yOiAjMDMzO1xuICBjb2xvcjogd2hpdGU7XG4gIHBhZGRpbmc6IDFlbTtcbiAgb3ZlcmZsb3c6IGF1dG87XG5cbiAgJiA+IHAgPiBhOmxpbmssXG4gICYgPiBwID4gYTp2aXNpdGVkLFxuICAmID4gcCA+IGE6aG92ZXIsXG4gICYgPiBwID4gYTphY3RpdmUge1xuICAgIGNvbG9yOiB3aGl0ZTtcbiAgfVxuYDtcbmV4cG9ydCBjb25zdCBQYWdlID0gc3R5bGVkLmRpdiBgXG4gIGRpc3BsYXk6IGZsZXg7XG4gIGZsZXgtZGlyZWN0aW9uOiBjb2x1bW47XG4gIGp1c3RpZnktY29udGVudDogc3BhY2UtYmV0d2VlbjtcbiAgbWluLWhlaWdodDogMTAwdmg7XG4gIGFsaWduLWl0ZW1zOiBjZW50ZXI7XG4gIFxuICBhOmxpbmssXG4gIGE6dmlzaXRlZCxcbiAgYTpob3ZlcixcbiAgYTphY3RpdmUge1xuICAgIGNvbG9yOiBibGFjaztcbiAgfVxuICBcbiAgc2VjdGlvbiB7XG4gICAgdGV4dC1hbGlnbjogY2VudGVyO1xuICAgIHdpZHRoOiA2MDBweDtcbiAgICAvKiBtYXJnaW46IGF1dG87ICovXG4gICAgLyogbWFyZ2luLXRvcDogMHB4OyAqL1xuICAgIG1hcmdpbi1ib3R0b206IGF1dG87XG4gICAgLyogb3ZlcmZsb3c6IGF1dG87ICovXG4gIH1cbiAgc2VjdGlvbjpub3QoOmZpcnN0LW9mLXR5cGUpIHtcbiAgICBtYXJnaW4tdG9wOiAyZW07XG4gIH1cbiAgJiA+IGhlYWRlciB7XG4gICAgZGlzcGxheTogZmxleDtcbiAgICBmbGV4LWRpcmVjdGlvbjogcm93O1xuICAgIGp1c3RpZnktY29udGVudDogc3BhY2UtYmV0d2VlbjtcbiAgICB0ZXh0LWFsaWduOiBjZW50ZXI7XG4gIH1cbiAgJiA+IGZvb3RlciB7XG4gICAgZGlzcGxheTogZmxleDsgICAgXG4gICAgZmxleC1kaXJlY3Rpb246IHJvdztcbiAgICBqdXN0aWZ5LWNvbnRlbnQ6IHNwYWNlLWFyb3VuZDtcbiAgICB3aWR0aDogMTAwJTtcbiAgICBtYXJnaW4tYm90dG9tOiAwcHg7XG4gIH1cbmA7XG5leHBvcnQgY29uc3QgQ2VudGVyID0gc3R5bGVkLmRpdiBgXG4gIGRpc3BsYXk6IGZsZXg7XG4gIGp1c3RpZnktY29udGVudDogY2VudGVyO1xuYDtcbmV4cG9ydCBjb25zdCBXYWxsZXRMaW5rID0gc3R5bGVkLmEgYFxuICBkaXNwbGF5OiBpbmxpbmUtYmxvY2s7XG4gIHpvb206IDE7XG4gIGxpbmUtaGVpZ2h0OiBub3JtYWw7XG4gIHdoaXRlLXNwYWNlOiBub3dyYXA7XG4gIHZlcnRpY2FsLWFsaWduOiBtaWRkbGU7XG4gIHRleHQtYWxpZ246IGNlbnRlcjtcbiAgY3Vyc29yOiBwb2ludGVyO1xuICB1c2VyLXNlbGVjdDogbm9uZTtcbiAgYm94LXNpemluZzogYm9yZGVyLWJveDtcbiAgdGV4dC10cmFuc2Zvcm06ICR7KHsgdXBwZXJDYXNlZCB9KSA9PiB1cHBlckNhc2VkID8gJ3VwcGVyY2FzZScgOiAnbm9uZSd9O1xuXG4gIGZvbnQtZmFtaWx5OiBpbmhlcml0O1xuICBmb250LXNpemU6IDEwMCU7XG4gIHBhZGRpbmc6IDAuNWVtIDFlbTtcbiAgY29sb3I6ICM0NDQ7IC8qIHJnYmEgbm90IHN1cHBvcnRlZCAoSUUgOCkgKi9cbiAgY29sb3I6IHJnYmEoMCwgMCwgMCwgMC44KTsgLyogcmdiYSBzdXBwb3J0ZWQgKi9cbiAgYm9yZGVyOiAxcHggc29saWQgIzk5OTsgLypJRSA2LzcvOCovXG4gIGJvcmRlcjogbm9uZSByZ2JhKDAsIDAsIDAsIDApOyAvKklFOSArIGV2ZXJ5dGhpbmcgZWxzZSovXG4gIGJhY2tncm91bmQtY29sb3I6ICcjZTZlNmU2JztcbiAgdGV4dC1kZWNvcmF0aW9uOiBub25lO1xuICBib3JkZXItcmFkaXVzOiAycHg7XG5cbiAgOmZvY3VzIHtcbiAgICBvdXRsaW5lOiAwO1xuICB9XG5cbiAgJjpkaXNhYmxlZCB7XG4gICAgYm9yZGVyOiBub25lO1xuICAgIGJhY2tncm91bmQtaW1hZ2U6IG5vbmU7XG4gICAgLyogY3NzbGludCBpZ25vcmU6c3RhcnQgKi9cbiAgICBmaWx0ZXI6IGFscGhhKG9wYWNpdHk9NDApO1xuICAgIC8qIGNzc2xpbnQgaWdub3JlOmVuZCAqL1xuICAgIG9wYWNpdHk6IDAuNDtcbiAgICBjdXJzb3I6IG5vdC1hbGxvd2VkO1xuICAgIGJveC1zaGFkb3c6IG5vbmU7XG4gICAgcG9pbnRlci1ldmVudHM6IG5vbmU7XG4gIH1cblxuICA6aG92ZXIge1xuICAgIGZpbHRlcjogYWxwaGEob3BhY2l0eT05MCk7XG4gICAgYmFja2dyb3VuZC1pbWFnZTogbGluZWFyLWdyYWRpZW50KFxuICAgICAgdHJhbnNwYXJlbnQsXG4gICAgICByZ2JhKDAsIDAsIDAsIDAuMDUpIDQwJSxcbiAgICAgIHJnYmEoMCwgMCwgMCwgMC4xKVxuICAgICk7XG4gIH1cblxuICBiYWNrZ3JvdW5kLWNvbG9yOiAjZTZlNmU2O1xuICBib3JkZXItcmFkaXVzOiA0cHg7XG4gIHRleHQtc2hhZG93OiAwIDFweCAxcHggcmdiYSgwLCAwLCAwLCAwLjIpO1xuICBib3gtc2hhZG93OiAwIDAgMCAxcHggcmdiYSgwLCAwLCAwLCAwLjE1KSBpbnNldCxcbiAgICAwIDAgNnB4IHJnYmEoMCwgMCwgMCwgMC4yKSBpbnNldDtcbiAgYm9yZGVyLWNvbG9yOiAjMDAwO1xuYDtcbmV4cG9ydCBjb25zdCBJbmZvQm94ID0gc3R5bGVkLmRpdiBgXG4gIGJvcmRlci1yYWRpdXM6IDAuMjVlbTtcbiAgZmxleC1kaXJlY3Rpb246IGNvbHVtbjtcbiAgLyogbWFyZ2luOiAwLjVlbTsgKi9cbiAgcGFkZGluZzogMWVtO1xuICAvKiB3aWR0aDogMTAwJTsgKi9cbiAgYm9yZGVyOnNvbGlkIDFweCAjYjhkYWZmO1xuICBiYWNrZ3JvdW5kLWNvbG9yOiNjY2U1ZmY7XG4gIGNvbG9yOiMwMDQwODU7XG5gO1xuZXhwb3J0IGNvbnN0IFRhYmxlRXhwYW5kZWQgPSBzdHlsZWQuZGwgYFxuICB0ZXh0LWFsaWduOiBsZWZ0O1xuICBkdCB7XG4gICAgZm9udC13ZWlnaHQ6IGJvbGQ7XG4gICAgbWFyZ2luLXRvcDogMWVtO1xuICB9XG4gIGRkIHtcbiAgICBtYXJnaW4taW5saW5lLXN0YXJ0OiAwcHg7XG4gIH1cbmA7XG5leHBvcnQgY29uc3QgVGFibGVTaW1wbGUgPSBzdHlsZWQuZGwgYFxuICB0ZXh0LWFsaWduOiBsZWZ0O1xuICBkdCB7XG4gICAgZm9udC13ZWlnaHQ6IGJvbGQ7XG4gICAgZGlzcGxheTogaW5saW5lLWJsb2NrO1xuICAgIHdpZHRoOjMwJTtcbiAgfVxuICBkZCB7XG4gICAgbWFyZ2luLWlubGluZS1zdGFydDogMHB4O1xuICAgIGRpc3BsYXk6IGlubGluZS1ibG9jaztcbiAgICB3aWR0aDo3MCU7XG4gIH1cbmA7XG4iXX0=*/</style>
</head>
<script id="built_time_data">
</script>
<body>
- <h1>Order details</h1><div>This is the default status page for your order for <b>{{ order_summary }}</b>.</div><h2>Refund status</h2><div>The merchant has granted you refunds on the purchase of <b>{{ refund_amount }}</b>.</div><h2>Full contract details</h2><pre><table><tr><td>amount</td><td>{{ contract_terms.amount }}</td></tr><tr><td>summary</td><td>{{ contract_terms.summary }}</td></tr><tr><td>pay deadline</td><td>{{ contract_terms.pay_deadline.t_ms }}</td></tr><tr><td>merchant name</td><td>{{ contract_terms.merchant.name }}</td></tr></table><div>{{{contract_terms!stringify }}}</div></pre>
+ <div class="p1b3vqup"><header><h1>Details of order {{ contract_terms.order_id }}</h1></header><section><section><dl class="t2c81u8"><dt>Order summary:</dt><dd>{{ contract_terms.summary }}</dd><dt>Amount paid:</dt><dd>{{ contract_terms.amount }}</dd><dt>Order date:</dt><dd>{{ contract_terms.timestamp_str }} </dd><dt>Merchant name:</dt><dd>{{ contract_terms.merchant.name }}</dd></dl></section><section><h2>Full payment information</h2><dl class="t2c81u8"><dt>Amount paid:</dt><dd>{{ contract_terms.amount }}</dd><dt>Wire transfer method:</dt><dd>{{ contract_terms.wire_method }}</dd><dt>Payment deadline:</dt><dd>{{ contract_terms.pay_deadline_str }} </dd><dt>Exchange transfer deadline:</dt><dd>{{ contract_terms.wire_transfer_deadline_str }} </dd><dt>Maximum deposit fee:</dt><dd>{{ contract_terms.max_fee }}</dd><dt>Maximum wire fee:</dt><dd>{{ contract_terms.max_wire_fee }}</dd><dt>Wire fee amortization:</dt><dd>{{ contract_terms.wire_fee_amortization }} transactions</dd></dl></section><section><h2>Refund information</h2><dl class="t2c81u8"><dt>Refund deadline:</dt><dd>{{ contract_terms.refund_deadline_str }} </dd></dl></section><section><h2>Additional order details</h2><dl class="t2c81u8"><dt>Public reorder URL:</dt><dd> -- not defined yet -- </dd></dl></section><section><h2>Full merchant information</h2><dl class="t2c81u8"><dt>Merchant name:</dt><dd>{{ contract_terms.merchant.name }}</dd><dt>Merchant address:</dt><dd> </dd><dd> </dd><dd></dd><dd></dd><dd></dd><dd></dd><dd></dd><dt>Merchant's jurisdiction:</dt><dd> </dd><dd> </dd><dd></dd><dd></dd><dd></dd><dd></dd><dd></dd><dt>Merchant URI:</dt><dd>{{ contract_terms.merchant_base_url }}</dd><dt>Merchant's public key:</dt><dd>{{ contract_terms.merchant_pub }}</dd></dl></section></section><footer class="fef0x5t"><p><a href="https://taler.net/">Learn more about GNU Taler on our website.</a><p>Copyright © 2014—2021 Taler Systems SA</p></p></footer></div>
<script>var page = (function (exports) {
- 'use strict';
+ 'use strict';
- var n$1,u$2,i$2,t$1,r$2={},f$2=[],e$1=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i;function c$2(n,l){for(var u in l)n[u]=l[u];return n}function s$1(n){var l=n.parentNode;l&&l.removeChild(n);}function a$2(n,l,u){var i,t,o,r=arguments,f={};for(o in l)"key"==o?i=l[o]:"ref"==o?t=l[o]:f[o]=l[o];if(arguments.length>3)for(u=[u],o=3;o<arguments.length;o++)u.push(r[o]);if(null!=u&&(f.children=u),"function"==typeof n&&null!=n.defaultProps)for(o in n.defaultProps)void 0===f[o]&&(f[o]=n.defaultProps[o]);return v$2(n,f,i,t,null)}function v$2(l,u,i,t,o){var r={type:l,props:u,key:i,ref:t,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,__h:null,constructor:void 0,__v:null==o?++n$1.__v:o};return null!=n$1.vnode&&n$1.vnode(r),r}function y$1(n){return n.children}function p$1(n,l){this.props=n,this.context=l;}function d$1(n,l){if(null==l)return n.__?d$1(n.__,n.__.__k.indexOf(n)+1):null;for(var u;l<n.__k.length;l++)if(null!=(u=n.__k[l])&&null!=u.__e)return u.__e;return "function"==typeof n.type?d$1(n):null}function _$1(n){var l,u;if(null!=(n=n.__)&&null!=n.__c){for(n.__e=n.__c.base=null,l=0;l<n.__k.length;l++)if(null!=(u=n.__k[l])&&null!=u.__e){n.__e=n.__c.base=u.__e;break}return _$1(n)}}function k$1(l){(!l.__d&&(l.__d=!0)&&u$2.push(l)&&!b$1.__r++||t$1!==n$1.debounceRendering)&&((t$1=n$1.debounceRendering)||i$2)(b$1);}function b$1(){for(var n;b$1.__r=u$2.length;)n=u$2.sort(function(n,l){return n.__v.__b-l.__v.__b}),u$2=[],n.some(function(n){var l,u,i,t,o,r;n.__d&&(o=(t=(l=n).__v).__e,(r=l.__P)&&(u=[],(i=c$2({},t)).__v=t.__v+1,I(r,t,i,l.__n,void 0!==r.ownerSVGElement,null!=t.__h?[o]:null,u,null==o?d$1(t):o,t.__h),T(u,t),t.__e!=o&&_$1(t)));});}function m$2(n,l,u,i,t,o,e,c,s,a){var h,p,_,k,b,m,w,A=i&&i.__k||f$2,P=A.length;for(u.__k=[],h=0;h<l.length;h++)if(null!=(k=u.__k[h]=null==(k=l[h])||"boolean"==typeof k?null:"string"==typeof k||"number"==typeof k||"bigint"==typeof k?v$2(null,k,null,null,k):Array.isArray(k)?v$2(y$1,{children:k},null,null,null):k.__b>0?v$2(k.type,k.props,k.key,null,k.__v):k)){if(k.__=u,k.__b=u.__b+1,null===(_=A[h])||_&&k.key==_.key&&k.type===_.type)A[h]=void 0;else for(p=0;p<P;p++){if((_=A[p])&&k.key==_.key&&k.type===_.type){A[p]=void 0;break}_=null;}I(n,k,_=_||r$2,t,o,e,c,s,a),b=k.__e,(p=k.ref)&&_.ref!=p&&(w||(w=[]),_.ref&&w.push(_.ref,null,k),w.push(p,k.__c||b,k)),null!=b?(null==m&&(m=b),"function"==typeof k.type&&null!=k.__k&&k.__k===_.__k?k.__d=s=g$2(k,s,n):s=x$2(n,k,_,A,b,s),a||"option"!==u.type?"function"==typeof u.type&&(u.__d=s):n.value=""):s&&_.__e==s&&s.parentNode!=n&&(s=d$1(_));}for(u.__e=m,h=P;h--;)null!=A[h]&&("function"==typeof u.type&&null!=A[h].__e&&A[h].__e==u.__d&&(u.__d=d$1(i,h+1)),L(A[h],A[h]));if(w)for(h=0;h<w.length;h++)z(w[h],w[++h],w[++h]);}function g$2(n,l,u){var i,t;for(i=0;i<n.__k.length;i++)(t=n.__k[i])&&(t.__=n,l="function"==typeof t.type?g$2(t,l,u):x$2(u,t,t,n.__k,t.__e,l));return l}function x$2(n,l,u,i,t,o){var r,f,e;if(void 0!==l.__d)r=l.__d,l.__d=void 0;else if(null==u||t!=o||null==t.parentNode)n:if(null==o||o.parentNode!==n)n.appendChild(t),r=null;else {for(f=o,e=0;(f=f.nextSibling)&&e<i.length;e+=2)if(f==t)break n;n.insertBefore(t,o),r=o;}return void 0!==r?r:t.nextSibling}function A(n,l,u,i,t){var o;for(o in u)"children"===o||"key"===o||o in l||C(n,o,null,u[o],i);for(o in l)t&&"function"!=typeof l[o]||"children"===o||"key"===o||"value"===o||"checked"===o||u[o]===l[o]||C(n,o,l[o],u[o],i);}function P(n,l,u){"-"===l[0]?n.setProperty(l,u):n[l]=null==u?"":"number"!=typeof u||e$1.test(l)?u:u+"px";}function C(n,l,u,i,t){var o;n:if("style"===l)if("string"==typeof u)n.style.cssText=u;else {if("string"==typeof i&&(n.style.cssText=i=""),i)for(l in i)u&&l in u||P(n.style,l,"");if(u)for(l in u)i&&u[l]===i[l]||P(n.style,l,u[l]);}else if("o"===l[0]&&"n"===l[1])o=l!==(l=l.replace(/Capture$/,"")),l=l.toLowerCase()in n?l.toLowerCase().slice(2):l.slice(2),n.l||(n.l={}),n.l[l+o]=u,u?i||n.addEventListener(l,o?H:$,o):n.removeEventListener(l,o?H:$,o);else if("dangerouslySetInnerHTML"!==l){if(t)l=l.replace(/xlink[H:h]/,"h").replace(/sName$/,"s");else if("href"!==l&&"list"!==l&&"form"!==l&&"tabIndex"!==l&&"download"!==l&&l in n)try{n[l]=null==u?"":u;break n}catch(n){}"function"==typeof u||(null!=u&&(!1!==u||"a"===l[0]&&"r"===l[1])?n.setAttribute(l,u):n.removeAttribute(l));}}function $(l){this.l[l.type+!1](n$1.event?n$1.event(l):l);}function H(l){this.l[l.type+!0](n$1.event?n$1.event(l):l);}function I(l,u,i,t,o,r,f,e,s){var a,v,h,d,_,k,b,g,w,x,A,P=u.type;if(void 0!==u.constructor)return null;null!=i.__h&&(s=i.__h,e=u.__e=i.__e,u.__h=null,r=[e]),(a=n$1.__b)&&a(u);try{n:if("function"==typeof P){if(g=u.props,w=(a=P.contextType)&&t[a.__c],x=a?w?w.props.value:a.__:t,i.__c?b=(v=u.__c=i.__c).__=v.__E:("prototype"in P&&P.prototype.render?u.__c=v=new P(g,x):(u.__c=v=new p$1(g,x),v.constructor=P,v.render=M),w&&w.sub(v),v.props=g,v.state||(v.state={}),v.context=x,v.__n=t,h=v.__d=!0,v.__h=[]),null==v.__s&&(v.__s=v.state),null!=P.getDerivedStateFromProps&&(v.__s==v.state&&(v.__s=c$2({},v.__s)),c$2(v.__s,P.getDerivedStateFromProps(g,v.__s))),d=v.props,_=v.state,h)null==P.getDerivedStateFromProps&&null!=v.componentWillMount&&v.componentWillMount(),null!=v.componentDidMount&&v.__h.push(v.componentDidMount);else {if(null==P.getDerivedStateFromProps&&g!==d&&null!=v.componentWillReceiveProps&&v.componentWillReceiveProps(g,x),!v.__e&&null!=v.shouldComponentUpdate&&!1===v.shouldComponentUpdate(g,v.__s,x)||u.__v===i.__v){v.props=g,v.state=v.__s,u.__v!==i.__v&&(v.__d=!1),v.__v=u,u.__e=i.__e,u.__k=i.__k,u.__k.forEach(function(n){n&&(n.__=u);}),v.__h.length&&f.push(v);break n}null!=v.componentWillUpdate&&v.componentWillUpdate(g,v.__s,x),null!=v.componentDidUpdate&&v.__h.push(function(){v.componentDidUpdate(d,_,k);});}v.context=x,v.props=g,v.state=v.__s,(a=n$1.__r)&&a(u),v.__d=!1,v.__v=u,v.__P=l,a=v.render(v.props,v.state,v.context),v.state=v.__s,null!=v.getChildContext&&(t=c$2(c$2({},t),v.getChildContext())),h||null==v.getSnapshotBeforeUpdate||(k=v.getSnapshotBeforeUpdate(d,_)),A=null!=a&&a.type===y$1&&null==a.key?a.props.children:a,m$2(l,Array.isArray(A)?A:[A],u,i,t,o,r,f,e,s),v.base=u.__e,u.__h=null,v.__h.length&&f.push(v),b&&(v.__E=v.__=null),v.__e=!1;}else null==r&&u.__v===i.__v?(u.__k=i.__k,u.__e=i.__e):u.__e=j$1(i.__e,u,i,t,o,r,f,s);(a=n$1.diffed)&&a(u);}catch(l){u.__v=null,(s||null!=r)&&(u.__e=e,u.__h=!!s,r[r.indexOf(e)]=null),n$1.__e(l,u,i);}}function T(l,u){n$1.__c&&n$1.__c(u,l),l.some(function(u){try{l=u.__h,u.__h=[],l.some(function(n){n.call(u);});}catch(l){n$1.__e(l,u.__v);}});}function j$1(n,l,u,i,t,o,e,c){var a,v,h,y,p=u.props,d=l.props,_=l.type,k=0;if("svg"===_&&(t=!0),null!=o)for(;k<o.length;k++)if((a=o[k])&&(a===n||(_?a.localName==_:3==a.nodeType))){n=a,o[k]=null;break}if(null==n){if(null===_)return document.createTextNode(d);n=t?document.createElementNS("http://www.w3.org/2000/svg",_):document.createElement(_,d.is&&d),o=null,c=!1;}if(null===_)p===d||c&&n.data===d||(n.data=d);else {if(o=o&&f$2.slice.call(n.childNodes),v=(p=u.props||r$2).dangerouslySetInnerHTML,h=d.dangerouslySetInnerHTML,!c){if(null!=o)for(p={},y=0;y<n.attributes.length;y++)p[n.attributes[y].name]=n.attributes[y].value;(h||v)&&(h&&(v&&h.__html==v.__html||h.__html===n.innerHTML)||(n.innerHTML=h&&h.__html||""));}if(A(n,d,p,t,c),h)l.__k=[];else if(k=l.props.children,m$2(n,Array.isArray(k)?k:[k],l,u,i,t&&"foreignObject"!==_,o,e,n.firstChild,c),null!=o)for(k=o.length;k--;)null!=o[k]&&s$1(o[k]);c||("value"in d&&void 0!==(k=d.value)&&(k!==n.value||"progress"===_&&!k)&&C(n,"value",k,p.value,!1),"checked"in d&&void 0!==(k=d.checked)&&k!==n.checked&&C(n,"checked",k,p.checked,!1));}return n}function z(l,u,i){try{"function"==typeof l?l(u):l.current=u;}catch(l){n$1.__e(l,i);}}function L(l,u,i){var t,o,r;if(n$1.unmount&&n$1.unmount(l),(t=l.ref)&&(t.current&&t.current!==l.__e||z(t,null,u)),i||"function"==typeof l.type||(i=null!=(o=l.__e)),l.__e=l.__d=void 0,null!=(t=l.__c)){if(t.componentWillUnmount)try{t.componentWillUnmount();}catch(l){n$1.__e(l,u);}t.base=t.__P=null;}if(t=l.__k)for(r=0;r<t.length;r++)t[r]&&L(t[r],u,i);null!=o&&s$1(o);}function M(n,l,u){return this.constructor(n,u)}function N(l,u,i){var t,o,e;n$1.__&&n$1.__(l,u),o=(t="function"==typeof i)?null:i&&i.__k||u.__k,e=[],I(u,l=(!t&&i||u).__k=a$2(y$1,null,[l]),o||r$2,r$2,void 0!==u.ownerSVGElement,!t&&i?[i]:o?null:u.firstChild?f$2.slice.call(u.childNodes):null,e,!t&&i?i:o?o.__e:u.firstChild,t),T(e,l);}n$1={__e:function(n,l){for(var u,i,t;l=l.__;)if((u=l.__c)&&!u.__)try{if((i=u.constructor)&&null!=i.getDerivedStateFromError&&(u.setState(i.getDerivedStateFromError(n)),t=u.__d),null!=u.componentDidCatch&&(u.componentDidCatch(n),t=u.__d),t)return u.__E=u}catch(l){n=l;}throw n},__v:0},p$1.prototype.setState=function(n,l){var u;u=null!=this.__s&&this.__s!==this.state?this.__s:this.__s=c$2({},this.state),"function"==typeof n&&(n=n(c$2({},u),this.props)),n&&c$2(u,n),null!=n&&this.__v&&(l&&this.__h.push(l),k$1(this));},p$1.prototype.forceUpdate=function(n){this.__v&&(this.__e=!0,n&&this.__h.push(n),k$1(this));},p$1.prototype.render=y$1,u$2=[],i$2="function"==typeof Promise?Promise.prototype.then.bind(Promise.resolve()):setTimeout,b$1.__r=0;
+ var n$1,u$2,i$2,t$1,r$2={},f$2=[],e$1=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i;function c$2(n,l){for(var u in l)n[u]=l[u];return n}function s$1(n){var l=n.parentNode;l&&l.removeChild(n);}function a$2(n,l,u){var i,t,o,r=arguments,f={};for(o in l)"key"==o?i=l[o]:"ref"==o?t=l[o]:f[o]=l[o];if(arguments.length>3)for(u=[u],o=3;o<arguments.length;o++)u.push(r[o]);if(null!=u&&(f.children=u),"function"==typeof n&&null!=n.defaultProps)for(o in n.defaultProps)void 0===f[o]&&(f[o]=n.defaultProps[o]);return v$2(n,f,i,t,null)}function v$2(l,u,i,t,o){var r={type:l,props:u,key:i,ref:t,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,__h:null,constructor:void 0,__v:null==o?++n$1.__v:o};return null!=n$1.vnode&&n$1.vnode(r),r}function y$1(n){return n.children}function p$1(n,l){this.props=n,this.context=l;}function d$1(n,l){if(null==l)return n.__?d$1(n.__,n.__.__k.indexOf(n)+1):null;for(var u;l<n.__k.length;l++)if(null!=(u=n.__k[l])&&null!=u.__e)return u.__e;return "function"==typeof n.type?d$1(n):null}function _$1(n){var l,u;if(null!=(n=n.__)&&null!=n.__c){for(n.__e=n.__c.base=null,l=0;l<n.__k.length;l++)if(null!=(u=n.__k[l])&&null!=u.__e){n.__e=n.__c.base=u.__e;break}return _$1(n)}}function k$1(l){(!l.__d&&(l.__d=!0)&&u$2.push(l)&&!b$1.__r++||t$1!==n$1.debounceRendering)&&((t$1=n$1.debounceRendering)||i$2)(b$1);}function b$1(){for(var n;b$1.__r=u$2.length;)n=u$2.sort(function(n,l){return n.__v.__b-l.__v.__b}),u$2=[],n.some(function(n){var l,u,i,t,o,r;n.__d&&(o=(t=(l=n).__v).__e,(r=l.__P)&&(u=[],(i=c$2({},t)).__v=t.__v+1,I(r,t,i,l.__n,void 0!==r.ownerSVGElement,null!=t.__h?[o]:null,u,null==o?d$1(t):o,t.__h),T(u,t),t.__e!=o&&_$1(t)));});}function m$2(n,l,u,i,t,o,e,c,s,a){var h,p,_,k,b,m,w,A=i&&i.__k||f$2,P=A.length;for(u.__k=[],h=0;h<l.length;h++)if(null!=(k=u.__k[h]=null==(k=l[h])||"boolean"==typeof k?null:"string"==typeof k||"number"==typeof k||"bigint"==typeof k?v$2(null,k,null,null,k):Array.isArray(k)?v$2(y$1,{children:k},null,null,null):k.__b>0?v$2(k.type,k.props,k.key,null,k.__v):k)){if(k.__=u,k.__b=u.__b+1,null===(_=A[h])||_&&k.key==_.key&&k.type===_.type)A[h]=void 0;else for(p=0;p<P;p++){if((_=A[p])&&k.key==_.key&&k.type===_.type){A[p]=void 0;break}_=null;}I(n,k,_=_||r$2,t,o,e,c,s,a),b=k.__e,(p=k.ref)&&_.ref!=p&&(w||(w=[]),_.ref&&w.push(_.ref,null,k),w.push(p,k.__c||b,k)),null!=b?(null==m&&(m=b),"function"==typeof k.type&&null!=k.__k&&k.__k===_.__k?k.__d=s=g$2(k,s,n):s=x$3(n,k,_,A,b,s),a||"option"!==u.type?"function"==typeof u.type&&(u.__d=s):n.value=""):s&&_.__e==s&&s.parentNode!=n&&(s=d$1(_));}for(u.__e=m,h=P;h--;)null!=A[h]&&("function"==typeof u.type&&null!=A[h].__e&&A[h].__e==u.__d&&(u.__d=d$1(i,h+1)),L$1(A[h],A[h]));if(w)for(h=0;h<w.length;h++)z(w[h],w[++h],w[++h]);}function g$2(n,l,u){var i,t;for(i=0;i<n.__k.length;i++)(t=n.__k[i])&&(t.__=n,l="function"==typeof t.type?g$2(t,l,u):x$3(u,t,t,n.__k,t.__e,l));return l}function w$1(n,l){return l=l||[],null==n||"boolean"==typeof n||(Array.isArray(n)?n.some(function(n){w$1(n,l);}):l.push(n)),l}function x$3(n,l,u,i,t,o){var r,f,e;if(void 0!==l.__d)r=l.__d,l.__d=void 0;else if(null==u||t!=o||null==t.parentNode)n:if(null==o||o.parentNode!==n)n.appendChild(t),r=null;else {for(f=o,e=0;(f=f.nextSibling)&&e<i.length;e+=2)if(f==t)break n;n.insertBefore(t,o),r=o;}return void 0!==r?r:t.nextSibling}function A$1(n,l,u,i,t){var o;for(o in u)"children"===o||"key"===o||o in l||C$1(n,o,null,u[o],i);for(o in l)t&&"function"!=typeof l[o]||"children"===o||"key"===o||"value"===o||"checked"===o||u[o]===l[o]||C$1(n,o,l[o],u[o],i);}function P$1(n,l,u){"-"===l[0]?n.setProperty(l,u):n[l]=null==u?"":"number"!=typeof u||e$1.test(l)?u:u+"px";}function C$1(n,l,u,i,t){var o;n:if("style"===l)if("string"==typeof u)n.style.cssText=u;else {if("string"==typeof i&&(n.style.cssText=i=""),i)for(l in i)u&&l in u||P$1(n.style,l,"");if(u)for(l in u)i&&u[l]===i[l]||P$1(n.style,l,u[l]);}else if("o"===l[0]&&"n"===l[1])o=l!==(l=l.replace(/Capture$/,"")),l=l.toLowerCase()in n?l.toLowerCase().slice(2):l.slice(2),n.l||(n.l={}),n.l[l+o]=u,u?i||n.addEventListener(l,o?H$1:$$1,o):n.removeEventListener(l,o?H$1:$$1,o);else if("dangerouslySetInnerHTML"!==l){if(t)l=l.replace(/xlink[H:h]/,"h").replace(/sName$/,"s");else if("href"!==l&&"list"!==l&&"form"!==l&&"tabIndex"!==l&&"download"!==l&&l in n)try{n[l]=null==u?"":u;break n}catch(n){}"function"==typeof u||(null!=u&&(!1!==u||"a"===l[0]&&"r"===l[1])?n.setAttribute(l,u):n.removeAttribute(l));}}function $$1(l){this.l[l.type+!1](n$1.event?n$1.event(l):l);}function H$1(l){this.l[l.type+!0](n$1.event?n$1.event(l):l);}function I(l,u,i,t,o,r,f,e,s){var a,v,h,d,_,k,b,g,w,x,A,P=u.type;if(void 0!==u.constructor)return null;null!=i.__h&&(s=i.__h,e=u.__e=i.__e,u.__h=null,r=[e]),(a=n$1.__b)&&a(u);try{n:if("function"==typeof P){if(g=u.props,w=(a=P.contextType)&&t[a.__c],x=a?w?w.props.value:a.__:t,i.__c?b=(v=u.__c=i.__c).__=v.__E:("prototype"in P&&P.prototype.render?u.__c=v=new P(g,x):(u.__c=v=new p$1(g,x),v.constructor=P,v.render=M$1),w&&w.sub(v),v.props=g,v.state||(v.state={}),v.context=x,v.__n=t,h=v.__d=!0,v.__h=[]),null==v.__s&&(v.__s=v.state),null!=P.getDerivedStateFromProps&&(v.__s==v.state&&(v.__s=c$2({},v.__s)),c$2(v.__s,P.getDerivedStateFromProps(g,v.__s))),d=v.props,_=v.state,h)null==P.getDerivedStateFromProps&&null!=v.componentWillMount&&v.componentWillMount(),null!=v.componentDidMount&&v.__h.push(v.componentDidMount);else {if(null==P.getDerivedStateFromProps&&g!==d&&null!=v.componentWillReceiveProps&&v.componentWillReceiveProps(g,x),!v.__e&&null!=v.shouldComponentUpdate&&!1===v.shouldComponentUpdate(g,v.__s,x)||u.__v===i.__v){v.props=g,v.state=v.__s,u.__v!==i.__v&&(v.__d=!1),v.__v=u,u.__e=i.__e,u.__k=i.__k,u.__k.forEach(function(n){n&&(n.__=u);}),v.__h.length&&f.push(v);break n}null!=v.componentWillUpdate&&v.componentWillUpdate(g,v.__s,x),null!=v.componentDidUpdate&&v.__h.push(function(){v.componentDidUpdate(d,_,k);});}v.context=x,v.props=g,v.state=v.__s,(a=n$1.__r)&&a(u),v.__d=!1,v.__v=u,v.__P=l,a=v.render(v.props,v.state,v.context),v.state=v.__s,null!=v.getChildContext&&(t=c$2(c$2({},t),v.getChildContext())),h||null==v.getSnapshotBeforeUpdate||(k=v.getSnapshotBeforeUpdate(d,_)),A=null!=a&&a.type===y$1&&null==a.key?a.props.children:a,m$2(l,Array.isArray(A)?A:[A],u,i,t,o,r,f,e,s),v.base=u.__e,u.__h=null,v.__h.length&&f.push(v),b&&(v.__E=v.__=null),v.__e=!1;}else null==r&&u.__v===i.__v?(u.__k=i.__k,u.__e=i.__e):u.__e=j$1(i.__e,u,i,t,o,r,f,s);(a=n$1.diffed)&&a(u);}catch(l){u.__v=null,(s||null!=r)&&(u.__e=e,u.__h=!!s,r[r.indexOf(e)]=null),n$1.__e(l,u,i);}}function T(l,u){n$1.__c&&n$1.__c(u,l),l.some(function(u){try{l=u.__h,u.__h=[],l.some(function(n){n.call(u);});}catch(l){n$1.__e(l,u.__v);}});}function j$1(n,l,u,i,t,o,e,c){var a,v,h,y,p=u.props,d=l.props,_=l.type,k=0;if("svg"===_&&(t=!0),null!=o)for(;k<o.length;k++)if((a=o[k])&&(a===n||(_?a.localName==_:3==a.nodeType))){n=a,o[k]=null;break}if(null==n){if(null===_)return document.createTextNode(d);n=t?document.createElementNS("http://www.w3.org/2000/svg",_):document.createElement(_,d.is&&d),o=null,c=!1;}if(null===_)p===d||c&&n.data===d||(n.data=d);else {if(o=o&&f$2.slice.call(n.childNodes),v=(p=u.props||r$2).dangerouslySetInnerHTML,h=d.dangerouslySetInnerHTML,!c){if(null!=o)for(p={},y=0;y<n.attributes.length;y++)p[n.attributes[y].name]=n.attributes[y].value;(h||v)&&(h&&(v&&h.__html==v.__html||h.__html===n.innerHTML)||(n.innerHTML=h&&h.__html||""));}if(A$1(n,d,p,t,c),h)l.__k=[];else if(k=l.props.children,m$2(n,Array.isArray(k)?k:[k],l,u,i,t&&"foreignObject"!==_,o,e,n.firstChild,c),null!=o)for(k=o.length;k--;)null!=o[k]&&s$1(o[k]);c||("value"in d&&void 0!==(k=d.value)&&(k!==n.value||"progress"===_&&!k)&&C$1(n,"value",k,p.value,!1),"checked"in d&&void 0!==(k=d.checked)&&k!==n.checked&&C$1(n,"checked",k,p.checked,!1));}return n}function z(l,u,i){try{"function"==typeof l?l(u):l.current=u;}catch(l){n$1.__e(l,i);}}function L$1(l,u,i){var t,o,r;if(n$1.unmount&&n$1.unmount(l),(t=l.ref)&&(t.current&&t.current!==l.__e||z(t,null,u)),i||"function"==typeof l.type||(i=null!=(o=l.__e)),l.__e=l.__d=void 0,null!=(t=l.__c)){if(t.componentWillUnmount)try{t.componentWillUnmount();}catch(l){n$1.__e(l,u);}t.base=t.__P=null;}if(t=l.__k)for(r=0;r<t.length;r++)t[r]&&L$1(t[r],u,i);null!=o&&s$1(o);}function M$1(n,l,u){return this.constructor(n,u)}function N(l,u,i){var t,o,e;n$1.__&&n$1.__(l,u),o=(t="function"==typeof i)?null:i&&i.__k||u.__k,e=[],I(u,l=(!t&&i||u).__k=a$2(y$1,null,[l]),o||r$2,r$2,void 0!==u.ownerSVGElement,!t&&i?[i]:o?null:u.firstChild?f$2.slice.call(u.childNodes):null,e,!t&&i?i:o?o.__e:u.firstChild,t),T(e,l);}n$1={__e:function(n,l){for(var u,i,t;l=l.__;)if((u=l.__c)&&!u.__)try{if((i=u.constructor)&&null!=i.getDerivedStateFromError&&(u.setState(i.getDerivedStateFromError(n)),t=u.__d),null!=u.componentDidCatch&&(u.componentDidCatch(n),t=u.__d),t)return u.__E=u}catch(l){n=l;}throw n},__v:0},p$1.prototype.setState=function(n,l){var u;u=null!=this.__s&&this.__s!==this.state?this.__s:this.__s=c$2({},this.state),"function"==typeof n&&(n=n(c$2({},u),this.props)),n&&c$2(u,n),null!=n&&this.__v&&(l&&this.__h.push(l),k$1(this));},p$1.prototype.forceUpdate=function(n){this.__v&&(this.__e=!0,n&&this.__h.push(n),k$1(this));},p$1.prototype.render=y$1,u$2=[],i$2="function"==typeof Promise?Promise.prototype.then.bind(Promise.resolve()):setTimeout,b$1.__r=0;
- var r$1=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|^--/i,n=/[&<>"]/;function o$1(e){var t=String(e);return n.test(t)?t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;"):t}var a$1=function(e,t){return String(e).replace(/(\n+)/g,"$1"+(t||"\t"))},i$1=function(e,t,r){return String(e).length>(t||40)||!r&&-1!==String(e).indexOf("\n")||-1!==String(e).indexOf("<")},l={};function s(e){var t="";for(var n in e){var o=e[n];null!=o&&""!==o&&(t&&(t+=" "),t+="-"==n[0]?n:l[n]||(l[n]=n.replace(/([A-Z])/g,"-$1").toLowerCase()),t+=": ",t+=o,"number"==typeof o&&!1===r$1.test(n)&&(t+="px"),t+=";");}return t||void 0}function f$1(e,t){for(var r in t)e[r]=t[r];return e}function u$1(e,t){return Array.isArray(t)?t.reduce(u$1,e):null!=t&&!1!==t&&e.push(t),e}var c$1={shallow:!0},p=[],_=/^(area|base|br|col|embed|hr|img|input|link|meta|param|source|track|wbr)$/,v$1=/[\s\n\\/='"\0<>]/,d=function(){};m$1.render=m$1;var g$1=function(e,t){return m$1(e,t,c$1)},h=[];function m$1(t,r,n){r=r||{},n=n||{};var o=n$1.__s;n$1.__s=!0;var a=x$1(t,r,n);return n$1.__c&&n$1.__c(t,h),h.length=0,n$1.__s=o,a}function x$1(r,n,l,c,g,h){if(null==r||"boolean"==typeof r)return "";if("object"!=typeof r)return o$1(r);var m=l.pretty,y=m&&"string"==typeof m?m:"\t";if(Array.isArray(r)){for(var b="",S=0;S<r.length;S++)m&&S>0&&(b+="\n"),b+=x$1(r[S],n,l,c,g,h);return b}var w,k=r.type,O=r.props,C=!1;if("function"==typeof k){if(C=!0,!l.shallow||!c&&!1!==l.renderRootComponent){if(k===y$1){var A=[];return u$1(A,r.props.children),x$1(A,n,l,!1!==l.shallowHighOrder,g,h)}var H,j=r.__c={__v:r,context:n,props:r.props,setState:d,forceUpdate:d,__h:[]};if(n$1.__b&&n$1.__b(r),n$1.__r&&n$1.__r(r),k.prototype&&"function"==typeof k.prototype.render){var F=k.contextType,M=F&&n[F.__c],T=null!=F?M?M.props.value:F.__:n;(j=r.__c=new k(O,T)).__v=r,j._dirty=j.__d=!0,j.props=O,null==j.state&&(j.state={}),null==j._nextState&&null==j.__s&&(j._nextState=j.__s=j.state),j.context=T,k.getDerivedStateFromProps?j.state=f$1(f$1({},j.state),k.getDerivedStateFromProps(j.props,j.state)):j.componentWillMount&&(j.componentWillMount(),j.state=j._nextState!==j.state?j._nextState:j.__s!==j.state?j.__s:j.state),H=j.render(j.props,j.state,j.context);}else {var $=k.contextType,L=$&&n[$.__c];H=k.call(r.__c,O,null!=$?L?L.props.value:$.__:n);}return j.getChildContext&&(n=f$1(f$1({},n),j.getChildContext())),n$1.diffed&&n$1.diffed(r),x$1(H,n,l,!1!==l.shallowHighOrder,g,h)}k=(w=k).displayName||w!==Function&&w.name||function(e){var t=(Function.prototype.toString.call(e).match(/^\s*function\s+([^( ]+)/)||"")[1];if(!t){for(var r=-1,n=p.length;n--;)if(p[n]===e){r=n;break}r<0&&(r=p.push(e)-1),t="UnnamedComponent"+r;}return t}(w);}var E,D,N="<"+k;if(O){var P=Object.keys(O);l&&!0===l.sortAttributes&&P.sort();for(var R=0;R<P.length;R++){var U=P[R],W=O[U];if("children"!==U){if(!v$1.test(U)&&(l&&l.allAttributes||"key"!==U&&"ref"!==U&&"__self"!==U&&"__source"!==U&&"defaultValue"!==U)){if("className"===U){if(O.class)continue;U="class";}else g&&U.match(/^xlink:?./)&&(U=U.toLowerCase().replace(/^xlink:?/,"xlink:"));if("htmlFor"===U){if(O.for)continue;U="for";}"style"===U&&W&&"object"==typeof W&&(W=s(W)),"a"===U[0]&&"r"===U[1]&&"boolean"==typeof W&&(W=String(W));var q=l.attributeHook&&l.attributeHook(U,W,n,l,C);if(q||""===q)N+=q;else if("dangerouslySetInnerHTML"===U)D=W&&W.__html;else if("textarea"===k&&"value"===U)E=W;else if((W||0===W||""===W)&&"function"!=typeof W){if(!(!0!==W&&""!==W||(W=U,l&&l.xml))){N+=" "+U;continue}if("value"===U){if("select"===k){h=W;continue}"option"===k&&h==W&&(N+=" selected");}N+=" "+U+'="'+o$1(W)+'"';}}}else E=W;}}if(m){var z=N.replace(/\n\s*/," ");z===N||~z.indexOf("\n")?m&&~N.indexOf("\n")&&(N+="\n"):N=z;}if(N+=">",v$1.test(k))throw new Error(k+" is not a valid HTML tag name in "+N);var I,V=_.test(k)||l.voidElements&&l.voidElements.test(k),Z=[];if(D)m&&i$1(D)&&(D="\n"+y+a$1(D,y)),N+=D;else if(null!=E&&u$1(I=[],E).length){for(var B=m&&~N.indexOf("\n"),G=!1,J=0;J<I.length;J++){var K=I[J];if(null!=K&&!1!==K){var Q=x$1(K,n,l,!0,"svg"===k||"foreignObject"!==k&&g,h);if(m&&!B&&i$1(Q)&&(B=!0),Q)if(m){var X=Q.length>0&&"<"!=Q[0];G&&X?Z[Z.length-1]+=Q:Z.push(Q),G=X;}else Z.push(Q);}}if(m&&B)for(var Y=Z.length;Y--;)Z[Y]="\n"+y+a$1(Z[Y],y);}if(Z.length||D)N+=Z.join("");else if(l&&l.xml)return N.substring(0,N.length-1)+" />";return !V||I||D?(m&&~N.indexOf("\n")&&(N+="\n"),N+="</"+k+">"):N=N.replace(/>$/," />"),N}m$1.shallowRender=g$1;
-
- var t,u,r,o=0,i=[],c=n$1.__b,f=n$1.__r,e=n$1.diffed,a=n$1.__c,v=n$1.unmount;function m(t,r){n$1.__h&&n$1.__h(u,t,o||r),o=0;var i=u.__H||(u.__H={__:[],__h:[]});return t>=i.__.length&&i.__.push({}),i.__[t]}function y(r,o){var i=m(t++,3);!n$1.__s&&k(i.__H,o)&&(i.__=r,i.__H=o,u.__H.__h.push(i));}function x(){i.forEach(function(t){if(t.__P)try{t.__H.__h.forEach(g),t.__H.__h.forEach(j),t.__H.__h=[];}catch(u){t.__H.__h=[],n$1.__e(u,t.__v);}}),i=[];}n$1.__b=function(n){u=null,c&&c(n);},n$1.__r=function(n){f&&f(n),t=0;var r=(u=n.__c).__H;r&&(r.__h.forEach(g),r.__h.forEach(j),r.__h=[]);},n$1.diffed=function(t){e&&e(t);var o=t.__c;o&&o.__H&&o.__H.__h.length&&(1!==i.push(o)&&r===n$1.requestAnimationFrame||((r=n$1.requestAnimationFrame)||function(n){var t,u=function(){clearTimeout(r),b&&cancelAnimationFrame(t),setTimeout(n);},r=setTimeout(u,100);b&&(t=requestAnimationFrame(u));})(x)),u=void 0;},n$1.__c=function(t,u){u.some(function(t){try{t.__h.forEach(g),t.__h=t.__h.filter(function(n){return !n.__||j(n)});}catch(r){u.some(function(n){n.__h&&(n.__h=[]);}),u=[],n$1.__e(r,t.__v);}}),a&&a(t,u);},n$1.unmount=function(t){v&&v(t);var u=t.__c;if(u&&u.__H)try{u.__H.__.forEach(g);}catch(t){n$1.__e(t,u.__v);}};var b="function"==typeof requestAnimationFrame;function g(n){var t=u;"function"==typeof n.__c&&n.__c(),u=t;}function j(n){var t=u;n.__c=n.__(),u=t;}function k(n,t){return !n||n.length!==t.length||t.some(function(t,u){return t!==n[u]})}
-
- /*
- This file is part of GNU Taler
- (C) 2021 Taler Systems S.A.
+ var r$1=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|^--/i,n=/[&<>"]/;function o$1(e){var t=String(e);return n.test(t)?t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;"):t}var a$1=function(e,t){return String(e).replace(/(\n+)/g,"$1"+(t||"\t"))},i$1=function(e,t,r){return String(e).length>(t||40)||!r&&-1!==String(e).indexOf("\n")||-1!==String(e).indexOf("<")},l={};function s(e){var t="";for(var n in e){var o=e[n];null!=o&&""!==o&&(t&&(t+=" "),t+="-"==n[0]?n:l[n]||(l[n]=n.replace(/([A-Z])/g,"-$1").toLowerCase()),t+=": ",t+=o,"number"==typeof o&&!1===r$1.test(n)&&(t+="px"),t+=";");}return t||void 0}function f$1(e,t){for(var r in t)e[r]=t[r];return e}function u$1(e,t){return Array.isArray(t)?t.reduce(u$1,e):null!=t&&!1!==t&&e.push(t),e}var c$1={shallow:!0},p=[],_=/^(area|base|br|col|embed|hr|img|input|link|meta|param|source|track|wbr)$/,v$1=/[\s\n\\/='"\0<>]/,d=function(){};m$1.render=m$1;var g$1=function(e,t){return m$1(e,t,c$1)},h=[];function m$1(t,r,n){r=r||{},n=n||{};var o=n$1.__s;n$1.__s=!0;var a=x$2(t,r,n);return n$1.__c&&n$1.__c(t,h),h.length=0,n$1.__s=o,a}function x$2(r,n,l,c,g,h){if(null==r||"boolean"==typeof r)return "";if("object"!=typeof r)return o$1(r);var m=l.pretty,y=m&&"string"==typeof m?m:"\t";if(Array.isArray(r)){for(var b="",S=0;S<r.length;S++)m&&S>0&&(b+="\n"),b+=x$2(r[S],n,l,c,g,h);return b}var w,k=r.type,O=r.props,C=!1;if("function"==typeof k){if(C=!0,!l.shallow||!c&&!1!==l.renderRootComponent){if(k===y$1){var A=[];return u$1(A,r.props.children),x$2(A,n,l,!1!==l.shallowHighOrder,g,h)}var H,j=r.__c={__v:r,context:n,props:r.props,setState:d,forceUpdate:d,__h:[]};if(n$1.__b&&n$1.__b(r),n$1.__r&&n$1.__r(r),k.prototype&&"function"==typeof k.prototype.render){var F=k.contextType,M=F&&n[F.__c],T=null!=F?M?M.props.value:F.__:n;(j=r.__c=new k(O,T)).__v=r,j._dirty=j.__d=!0,j.props=O,null==j.state&&(j.state={}),null==j._nextState&&null==j.__s&&(j._nextState=j.__s=j.state),j.context=T,k.getDerivedStateFromProps?j.state=f$1(f$1({},j.state),k.getDerivedStateFromProps(j.props,j.state)):j.componentWillMount&&(j.componentWillMount(),j.state=j._nextState!==j.state?j._nextState:j.__s!==j.state?j.__s:j.state),H=j.render(j.props,j.state,j.context);}else {var $=k.contextType,L=$&&n[$.__c];H=k.call(r.__c,O,null!=$?L?L.props.value:$.__:n);}return j.getChildContext&&(n=f$1(f$1({},n),j.getChildContext())),n$1.diffed&&n$1.diffed(r),x$2(H,n,l,!1!==l.shallowHighOrder,g,h)}k=(w=k).displayName||w!==Function&&w.name||function(e){var t=(Function.prototype.toString.call(e).match(/^\s*function\s+([^( ]+)/)||"")[1];if(!t){for(var r=-1,n=p.length;n--;)if(p[n]===e){r=n;break}r<0&&(r=p.push(e)-1),t="UnnamedComponent"+r;}return t}(w);}var E,D,N="<"+k;if(O){var P=Object.keys(O);l&&!0===l.sortAttributes&&P.sort();for(var R=0;R<P.length;R++){var U=P[R],W=O[U];if("children"!==U){if(!v$1.test(U)&&(l&&l.allAttributes||"key"!==U&&"ref"!==U&&"__self"!==U&&"__source"!==U&&"defaultValue"!==U)){if("className"===U){if(O.class)continue;U="class";}else g&&U.match(/^xlink:?./)&&(U=U.toLowerCase().replace(/^xlink:?/,"xlink:"));if("htmlFor"===U){if(O.for)continue;U="for";}"style"===U&&W&&"object"==typeof W&&(W=s(W)),"a"===U[0]&&"r"===U[1]&&"boolean"==typeof W&&(W=String(W));var q=l.attributeHook&&l.attributeHook(U,W,n,l,C);if(q||""===q)N+=q;else if("dangerouslySetInnerHTML"===U)D=W&&W.__html;else if("textarea"===k&&"value"===U)E=W;else if((W||0===W||""===W)&&"function"!=typeof W){if(!(!0!==W&&""!==W||(W=U,l&&l.xml))){N+=" "+U;continue}if("value"===U){if("select"===k){h=W;continue}"option"===k&&h==W&&(N+=" selected");}N+=" "+U+'="'+o$1(W)+'"';}}}else E=W;}}if(m){var z=N.replace(/\n\s*/," ");z===N||~z.indexOf("\n")?m&&~N.indexOf("\n")&&(N+="\n"):N=z;}if(N+=">",v$1.test(k))throw new Error(k+" is not a valid HTML tag name in "+N);var I,V=_.test(k)||l.voidElements&&l.voidElements.test(k),Z=[];if(D)m&&i$1(D)&&(D="\n"+y+a$1(D,y)),N+=D;else if(null!=E&&u$1(I=[],E).length){for(var B=m&&~N.indexOf("\n"),G=!1,J=0;J<I.length;J++){var K=I[J];if(null!=K&&!1!==K){var Q=x$2(K,n,l,!0,"svg"===k||"foreignObject"!==k&&g,h);if(m&&!B&&i$1(Q)&&(B=!0),Q)if(m){var X=Q.length>0&&"<"!=Q[0];G&&X?Z[Z.length-1]+=Q:Z.push(Q),G=X;}else Z.push(Q);}}if(m&&B)for(var Y=Z.length;Y--;)Z[Y]="\n"+y+a$1(Z[Y],y);}if(Z.length||D)N+=Z.join("");else if(l&&l.xml)return N.substring(0,N.length-1)+" />";return !V||I||D?(m&&~N.indexOf("\n")&&(N+="\n"),N+="</"+k+">"):N=N.replace(/>$/," />"),N}m$1.shallowRender=g$1;
- GNU Taler is free software; you can redistribute it and/or modify it under the
- terms of the GNU General Public License as published by the Free Software
- Foundation; either version 3, or (at your option) any later version.
+ var t,u,r,o=0,i=[],c=n$1.__b,f=n$1.__r,e=n$1.diffed,a=n$1.__c,v=n$1.unmount;function m(t,r){n$1.__h&&n$1.__h(u,t,o||r),o=0;var i=u.__H||(u.__H={__:[],__h:[]});return t>=i.__.length&&i.__.push({}),i.__[t]}function y(r,o){var i=m(t++,3);!n$1.__s&&k(i.__H,o)&&(i.__=r,i.__H=o,u.__H.__h.push(i));}function x$1(){i.forEach(function(t){if(t.__P)try{t.__H.__h.forEach(g),t.__H.__h.forEach(j),t.__H.__h=[];}catch(u){t.__H.__h=[],n$1.__e(u,t.__v);}}),i=[];}n$1.__b=function(n){u=null,c&&c(n);},n$1.__r=function(n){f&&f(n),t=0;var r=(u=n.__c).__H;r&&(r.__h.forEach(g),r.__h.forEach(j),r.__h=[]);},n$1.diffed=function(t){e&&e(t);var o=t.__c;o&&o.__H&&o.__H.__h.length&&(1!==i.push(o)&&r===n$1.requestAnimationFrame||((r=n$1.requestAnimationFrame)||function(n){var t,u=function(){clearTimeout(r),b&&cancelAnimationFrame(t),setTimeout(n);},r=setTimeout(u,100);b&&(t=requestAnimationFrame(u));})(x$1)),u=void 0;},n$1.__c=function(t,u){u.some(function(t){try{t.__h.forEach(g),t.__h=t.__h.filter(function(n){return !n.__||j(n)});}catch(r){u.some(function(n){n.__h&&(n.__h=[]);}),u=[],n$1.__e(r,t.__v);}}),a&&a(t,u);},n$1.unmount=function(t){v&&v(t);var u=t.__c;if(u&&u.__H)try{u.__H.__.forEach(g);}catch(t){n$1.__e(t,u.__v);}};var b="function"==typeof requestAnimationFrame;function g(n){var t=u;"function"==typeof n.__c&&n.__c(),u=t;}function j(n){var t=u;n.__c=n.__(),u=t;}function k(n,t){return !n||n.length!==t.length||t.some(function(t,u){return t!==n[u]})}
- GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY
- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+ function C(n,t){for(var e in t)n[e]=t[e];return n}function S(n,t){for(var e in n)if("__source"!==e&&!(e in t))return !0;for(var r in t)if("__source"!==r&&n[r]!==t[r])return !0;return !1}function E(n){this.props=n;}(E.prototype=new p$1).isPureReactComponent=!0,E.prototype.shouldComponentUpdate=function(n,t){return S(this.props,n)||S(this.state,t)};var w=n$1.__b;n$1.__b=function(n){n.type&&n.type.__f&&n.ref&&(n.props.ref=n.ref,n.ref=null),w&&w(n);};var R="undefined"!=typeof Symbol&&Symbol.for&&Symbol.for("react.forward_ref")||3911;function x(n){function t(t,e){var r=C({},t);return delete r.ref,n(r,(e=t.ref||e)&&("object"!=typeof e||"current"in e)?e:null)}return t.$$typeof=R,t.render=t,t.prototype.isReactComponent=t.__f=!0,t.displayName="ForwardRef("+(n.displayName||n.name)+")",t}var A=n$1.__e;n$1.__e=function(n,t,e){if(n.then)for(var r,u=t;u=u.__;)if((r=u.__c)&&r.__c)return null==t.__e&&(t.__e=e.__e,t.__k=e.__k),r.__c(n,t);A(n,t,e);};var O=n$1.unmount;function L(){this.__u=0,this.t=null,this.__b=null;}function U(n){var t=n.__.__c;return t&&t.__e&&t.__e(n)}function F(){this.u=null,this.o=null;}n$1.unmount=function(n){var t=n.__c;t&&t.__R&&t.__R(),t&&!0===n.__h&&(n.type=null),O&&O(n);},(L.prototype=new p$1).__c=function(n,t){var e=t.__c,r=this;null==r.t&&(r.t=[]),r.t.push(e);var u=U(r.__v),o=!1,i=function(){o||(o=!0,e.__R=null,u?u(l):l());};e.__R=i;var l=function(){if(!--r.__u){if(r.state.__e){var n=r.state.__e;r.__v.__k[0]=function n(t,e,r){return t&&(t.__v=null,t.__k=t.__k&&t.__k.map(function(t){return n(t,e,r)}),t.__c&&t.__c.__P===e&&(t.__e&&r.insertBefore(t.__e,t.__d),t.__c.__e=!0,t.__c.__P=r)),t}(n,n.__c.__P,n.__c.__O);}var t;for(r.setState({__e:r.__b=null});t=r.t.pop();)t.forceUpdate();}},f=!0===t.__h;r.__u++||f||r.setState({__e:r.__b=r.__v.__k[0]}),n.then(i,i);},L.prototype.componentWillUnmount=function(){this.t=[];},L.prototype.render=function(n,t){if(this.__b){if(this.__v.__k){var e=document.createElement("div"),r=this.__v.__k[0].__c;this.__v.__k[0]=function n(t,e,r){return t&&(t.__c&&t.__c.__H&&(t.__c.__H.__.forEach(function(n){"function"==typeof n.__c&&n.__c();}),t.__c.__H=null),null!=(t=C({},t)).__c&&(t.__c.__P===r&&(t.__c.__P=e),t.__c=null),t.__k=t.__k&&t.__k.map(function(t){return n(t,e,r)})),t}(this.__b,e,r.__O=r.__P);}this.__b=null;}var u=t.__e&&a$2(y$1,null,n.fallback);return u&&(u.__h=null),[a$2(y$1,null,t.__e?null:n.children),u]};var M=function(n,t,e){if(++e[1]===e[0]&&n.o.delete(t),n.props.revealOrder&&("t"!==n.props.revealOrder[0]||!n.o.size))for(e=n.u;e;){for(;e.length>3;)e.pop()();if(e[1]<e[0])break;n.u=e=e[2];}};(F.prototype=new p$1).__e=function(n){var t=this,e=U(t.__v),r=t.o.get(n);return r[0]++,function(u){var o=function(){t.props.revealOrder?(r.push(u),M(t,n,r)):u();};e?e(o):o();}},F.prototype.render=function(n){this.u=null,this.o=new Map;var t=w$1(n.children);n.revealOrder&&"b"===n.revealOrder[0]&&t.reverse();for(var e=t.length;e--;)this.o.set(t[e],this.u=[1,0,this.u]);return n.children},F.prototype.componentDidUpdate=F.prototype.componentDidMount=function(){var n=this;this.o.forEach(function(t,e){M(n,e,t);});};var W="undefined"!=typeof Symbol&&Symbol.for&&Symbol.for("react.element")||60103,P=/^(?:accent|alignment|arabic|baseline|cap|clip(?!PathU)|color|fill|flood|font|glyph(?!R)|horiz|marker(?!H|W|U)|overline|paint|stop|strikethrough|stroke|text(?!L)|underline|unicode|units|v|vector|vert|word|writing|x(?!C))[A-Z]/,V=function(n){return ("undefined"!=typeof Symbol&&"symbol"==typeof Symbol()?/fil|che|rad/i:/fil|che|ra/i).test(n)};p$1.prototype.isReactComponent={},["componentWillMount","componentWillReceiveProps","componentWillUpdate"].forEach(function(n){Object.defineProperty(p$1.prototype,n,{configurable:!0,get:function(){return this["UNSAFE_"+n]},set:function(t){Object.defineProperty(this,n,{configurable:!0,writable:!0,value:t});}});});var H=n$1.event;function Z(){}function Y(){return this.cancelBubble}function $(){return this.defaultPrevented}n$1.event=function(n){return H&&(n=H(n)),n.persist=Z,n.isPropagationStopped=Y,n.isDefaultPrevented=$,n.nativeEvent=n};var G={configurable:!0,get:function(){return this.class}},J=n$1.vnode;n$1.vnode=function(n){var t=n.type,e=n.props,r=e;if("string"==typeof t){for(var u in r={},e){var o=e[u];"value"===u&&"defaultValue"in e&&null==o||("defaultValue"===u&&"value"in e&&null==e.value?u="value":"download"===u&&!0===o?o="":/ondoubleclick/i.test(u)?u="ondblclick":/^onchange(textarea|input)/i.test(u+t)&&!V(e.type)?u="oninput":/^on(Ani|Tra|Tou|BeforeInp)/.test(u)?u=u.toLowerCase():P.test(u)?u=u.replace(/[A-Z0-9]/,"-$&").toLowerCase():null===o&&(o=void 0),r[u]=o);}"select"==t&&r.multiple&&Array.isArray(r.value)&&(r.value=w$1(e.children).forEach(function(n){n.props.selected=-1!=r.value.indexOf(n.props.value);})),"select"==t&&null!=r.defaultValue&&(r.value=w$1(e.children).forEach(function(n){n.props.selected=r.multiple?-1!=r.defaultValue.indexOf(n.props.value):r.defaultValue==n.props.value;})),n.props=r;}t&&e.class!=e.className&&(G.enumerable="className"in e,null!=e.className&&(r.class=e.className),Object.defineProperty(r,"className",G)),n.$$typeof=W,J&&J(n);};var K=n$1.__r;n$1.__r=function(n){K&&K(n);};"object"==typeof performance&&"function"==typeof performance.now?performance.now.bind(performance):function(){return Date.now()};
- You should have received a copy of the GNU General Public License along with
- GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
- */
- function Footer() {
- return a$2("div", { class: "talerbar" },
- a$2("p", null,
- "You can learn more about GNU Taler on our ",
- a$2("a", { href: "https://taler.net/" }, "website"),
- ".",
- a$2("br", null),
- "Copyright \u00A9 2014\u20142021 Taler Systems SA"));
- }
+ function memoize(fn) {
+ var cache = {};
+ return function (arg) {
+ if (cache[arg] === undefined) cache[arg] = fn(arg);
+ return cache[arg];
+ };
+ }
- function toInteger(dirtyNumber) {
- if (dirtyNumber === null || dirtyNumber === true || dirtyNumber === false) {
- return NaN;
- }
+ var reactPropsRegex = /^((children|dangerouslySetInnerHTML|key|ref|autoFocus|defaultValue|defaultChecked|innerHTML|suppressContentEditableWarning|suppressHydrationWarning|valueLink|accept|acceptCharset|accessKey|action|allow|allowUserMedia|allowPaymentRequest|allowFullScreen|allowTransparency|alt|async|autoComplete|autoPlay|capture|cellPadding|cellSpacing|challenge|charSet|checked|cite|classID|className|cols|colSpan|content|contentEditable|contextMenu|controls|controlsList|coords|crossOrigin|data|dateTime|decoding|default|defer|dir|disabled|disablePictureInPicture|download|draggable|encType|form|formAction|formEncType|formMethod|formNoValidate|formTarget|frameBorder|headers|height|hidden|high|href|hrefLang|htmlFor|httpEquiv|id|inputMode|integrity|is|keyParams|keyType|kind|label|lang|list|loading|loop|low|marginHeight|marginWidth|max|maxLength|media|mediaGroup|method|min|minLength|multiple|muted|name|nonce|noValidate|open|optimum|pattern|placeholder|playsInline|poster|preload|profile|radioGroup|readOnly|referrerPolicy|rel|required|reversed|role|rows|rowSpan|sandbox|scope|scoped|scrolling|seamless|selected|shape|size|sizes|slot|span|spellCheck|src|srcDoc|srcLang|srcSet|start|step|style|summary|tabIndex|target|title|type|useMap|value|width|wmode|wrap|about|datatype|inlist|prefix|property|resource|typeof|vocab|autoCapitalize|autoCorrect|autoSave|color|inert|itemProp|itemScope|itemType|itemID|itemRef|on|results|security|unselectable|accentHeight|accumulate|additive|alignmentBaseline|allowReorder|alphabetic|amplitude|arabicForm|ascent|attributeName|attributeType|autoReverse|azimuth|baseFrequency|baselineShift|baseProfile|bbox|begin|bias|by|calcMode|capHeight|clip|clipPathUnits|clipPath|clipRule|colorInterpolation|colorInterpolationFilters|colorProfile|colorRendering|contentScriptType|contentStyleType|cursor|cx|cy|d|decelerate|descent|diffuseConstant|direction|display|divisor|dominantBaseline|dur|dx|dy|edgeMode|elevation|enableBackground|end|exponent|externalResourcesRequired|fill|fillOpacity|fillRule|filter|filterRes|filterUnits|floodColor|floodOpacity|focusable|fontFamily|fontSize|fontSizeAdjust|fontStretch|fontStyle|fontVariant|fontWeight|format|from|fr|fx|fy|g1|g2|glyphName|glyphOrientationHorizontal|glyphOrientationVertical|glyphRef|gradientTransform|gradientUnits|hanging|horizAdvX|horizOriginX|ideographic|imageRendering|in|in2|intercept|k|k1|k2|k3|k4|kernelMatrix|kernelUnitLength|kerning|keyPoints|keySplines|keyTimes|lengthAdjust|letterSpacing|lightingColor|limitingConeAngle|local|markerEnd|markerMid|markerStart|markerHeight|markerUnits|markerWidth|mask|maskContentUnits|maskUnits|mathematical|mode|numOctaves|offset|opacity|operator|order|orient|orientation|origin|overflow|overlinePosition|overlineThickness|panose1|paintOrder|pathLength|patternContentUnits|patternTransform|patternUnits|pointerEvents|points|pointsAtX|pointsAtY|pointsAtZ|preserveAlpha|preserveAspectRatio|primitiveUnits|r|radius|refX|refY|renderingIntent|repeatCount|repeatDur|requiredExtensions|requiredFeatures|restart|result|rotate|rx|ry|scale|seed|shapeRendering|slope|spacing|specularConstant|specularExponent|speed|spreadMethod|startOffset|stdDeviation|stemh|stemv|stitchTiles|stopColor|stopOpacity|strikethroughPosition|strikethroughThickness|string|stroke|strokeDasharray|strokeDashoffset|strokeLinecap|strokeLinejoin|strokeMiterlimit|strokeOpacity|strokeWidth|surfaceScale|systemLanguage|tableValues|targetX|targetY|textAnchor|textDecoration|textRendering|textLength|to|transform|u1|u2|underlinePosition|underlineThickness|unicode|unicodeBidi|unicodeRange|unitsPerEm|vAlphabetic|vHanging|vIdeographic|vMathematical|values|vectorEffect|version|vertAdvY|vertOriginX|vertOriginY|viewBox|viewTarget|visibility|widths|wordSpacing|writingMode|x|xHeight|x1|x2|xChannelSelector|xlinkActuate|xlinkArcrole|xlinkHref|xlinkRole|xlinkShow|xlinkTitle|xlinkType|xmlBase|xmlns|xmlnsXlink|xmlLang|xmlSpace|y|y1|y2|yChannelSelector|z|zoomAndPan|for|class|autofocus)|(([Dd][Aa][Tt][Aa]|[Aa][Rr][Ii][Aa]|x)-.*))$/; // https://esbench.com/bench/5bfee68a4cd7e6009ef61d23
- var number = Number(dirtyNumber);
+ var index = memoize(function (prop) {
+ return reactPropsRegex.test(prop) || prop.charCodeAt(0) === 111
+ /* o */
+ && prop.charCodeAt(1) === 110
+ /* n */
+ && prop.charCodeAt(2) < 91;
+ }
+ /* Z+1 */
+ );
- if (isNaN(number)) {
- return number;
- }
+ const cx = function cx() {
+ return Array.prototype.slice.call(arguments).filter(Boolean).join(' ');
+ };
- return number < 0 ? Math.ceil(number) : Math.floor(number);
- }
+ var cx$1 = cx;
- function requiredArgs(required, args) {
- if (args.length < required) {
- throw new TypeError(required + ' argument' + (required > 1 ? 's' : '') + ' required, but only ' + args.length + ' present');
- }
- }
+ /**
+ * This file contains an runtime version of `styled` component. Responsibilities of the component are:
+ * - returns ReactElement based on HTML tag used with `styled` or custom React Component
+ * - injects classNames for the returned component
+ * - injects CSS variables used to define dynamic styles based on props
+ */
- /**
- * @name toDate
- * @category Common Helpers
- * @summary Convert the given argument to an instance of Date.
- *
- * @description
- * Convert the given argument to an instance of Date.
- *
- * If the argument is an instance of Date, the function returns its clone.
- *
- * If the argument is a number, it is treated as a timestamp.
- *
- * If the argument is none of the above, the function returns Invalid Date.
- *
- * **Note**: *all* Date arguments passed to any *date-fns* function is processed by `toDate`.
- *
- * @param {Date|Number} argument - the value to convert
- * @returns {Date} the parsed date in the local time zone
- * @throws {TypeError} 1 argument required
- *
- * @example
- * // Clone the date:
- * const result = toDate(new Date(2014, 1, 11, 11, 30, 30))
- * //=> Tue Feb 11 2014 11:30:30
- *
- * @example
- * // Convert the timestamp to date:
- * const result = toDate(1392098430000)
- * //=> Tue Feb 11 2014 11:30:30
- */
+ // Workaround for rest operator
+ const restOp = (obj, keysToExclude) => Object.keys(obj).filter(prop => keysToExclude.indexOf(prop) === -1).reduce((acc, curr) => {
+ acc[curr] = obj[curr];
+ return acc;
+ }, {}); // rest operator workaround
- function toDate(argument) {
- requiredArgs(1, arguments);
- var argStr = Object.prototype.toString.call(argument); // Clone the date
- if (argument instanceof Date || typeof argument === 'object' && argStr === '[object Date]') {
- // Prevent the date to lose the milliseconds when passed to new Date() in IE10
- return new Date(argument.getTime());
- } else if (typeof argument === 'number' || argStr === '[object Number]') {
- return new Date(argument);
- } else {
- if ((typeof argument === 'string' || argStr === '[object String]') && typeof console !== 'undefined') {
- // eslint-disable-next-line no-console
- console.warn("Starting with v2.0.0-beta.1 date-fns doesn't accept strings as date arguments. Please use `parseISO` to parse strings. See: https://git.io/fjule"); // eslint-disable-next-line no-console
+ const warnIfInvalid = (value, componentName) => {
+ };
- console.warn(new Error().stack);
- }
+ function styled(tag) {
+ return options => {
- return new Date(NaN);
- }
- }
+ const render = (props, ref) => {
+ const {
+ as: component = tag,
+ class: className
+ } = props;
+ const rest = restOp(props, ['as', 'class']);
+ let filteredProps; // Check if it's an HTML tag and not a custom element
- /**
- * @name addMilliseconds
- * @category Millisecond Helpers
- * @summary Add the specified number of milliseconds to the given date.
- *
- * @description
- * Add the specified number of milliseconds to the given date.
- *
- * ### v2.0.0 breaking changes:
- *
- * - [Changes that are common for the whole library](https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#Common-Changes).
- *
- * @param {Date|Number} date - the date to be changed
- * @param {Number} amount - the amount of milliseconds to be added. Positive decimals will be rounded using `Math.floor`, decimals less than zero will be rounded using `Math.ceil`.
- * @returns {Date} the new date with the milliseconds added
- * @throws {TypeError} 2 arguments required
- *
- * @example
- * // Add 750 milliseconds to 10 July 2014 12:45:30.000:
- * const result = addMilliseconds(new Date(2014, 6, 10, 12, 45, 30, 0), 750)
- * //=> Thu Jul 10 2014 12:45:30.750
- */
+ if (typeof component === 'string' && component.indexOf('-') === -1) {
+ filteredProps = {}; // eslint-disable-next-line guard-for-in
- function addMilliseconds(dirtyDate, dirtyAmount) {
- requiredArgs(2, arguments);
- var timestamp = toDate(dirtyDate).getTime();
- var amount = toInteger(dirtyAmount);
- return new Date(timestamp + amount);
- }
+ for (const key in rest) {
+ if (key === 'as' || index(key)) {
+ // Don't pass through invalid attributes to HTML elements
+ filteredProps[key] = rest[key];
+ }
+ }
+ } else {
+ filteredProps = rest;
+ }
- /**
- * Google Chrome as of 67.0.3396.87 introduced timezones with offset that includes seconds.
- * They usually appear for dates that denote time before the timezones were introduced
- * (e.g. for 'Europe/Prague' timezone the offset is GMT+00:57:44 before 1 October 1891
- * and GMT+01:00:00 after that date)
- *
- * Date#getTimezoneOffset returns the offset in minutes and would return 57 for the example above,
- * which would lead to incorrect calculations.
- *
- * This function returns the timezone offset in milliseconds that takes seconds in account.
- */
- function getTimezoneOffsetInMilliseconds(date) {
- var utcDate = new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds(), date.getMilliseconds()));
- utcDate.setUTCFullYear(date.getFullYear());
- return date.getTime() - utcDate.getTime();
- }
+ filteredProps.ref = ref;
+ filteredProps.className = cx$1(filteredProps.className || className, options.class);
+ const {
+ vars
+ } = options;
+
+ if (vars) {
+ const style = {}; // eslint-disable-next-line guard-for-in
+
+ for (const name in vars) {
+ const variable = vars[name];
+ const result = variable[0];
+ const unit = variable[1] || '';
+ const value = typeof result === 'function' ? result(props) : result;
+ warnIfInvalid(value, options.name);
+ style[`--${name}`] = `${value}${unit}`;
+ }
- /**
- * @name isValid
- * @category Common Helpers
- * @summary Is the given date valid?
- *
- * @description
- * Returns false if argument is Invalid Date and true otherwise.
- * Argument is converted to Date using `toDate`. See [toDate]{@link https://date-fns.org/docs/toDate}
- * Invalid Date is a Date, whose time value is NaN.
- *
- * Time value of Date: http://es5.github.io/#x15.9.1.1
- *
- * ### v2.0.0 breaking changes:
- *
- * - [Changes that are common for the whole library](https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#Common-Changes).
- *
- * - Now `isValid` doesn't throw an exception
- * if the first argument is not an instance of Date.
- * Instead, argument is converted beforehand using `toDate`.
- *
- * Examples:
- *
- * | `isValid` argument | Before v2.0.0 | v2.0.0 onward |
- * |---------------------------|---------------|---------------|
- * | `new Date()` | `true` | `true` |
- * | `new Date('2016-01-01')` | `true` | `true` |
- * | `new Date('')` | `false` | `false` |
- * | `new Date(1488370835081)` | `true` | `true` |
- * | `new Date(NaN)` | `false` | `false` |
- * | `'2016-01-01'` | `TypeError` | `false` |
- * | `''` | `TypeError` | `false` |
- * | `1488370835081` | `TypeError` | `true` |
- * | `NaN` | `TypeError` | `false` |
- *
- * We introduce this change to make *date-fns* consistent with ECMAScript behavior
- * that try to coerce arguments to the expected type
- * (which is also the case with other *date-fns* functions).
- *
- * @param {*} date - the date to check
- * @returns {Boolean} the date is valid
- * @throws {TypeError} 1 argument required
- *
- * @example
- * // For the valid date:
- * var result = isValid(new Date(2014, 1, 31))
- * //=> true
- *
- * @example
- * // For the value, convertable into a date:
- * var result = isValid(1393804800000)
- * //=> true
- *
- * @example
- * // For the invalid date:
- * var result = isValid(new Date(''))
- * //=> false
- */
+ const ownStyle = filteredProps.style || {};
+ const keys = Object.keys(ownStyle);
- function isValid(dirtyDate) {
- requiredArgs(1, arguments);
- var date = toDate(dirtyDate);
- return !isNaN(date);
- }
+ if (keys.length > 0) {
+ keys.forEach(key => {
+ style[key] = ownStyle[key];
+ });
+ }
- var formatDistanceLocale = {
- lessThanXSeconds: {
- one: 'less than a second',
- other: 'less than {{count}} seconds'
- },
- xSeconds: {
- one: '1 second',
- other: '{{count}} seconds'
- },
- halfAMinute: 'half a minute',
- lessThanXMinutes: {
- one: 'less than a minute',
- other: 'less than {{count}} minutes'
- },
- xMinutes: {
- one: '1 minute',
- other: '{{count}} minutes'
- },
- aboutXHours: {
- one: 'about 1 hour',
- other: 'about {{count}} hours'
- },
- xHours: {
- one: '1 hour',
- other: '{{count}} hours'
- },
- xDays: {
- one: '1 day',
- other: '{{count}} days'
- },
- aboutXWeeks: {
- one: 'about 1 week',
- other: 'about {{count}} weeks'
- },
- xWeeks: {
- one: '1 week',
- other: '{{count}} weeks'
- },
- aboutXMonths: {
- one: 'about 1 month',
- other: 'about {{count}} months'
- },
- xMonths: {
- one: '1 month',
- other: '{{count}} months'
- },
- aboutXYears: {
- one: 'about 1 year',
- other: 'about {{count}} years'
- },
- xYears: {
- one: '1 year',
- other: '{{count}} years'
- },
- overXYears: {
- one: 'over 1 year',
- other: 'over {{count}} years'
- },
- almostXYears: {
- one: 'almost 1 year',
- other: 'almost {{count}} years'
- }
- };
- function formatDistance(token, count, options) {
- options = options || {};
- var result;
-
- if (typeof formatDistanceLocale[token] === 'string') {
- result = formatDistanceLocale[token];
- } else if (count === 1) {
- result = formatDistanceLocale[token].one;
- } else {
- result = formatDistanceLocale[token].other.replace('{{count}}', count);
- }
+ filteredProps.style = style;
+ }
- if (options.addSuffix) {
- if (options.comparison > 0) {
- return 'in ' + result;
- } else {
- return result + ' ago';
+ if (tag.__linaria && tag !== component) {
+ // If the underlying tag is a styled component, forward the `as` prop
+ // Otherwise the styles from the underlying component will be ignored
+ filteredProps.as = component;
+ return /*#__PURE__*/a$2(tag, filteredProps);
}
- }
- return result;
- }
+ return /*#__PURE__*/a$2(component, filteredProps);
+ };
- function buildFormatLongFn(args) {
- return function (dirtyOptions) {
- var options = dirtyOptions || {};
- var width = options.width ? String(options.width) : args.defaultWidth;
- var format = args.formats[width] || args.formats[args.defaultWidth];
- return format;
+ const Result = x ? /*#__PURE__*/x(render) : // React.forwardRef won't available on older React versions and in Preact
+ // Fallback to a innerRef prop in that case
+ props => {
+ const rest = restOp(props, ['innerRef']);
+ return render(rest, props.innerRef);
};
- }
+ Result.displayName = options.name; // These properties will be read by the babel plugin for interpolation
- var dateFormats = {
- full: 'EEEE, MMMM do, y',
- long: 'MMMM do, y',
- medium: 'MMM d, y',
- short: 'MM/dd/yyyy'
- };
- var timeFormats = {
- full: 'h:mm:ss a zzzz',
- long: 'h:mm:ss a z',
- medium: 'h:mm:ss a',
- short: 'h:mm a'
- };
- var dateTimeFormats = {
- full: "{{date}} 'at' {{time}}",
- long: "{{date}} 'at' {{time}}",
- medium: '{{date}}, {{time}}',
- short: '{{date}}, {{time}}'
- };
- var formatLong = {
- date: buildFormatLongFn({
- formats: dateFormats,
- defaultWidth: 'full'
- }),
- time: buildFormatLongFn({
- formats: timeFormats,
- defaultWidth: 'full'
- }),
- dateTime: buildFormatLongFn({
- formats: dateTimeFormats,
- defaultWidth: 'full'
- })
- };
- var formatLong$1 = formatLong;
-
- var formatRelativeLocale = {
- lastWeek: "'last' eeee 'at' p",
- yesterday: "'yesterday at' p",
- today: "'today at' p",
- tomorrow: "'tomorrow at' p",
- nextWeek: "eeee 'at' p",
- other: 'P'
+ Result.__linaria = {
+ className: options.class,
+ extends: tag
+ };
+ return Result;
};
- function formatRelative(token, _date, _baseDate, _options) {
- return formatRelativeLocale[token];
- }
-
- function buildLocalizeFn(args) {
- return function (dirtyIndex, dirtyOptions) {
- var options = dirtyOptions || {};
- var context = options.context ? String(options.context) : 'standalone';
- var valuesArray;
+ }
- if (context === 'formatting' && args.formattingValues) {
- var defaultWidth = args.defaultFormattingWidth || args.defaultWidth;
- var width = options.width ? String(options.width) : defaultWidth;
- valuesArray = args.formattingValues[width] || args.formattingValues[defaultWidth];
- } else {
- var _defaultWidth = args.defaultWidth;
+ var styled$1 = styled;
+
+ /*
+ This file is part of GNU Taler
+ (C) 2021 Taler Systems S.A.
+
+ GNU Taler is free software; you can redistribute it and/or modify it under the
+ terms of the GNU General Public License as published by the Free Software
+ Foundation; either version 3, or (at your option) any later version.
+
+ GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along with
+ GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
+ */
+ const QRPlaceholder = /*#__PURE__*/styled$1("div")({
+ name: "QRPlaceholder",
+ class: "q1ma0zxq"
+ });
+ const FooterBar = /*#__PURE__*/styled$1("footer")({
+ name: "FooterBar",
+ class: "fef0x5t"
+ });
+ const Page = /*#__PURE__*/styled$1("div")({
+ name: "Page",
+ class: "p1b3vqup"
+ });
+ const WalletLink = /*#__PURE__*/styled$1("a")({
+ name: "WalletLink",
+ class: "wpwjmk",
+ vars: {
+ "wpwjmk-0": [({
+ upperCased
+ }) => upperCased ? 'uppercase' : 'none']
+ }
+ });
+ const InfoBox = /*#__PURE__*/styled$1("div")({
+ name: "InfoBox",
+ class: "i1pkgksb"
+ });
+ const TableExpanded = /*#__PURE__*/styled$1("dl")({
+ name: "TableExpanded",
+ class: "t2c81u8"
+ });
+ const TableSimple = /*#__PURE__*/styled$1("dl")({
+ name: "TableSimple",
+ class: "t1mav7fx"
+ });
+
+ /*
+ This file is part of GNU Taler
+ (C) 2021 Taler Systems S.A.
+
+ GNU Taler is free software; you can redistribute it and/or modify it under the
+ terms of the GNU General Public License as published by the Free Software
+ Foundation; either version 3, or (at your option) any later version.
+
+ GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along with
+ GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
+ */
+ function Footer() {
+ return a$2(FooterBar, null,
+ a$2("p", null,
+ a$2("a", { href: "https://taler.net/" }, "Learn more about GNU Taler on our website."),
+ a$2("p", null, "Copyright \u00A9 2014\u20142021 Taler Systems SA")));
+ }
- var _width = options.width ? String(options.width) : args.defaultWidth;
+ function toInteger(dirtyNumber) {
+ if (dirtyNumber === null || dirtyNumber === true || dirtyNumber === false) {
+ return NaN;
+ }
- valuesArray = args.values[_width] || args.values[_defaultWidth];
- }
+ var number = Number(dirtyNumber);
- var index = args.argumentCallback ? args.argumentCallback(dirtyIndex) : dirtyIndex;
- return valuesArray[index];
- };
+ if (isNaN(number)) {
+ return number;
}
- var eraValues = {
- narrow: ['B', 'A'],
- abbreviated: ['BC', 'AD'],
- wide: ['Before Christ', 'Anno Domini']
- };
- var quarterValues = {
- narrow: ['1', '2', '3', '4'],
- abbreviated: ['Q1', 'Q2', 'Q3', 'Q4'],
- wide: ['1st quarter', '2nd quarter', '3rd quarter', '4th quarter'] // Note: in English, the names of days of the week and months are capitalized.
- // If you are making a new locale based on this one, check if the same is true for the language you're working on.
- // Generally, formatted dates should look like they are in the middle of a sentence,
- // e.g. in Spanish language the weekdays and months should be in the lowercase.
+ return number < 0 ? Math.ceil(number) : Math.floor(number);
+ }
- };
- var monthValues = {
- narrow: ['J', 'F', 'M', 'A', 'M', 'J', 'J', 'A', 'S', 'O', 'N', 'D'],
- abbreviated: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
- wide: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']
- };
- var dayValues = {
- narrow: ['S', 'M', 'T', 'W', 'T', 'F', 'S'],
- short: ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'],
- abbreviated: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'],
- wide: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday']
- };
- var dayPeriodValues = {
- narrow: {
- am: 'a',
- pm: 'p',
- midnight: 'mi',
- noon: 'n',
- morning: 'morning',
- afternoon: 'afternoon',
- evening: 'evening',
- night: 'night'
- },
- abbreviated: {
- am: 'AM',
- pm: 'PM',
- midnight: 'midnight',
- noon: 'noon',
- morning: 'morning',
- afternoon: 'afternoon',
- evening: 'evening',
- night: 'night'
- },
- wide: {
- am: 'a.m.',
- pm: 'p.m.',
- midnight: 'midnight',
- noon: 'noon',
- morning: 'morning',
- afternoon: 'afternoon',
- evening: 'evening',
- night: 'night'
- }
- };
- var formattingDayPeriodValues = {
- narrow: {
- am: 'a',
- pm: 'p',
- midnight: 'mi',
- noon: 'n',
- morning: 'in the morning',
- afternoon: 'in the afternoon',
- evening: 'in the evening',
- night: 'at night'
- },
- abbreviated: {
- am: 'AM',
- pm: 'PM',
- midnight: 'midnight',
- noon: 'noon',
- morning: 'in the morning',
- afternoon: 'in the afternoon',
- evening: 'in the evening',
- night: 'at night'
- },
- wide: {
- am: 'a.m.',
- pm: 'p.m.',
- midnight: 'midnight',
- noon: 'noon',
- morning: 'in the morning',
- afternoon: 'in the afternoon',
- evening: 'in the evening',
- night: 'at night'
- }
- };
+ function requiredArgs(required, args) {
+ if (args.length < required) {
+ throw new TypeError(required + ' argument' + (required > 1 ? 's' : '') + ' required, but only ' + args.length + ' present');
+ }
+ }
- function ordinalNumber(dirtyNumber, _dirtyOptions) {
- var number = Number(dirtyNumber); // If ordinal numbers depend on context, for example,
- // if they are different for different grammatical genders,
- // use `options.unit`:
- //
- // var options = dirtyOptions || {}
- // var unit = String(options.unit)
- //
- // where `unit` can be 'year', 'quarter', 'month', 'week', 'date', 'dayOfYear',
- // 'day', 'hour', 'minute', 'second'
-
- var rem100 = number % 100;
-
- if (rem100 > 20 || rem100 < 10) {
- switch (rem100 % 10) {
- case 1:
- return number + 'st';
-
- case 2:
- return number + 'nd';
-
- case 3:
- return number + 'rd';
- }
+ /**
+ * @name toDate
+ * @category Common Helpers
+ * @summary Convert the given argument to an instance of Date.
+ *
+ * @description
+ * Convert the given argument to an instance of Date.
+ *
+ * If the argument is an instance of Date, the function returns its clone.
+ *
+ * If the argument is a number, it is treated as a timestamp.
+ *
+ * If the argument is none of the above, the function returns Invalid Date.
+ *
+ * **Note**: *all* Date arguments passed to any *date-fns* function is processed by `toDate`.
+ *
+ * @param {Date|Number} argument - the value to convert
+ * @returns {Date} the parsed date in the local time zone
+ * @throws {TypeError} 1 argument required
+ *
+ * @example
+ * // Clone the date:
+ * const result = toDate(new Date(2014, 1, 11, 11, 30, 30))
+ * //=> Tue Feb 11 2014 11:30:30
+ *
+ * @example
+ * // Convert the timestamp to date:
+ * const result = toDate(1392098430000)
+ * //=> Tue Feb 11 2014 11:30:30
+ */
+
+ function toDate(argument) {
+ requiredArgs(1, arguments);
+ var argStr = Object.prototype.toString.call(argument); // Clone the date
+
+ if (argument instanceof Date || typeof argument === 'object' && argStr === '[object Date]') {
+ // Prevent the date to lose the milliseconds when passed to new Date() in IE10
+ return new Date(argument.getTime());
+ } else if (typeof argument === 'number' || argStr === '[object Number]') {
+ return new Date(argument);
+ } else {
+ if ((typeof argument === 'string' || argStr === '[object String]') && typeof console !== 'undefined') {
+ // eslint-disable-next-line no-console
+ console.warn("Starting with v2.0.0-beta.1 date-fns doesn't accept strings as date arguments. Please use `parseISO` to parse strings. See: https://git.io/fjule"); // eslint-disable-next-line no-console
+
+ console.warn(new Error().stack);
}
- return number + 'th';
+ return new Date(NaN);
}
+ }
- var localize = {
- ordinalNumber: ordinalNumber,
- era: buildLocalizeFn({
- values: eraValues,
- defaultWidth: 'wide'
- }),
- quarter: buildLocalizeFn({
- values: quarterValues,
- defaultWidth: 'wide',
- argumentCallback: function (quarter) {
- return Number(quarter) - 1;
- }
- }),
- month: buildLocalizeFn({
- values: monthValues,
- defaultWidth: 'wide'
- }),
- day: buildLocalizeFn({
- values: dayValues,
- defaultWidth: 'wide'
- }),
- dayPeriod: buildLocalizeFn({
- values: dayPeriodValues,
- defaultWidth: 'wide',
- formattingValues: formattingDayPeriodValues,
- defaultFormattingWidth: 'wide'
- })
- };
- var localize$1 = localize;
+ /**
+ * @name addDays
+ * @category Day Helpers
+ * @summary Add the specified number of days to the given date.
+ *
+ * @description
+ * Add the specified number of days to the given date.
+ *
+ * ### v2.0.0 breaking changes:
+ *
+ * - [Changes that are common for the whole library](https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#Common-Changes).
+ *
+ * @param {Date|Number} date - the date to be changed
+ * @param {Number} amount - the amount of days to be added. Positive decimals will be rounded using `Math.floor`, decimals less than zero will be rounded using `Math.ceil`.
+ * @returns {Date} - the new date with the days added
+ * @throws {TypeError} - 2 arguments required
+ *
+ * @example
+ * // Add 10 days to 1 September 2014:
+ * const result = addDays(new Date(2014, 8, 1), 10)
+ * //=> Thu Sep 11 2014 00:00:00
+ */
+
+ function addDays(dirtyDate, dirtyAmount) {
+ requiredArgs(2, arguments);
+ var date = toDate(dirtyDate);
+ var amount = toInteger(dirtyAmount);
+
+ if (isNaN(amount)) {
+ return new Date(NaN);
+ }
- function buildMatchPatternFn(args) {
- return function (dirtyString, dirtyOptions) {
- var string = String(dirtyString);
- var options = dirtyOptions || {};
- var matchResult = string.match(args.matchPattern);
+ if (!amount) {
+ // If 0 days, no-op to avoid changing times in the hour before end of DST
+ return date;
+ }
- if (!matchResult) {
- return null;
- }
+ date.setDate(date.getDate() + amount);
+ return date;
+ }
- var matchedString = matchResult[0];
- var parseResult = string.match(args.parsePattern);
+ /**
+ * @name addMonths
+ * @category Month Helpers
+ * @summary Add the specified number of months to the given date.
+ *
+ * @description
+ * Add the specified number of months to the given date.
+ *
+ * ### v2.0.0 breaking changes:
+ *
+ * - [Changes that are common for the whole library](https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#Common-Changes).
+ *
+ * @param {Date|Number} date - the date to be changed
+ * @param {Number} amount - the amount of months to be added. Positive decimals will be rounded using `Math.floor`, decimals less than zero will be rounded using `Math.ceil`.
+ * @returns {Date} the new date with the months added
+ * @throws {TypeError} 2 arguments required
+ *
+ * @example
+ * // Add 5 months to 1 September 2014:
+ * const result = addMonths(new Date(2014, 8, 1), 5)
+ * //=> Sun Feb 01 2015 00:00:00
+ */
+
+ function addMonths(dirtyDate, dirtyAmount) {
+ requiredArgs(2, arguments);
+ var date = toDate(dirtyDate);
+ var amount = toInteger(dirtyAmount);
+
+ if (isNaN(amount)) {
+ return new Date(NaN);
+ }
- if (!parseResult) {
- return null;
- }
+ if (!amount) {
+ // If 0 months, no-op to avoid changing times in the hour before end of DST
+ return date;
+ }
- var value = args.valueCallback ? args.valueCallback(parseResult[0]) : parseResult[0];
- value = options.valueCallback ? options.valueCallback(value) : value;
- return {
- value: value,
- rest: string.slice(matchedString.length)
- };
- };
+ var dayOfMonth = date.getDate(); // The JS Date object supports date math by accepting out-of-bounds values for
+ // month, day, etc. For example, new Date(2020, 0, 0) returns 31 Dec 2019 and
+ // new Date(2020, 13, 1) returns 1 Feb 2021. This is *almost* the behavior we
+ // want except that dates will wrap around the end of a month, meaning that
+ // new Date(2020, 13, 31) will return 3 Mar 2021 not 28 Feb 2021 as desired. So
+ // we'll default to the end of the desired month by adding 1 to the desired
+ // month and using a date of 0 to back up one day to the end of the desired
+ // month.
+
+ var endOfDesiredMonth = new Date(date.getTime());
+ endOfDesiredMonth.setMonth(date.getMonth() + amount + 1, 0);
+ var daysInMonth = endOfDesiredMonth.getDate();
+
+ if (dayOfMonth >= daysInMonth) {
+ // If we're already at the end of the month, then this is the correct date
+ // and we're done.
+ return endOfDesiredMonth;
+ } else {
+ // Otherwise, we now know that setting the original day-of-month value won't
+ // cause an overflow, so set the desired day-of-month. Note that we can't
+ // just set the date of `endOfDesiredMonth` because that object may have had
+ // its time changed in the unusual case where where a DST transition was on
+ // the last day of the month and its local time was in the hour skipped or
+ // repeated next to a DST transition. So we use `date` instead which is
+ // guaranteed to still have the original time.
+ date.setFullYear(endOfDesiredMonth.getFullYear(), endOfDesiredMonth.getMonth(), dayOfMonth);
+ return date;
}
+ }
- function buildMatchFn(args) {
- return function (dirtyString, dirtyOptions) {
- var string = String(dirtyString);
- var options = dirtyOptions || {};
- var width = options.width;
- var matchPattern = width && args.matchPatterns[width] || args.matchPatterns[args.defaultMatchWidth];
- var matchResult = string.match(matchPattern);
+ /**
+ * @name addMilliseconds
+ * @category Millisecond Helpers
+ * @summary Add the specified number of milliseconds to the given date.
+ *
+ * @description
+ * Add the specified number of milliseconds to the given date.
+ *
+ * ### v2.0.0 breaking changes:
+ *
+ * - [Changes that are common for the whole library](https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#Common-Changes).
+ *
+ * @param {Date|Number} date - the date to be changed
+ * @param {Number} amount - the amount of milliseconds to be added. Positive decimals will be rounded using `Math.floor`, decimals less than zero will be rounded using `Math.ceil`.
+ * @returns {Date} the new date with the milliseconds added
+ * @throws {TypeError} 2 arguments required
+ *
+ * @example
+ * // Add 750 milliseconds to 10 July 2014 12:45:30.000:
+ * const result = addMilliseconds(new Date(2014, 6, 10, 12, 45, 30, 0), 750)
+ * //=> Thu Jul 10 2014 12:45:30.750
+ */
+
+ function addMilliseconds(dirtyDate, dirtyAmount) {
+ requiredArgs(2, arguments);
+ var timestamp = toDate(dirtyDate).getTime();
+ var amount = toInteger(dirtyAmount);
+ return new Date(timestamp + amount);
+ }
- if (!matchResult) {
- return null;
- }
+ /**
+ * Google Chrome as of 67.0.3396.87 introduced timezones with offset that includes seconds.
+ * They usually appear for dates that denote time before the timezones were introduced
+ * (e.g. for 'Europe/Prague' timezone the offset is GMT+00:57:44 before 1 October 1891
+ * and GMT+01:00:00 after that date)
+ *
+ * Date#getTimezoneOffset returns the offset in minutes and would return 57 for the example above,
+ * which would lead to incorrect calculations.
+ *
+ * This function returns the timezone offset in milliseconds that takes seconds in account.
+ */
+ function getTimezoneOffsetInMilliseconds(date) {
+ var utcDate = new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds(), date.getMilliseconds()));
+ utcDate.setUTCFullYear(date.getFullYear());
+ return date.getTime() - utcDate.getTime();
+ }
- var matchedString = matchResult[0];
- var parsePatterns = width && args.parsePatterns[width] || args.parsePatterns[args.defaultParseWidth];
- var value;
+ /**
+ * @name startOfDay
+ * @category Day Helpers
+ * @summary Return the start of a day for the given date.
+ *
+ * @description
+ * Return the start of a day for the given date.
+ * The result will be in the local timezone.
+ *
+ * ### v2.0.0 breaking changes:
+ *
+ * - [Changes that are common for the whole library](https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#Common-Changes).
+ *
+ * @param {Date|Number} date - the original date
+ * @returns {Date} the start of a day
+ * @throws {TypeError} 1 argument required
+ *
+ * @example
+ * // The start of a day for 2 September 2014 11:55:00:
+ * const result = startOfDay(new Date(2014, 8, 2, 11, 55, 0))
+ * //=> Tue Sep 02 2014 00:00:00
+ */
+
+ function startOfDay(dirtyDate) {
+ requiredArgs(1, arguments);
+ var date = toDate(dirtyDate);
+ date.setHours(0, 0, 0, 0);
+ return date;
+ }
- if (Object.prototype.toString.call(parsePatterns) === '[object Array]') {
- value = findIndex(parsePatterns, function (pattern) {
- return pattern.test(matchedString);
- });
- } else {
- value = findKey(parsePatterns, function (pattern) {
- return pattern.test(matchedString);
- });
- }
+ var MILLISECONDS_IN_DAY$1 = 86400000;
+ /**
+ * @name differenceInCalendarDays
+ * @category Day Helpers
+ * @summary Get the number of calendar days between the given dates.
+ *
+ * @description
+ * Get the number of calendar days between the given dates. This means that the times are removed
+ * from the dates and then the difference in days is calculated.
+ *
+ * ### v2.0.0 breaking changes:
+ *
+ * - [Changes that are common for the whole library](https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#Common-Changes).
+ *
+ * @param {Date|Number} dateLeft - the later date
+ * @param {Date|Number} dateRight - the earlier date
+ * @returns {Number} the number of calendar days
+ * @throws {TypeError} 2 arguments required
+ *
+ * @example
+ * // How many calendar days are between
+ * // 2 July 2011 23:00:00 and 2 July 2012 00:00:00?
+ * var result = differenceInCalendarDays(
+ * new Date(2012, 6, 2, 0, 0),
+ * new Date(2011, 6, 2, 23, 0)
+ * )
+ * //=> 366
+ * // How many calendar days are between
+ * // 2 July 2011 23:59:00 and 3 July 2011 00:01:00?
+ * var result = differenceInCalendarDays(
+ * new Date(2011, 6, 3, 0, 1),
+ * new Date(2011, 6, 2, 23, 59)
+ * )
+ * //=> 1
+ */
+
+ function differenceInCalendarDays(dirtyDateLeft, dirtyDateRight) {
+ requiredArgs(2, arguments);
+ var startOfDayLeft = startOfDay(dirtyDateLeft);
+ var startOfDayRight = startOfDay(dirtyDateRight);
+ var timestampLeft = startOfDayLeft.getTime() - getTimezoneOffsetInMilliseconds(startOfDayLeft);
+ var timestampRight = startOfDayRight.getTime() - getTimezoneOffsetInMilliseconds(startOfDayRight); // Round the number of days to the nearest integer
+ // because the number of milliseconds in a day is not constant
+ // (e.g. it's different in the day of the daylight saving time clock shift)
+
+ return Math.round((timestampLeft - timestampRight) / MILLISECONDS_IN_DAY$1);
+ }
- value = args.valueCallback ? args.valueCallback(value) : value;
- value = options.valueCallback ? options.valueCallback(value) : value;
- return {
- value: value,
- rest: string.slice(matchedString.length)
- };
- };
+ /**
+ * @name compareAsc
+ * @category Common Helpers
+ * @summary Compare the two dates and return -1, 0 or 1.
+ *
+ * @description
+ * Compare the two dates and return 1 if the first date is after the second,
+ * -1 if the first date is before the second or 0 if dates are equal.
+ *
+ * ### v2.0.0 breaking changes:
+ *
+ * - [Changes that are common for the whole library](https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#Common-Changes).
+ *
+ * @param {Date|Number} dateLeft - the first date to compare
+ * @param {Date|Number} dateRight - the second date to compare
+ * @returns {Number} the result of the comparison
+ * @throws {TypeError} 2 arguments required
+ *
+ * @example
+ * // Compare 11 February 1987 and 10 July 1989:
+ * const result = compareAsc(new Date(1987, 1, 11), new Date(1989, 6, 10))
+ * //=> -1
+ *
+ * @example
+ * // Sort the array of dates:
+ * const result = [
+ * new Date(1995, 6, 2),
+ * new Date(1987, 1, 11),
+ * new Date(1989, 6, 10)
+ * ].sort(compareAsc)
+ * //=> [
+ * // Wed Feb 11 1987 00:00:00,
+ * // Mon Jul 10 1989 00:00:00,
+ * // Sun Jul 02 1995 00:00:00
+ * // ]
+ */
+
+ function compareAsc(dirtyDateLeft, dirtyDateRight) {
+ requiredArgs(2, arguments);
+ var dateLeft = toDate(dirtyDateLeft);
+ var dateRight = toDate(dirtyDateRight);
+ var diff = dateLeft.getTime() - dateRight.getTime();
+
+ if (diff < 0) {
+ return -1;
+ } else if (diff > 0) {
+ return 1; // Return 0 if diff is 0; return NaN if diff is NaN
+ } else {
+ return diff;
}
+ }
- function findKey(object, predicate) {
- for (var key in object) {
- if (object.hasOwnProperty(key) && predicate(object[key])) {
- return key;
- }
- }
- }
+ /**
+ * @name isValid
+ * @category Common Helpers
+ * @summary Is the given date valid?
+ *
+ * @description
+ * Returns false if argument is Invalid Date and true otherwise.
+ * Argument is converted to Date using `toDate`. See [toDate]{@link https://date-fns.org/docs/toDate}
+ * Invalid Date is a Date, whose time value is NaN.
+ *
+ * Time value of Date: http://es5.github.io/#x15.9.1.1
+ *
+ * ### v2.0.0 breaking changes:
+ *
+ * - [Changes that are common for the whole library](https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#Common-Changes).
+ *
+ * - Now `isValid` doesn't throw an exception
+ * if the first argument is not an instance of Date.
+ * Instead, argument is converted beforehand using `toDate`.
+ *
+ * Examples:
+ *
+ * | `isValid` argument | Before v2.0.0 | v2.0.0 onward |
+ * |---------------------------|---------------|---------------|
+ * | `new Date()` | `true` | `true` |
+ * | `new Date('2016-01-01')` | `true` | `true` |
+ * | `new Date('')` | `false` | `false` |
+ * | `new Date(1488370835081)` | `true` | `true` |
+ * | `new Date(NaN)` | `false` | `false` |
+ * | `'2016-01-01'` | `TypeError` | `false` |
+ * | `''` | `TypeError` | `false` |
+ * | `1488370835081` | `TypeError` | `true` |
+ * | `NaN` | `TypeError` | `false` |
+ *
+ * We introduce this change to make *date-fns* consistent with ECMAScript behavior
+ * that try to coerce arguments to the expected type
+ * (which is also the case with other *date-fns* functions).
+ *
+ * @param {*} date - the date to check
+ * @returns {Boolean} the date is valid
+ * @throws {TypeError} 1 argument required
+ *
+ * @example
+ * // For the valid date:
+ * var result = isValid(new Date(2014, 1, 31))
+ * //=> true
+ *
+ * @example
+ * // For the value, convertable into a date:
+ * var result = isValid(1393804800000)
+ * //=> true
+ *
+ * @example
+ * // For the invalid date:
+ * var result = isValid(new Date(''))
+ * //=> false
+ */
+
+ function isValid(dirtyDate) {
+ requiredArgs(1, arguments);
+ var date = toDate(dirtyDate);
+ return !isNaN(date);
+ }
- function findIndex(array, predicate) {
- for (var key = 0; key < array.length; key++) {
- if (predicate(array[key])) {
- return key;
- }
- }
- }
+ /**
+ * @name differenceInCalendarMonths
+ * @category Month Helpers
+ * @summary Get the number of calendar months between the given dates.
+ *
+ * @description
+ * Get the number of calendar months between the given dates.
+ *
+ * ### v2.0.0 breaking changes:
+ *
+ * - [Changes that are common for the whole library](https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#Common-Changes).
+ *
+ * @param {Date|Number} dateLeft - the later date
+ * @param {Date|Number} dateRight - the earlier date
+ * @returns {Number} the number of calendar months
+ * @throws {TypeError} 2 arguments required
+ *
+ * @example
+ * // How many calendar months are between 31 January 2014 and 1 September 2014?
+ * var result = differenceInCalendarMonths(
+ * new Date(2014, 8, 1),
+ * new Date(2014, 0, 31)
+ * )
+ * //=> 8
+ */
+
+ function differenceInCalendarMonths(dirtyDateLeft, dirtyDateRight) {
+ requiredArgs(2, arguments);
+ var dateLeft = toDate(dirtyDateLeft);
+ var dateRight = toDate(dirtyDateRight);
+ var yearDiff = dateLeft.getFullYear() - dateRight.getFullYear();
+ var monthDiff = dateLeft.getMonth() - dateRight.getMonth();
+ return yearDiff * 12 + monthDiff;
+ }
- var matchOrdinalNumberPattern = /^(\d+)(th|st|nd|rd)?/i;
- var parseOrdinalNumberPattern = /\d+/i;
- var matchEraPatterns = {
- narrow: /^(b|a)/i,
- abbreviated: /^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,
- wide: /^(before christ|before common era|anno domini|common era)/i
- };
- var parseEraPatterns = {
- any: [/^b/i, /^(a|c)/i]
- };
- var matchQuarterPatterns = {
- narrow: /^[1234]/i,
- abbreviated: /^q[1234]/i,
- wide: /^[1234](th|st|nd|rd)? quarter/i
- };
- var parseQuarterPatterns = {
- any: [/1/i, /2/i, /3/i, /4/i]
- };
- var matchMonthPatterns = {
- narrow: /^[jfmasond]/i,
- abbreviated: /^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,
- wide: /^(january|february|march|april|may|june|july|august|september|october|november|december)/i
- };
- var parseMonthPatterns = {
- narrow: [/^j/i, /^f/i, /^m/i, /^a/i, /^m/i, /^j/i, /^j/i, /^a/i, /^s/i, /^o/i, /^n/i, /^d/i],
- any: [/^ja/i, /^f/i, /^mar/i, /^ap/i, /^may/i, /^jun/i, /^jul/i, /^au/i, /^s/i, /^o/i, /^n/i, /^d/i]
- };
- var matchDayPatterns = {
- narrow: /^[smtwf]/i,
- short: /^(su|mo|tu|we|th|fr|sa)/i,
- abbreviated: /^(sun|mon|tue|wed|thu|fri|sat)/i,
- wide: /^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i
- };
- var parseDayPatterns = {
- narrow: [/^s/i, /^m/i, /^t/i, /^w/i, /^t/i, /^f/i, /^s/i],
- any: [/^su/i, /^m/i, /^tu/i, /^w/i, /^th/i, /^f/i, /^sa/i]
- };
- var matchDayPeriodPatterns = {
- narrow: /^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,
- any: /^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i
- };
- var parseDayPeriodPatterns = {
- any: {
- am: /^a/i,
- pm: /^p/i,
- midnight: /^mi/i,
- noon: /^no/i,
- morning: /morning/i,
- afternoon: /afternoon/i,
- evening: /evening/i,
- night: /night/i
- }
- };
- var match = {
- ordinalNumber: buildMatchPatternFn({
- matchPattern: matchOrdinalNumberPattern,
- parsePattern: parseOrdinalNumberPattern,
- valueCallback: function (value) {
- return parseInt(value, 10);
- }
- }),
- era: buildMatchFn({
- matchPatterns: matchEraPatterns,
- defaultMatchWidth: 'wide',
- parsePatterns: parseEraPatterns,
- defaultParseWidth: 'any'
- }),
- quarter: buildMatchFn({
- matchPatterns: matchQuarterPatterns,
- defaultMatchWidth: 'wide',
- parsePatterns: parseQuarterPatterns,
- defaultParseWidth: 'any',
- valueCallback: function (index) {
- return index + 1;
- }
- }),
- month: buildMatchFn({
- matchPatterns: matchMonthPatterns,
- defaultMatchWidth: 'wide',
- parsePatterns: parseMonthPatterns,
- defaultParseWidth: 'any'
- }),
- day: buildMatchFn({
- matchPatterns: matchDayPatterns,
- defaultMatchWidth: 'wide',
- parsePatterns: parseDayPatterns,
- defaultParseWidth: 'any'
- }),
- dayPeriod: buildMatchFn({
- matchPatterns: matchDayPeriodPatterns,
- defaultMatchWidth: 'any',
- parsePatterns: parseDayPeriodPatterns,
- defaultParseWidth: 'any'
- })
- };
- var match$1 = match;
-
- /**
- * @type {Locale}
- * @category Locales
- * @summary English locale (United States).
- * @language English
- * @iso-639-2 eng
- * @author Sasha Koss [@kossnocorp]{@link https://github.com/kossnocorp}
- * @author Lesha Koss [@leshakoss]{@link https://github.com/leshakoss}
- */
+ /**
+ * @name differenceInCalendarYears
+ * @category Year Helpers
+ * @summary Get the number of calendar years between the given dates.
+ *
+ * @description
+ * Get the number of calendar years between the given dates.
+ *
+ * ### v2.0.0 breaking changes:
+ *
+ * - [Changes that are common for the whole library](https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#Common-Changes).
+ *
+ * @param {Date|Number} dateLeft - the later date
+ * @param {Date|Number} dateRight - the earlier date
+ * @returns {Number} the number of calendar years
+ * @throws {TypeError} 2 arguments required
+ *
+ * @example
+ * // How many calendar years are between 31 December 2013 and 11 February 2015?
+ * var result = differenceInCalendarYears(
+ * new Date(2015, 1, 11),
+ * new Date(2013, 11, 31)
+ * )
+ * //=> 2
+ */
+
+ function differenceInCalendarYears(dirtyDateLeft, dirtyDateRight) {
+ requiredArgs(2, arguments);
+ var dateLeft = toDate(dirtyDateLeft);
+ var dateRight = toDate(dirtyDateRight);
+ return dateLeft.getFullYear() - dateRight.getFullYear();
+ }
- var locale = {
- code: 'en-US',
- formatDistance: formatDistance,
- formatLong: formatLong$1,
- formatRelative: formatRelative,
- localize: localize$1,
- match: match$1,
- options: {
- weekStartsOn: 0
- /* Sunday */
- ,
- firstWeekContainsDate: 1
- }
- };
- var defaultLocale = locale;
+ // for accurate equality comparisons of UTC timestamps that end up
+ // having the same representation in local time, e.g. one hour before
+ // DST ends vs. the instant that DST ends.
- /**
- * @name subMilliseconds
- * @category Millisecond Helpers
- * @summary Subtract the specified number of milliseconds from the given date.
- *
- * @description
- * Subtract the specified number of milliseconds from the given date.
- *
- * ### v2.0.0 breaking changes:
- *
- * - [Changes that are common for the whole library](https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#Common-Changes).
- *
- * @param {Date|Number} date - the date to be changed
- * @param {Number} amount - the amount of milliseconds to be subtracted. Positive decimals will be rounded using `Math.floor`, decimals less than zero will be rounded using `Math.ceil`.
- * @returns {Date} the new date with the milliseconds subtracted
- * @throws {TypeError} 2 arguments required
- *
- * @example
- * // Subtract 750 milliseconds from 10 July 2014 12:45:30.000:
- * const result = subMilliseconds(new Date(2014, 6, 10, 12, 45, 30, 0), 750)
- * //=> Thu Jul 10 2014 12:45:29.250
- */
+ function compareLocalAsc(dateLeft, dateRight) {
+ var diff = dateLeft.getFullYear() - dateRight.getFullYear() || dateLeft.getMonth() - dateRight.getMonth() || dateLeft.getDate() - dateRight.getDate() || dateLeft.getHours() - dateRight.getHours() || dateLeft.getMinutes() - dateRight.getMinutes() || dateLeft.getSeconds() - dateRight.getSeconds() || dateLeft.getMilliseconds() - dateRight.getMilliseconds();
- function subMilliseconds(dirtyDate, dirtyAmount) {
- requiredArgs(2, arguments);
- var amount = toInteger(dirtyAmount);
- return addMilliseconds(dirtyDate, -amount);
+ if (diff < 0) {
+ return -1;
+ } else if (diff > 0) {
+ return 1; // Return 0 if diff is 0; return NaN if diff is NaN
+ } else {
+ return diff;
}
+ }
+ /**
+ * @name differenceInDays
+ * @category Day Helpers
+ * @summary Get the number of full days between the given dates.
+ *
+ * @description
+ * Get the number of full day periods between two dates. Fractional days are
+ * truncated towards zero.
+ *
+ * One "full day" is the distance between a local time in one day to the same
+ * local time on the next or previous day. A full day can sometimes be less than
+ * or more than 24 hours if a daylight savings change happens between two dates.
+ *
+ * To ignore DST and only measure exact 24-hour periods, use this instead:
+ * `Math.floor(differenceInHours(dateLeft, dateRight)/24)|0`.
+ *
+ *
+ * ### v2.0.0 breaking changes:
+ *
+ * - [Changes that are common for the whole library](https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#Common-Changes).
+ *
+ * @param {Date|Number} dateLeft - the later date
+ * @param {Date|Number} dateRight - the earlier date
+ * @returns {Number} the number of full days according to the local timezone
+ * @throws {TypeError} 2 arguments required
+ *
+ * @example
+ * // How many full days are between
+ * // 2 July 2011 23:00:00 and 2 July 2012 00:00:00?
+ * var result = differenceInDays(
+ * new Date(2012, 6, 2, 0, 0),
+ * new Date(2011, 6, 2, 23, 0)
+ * )
+ * //=> 365
+ * // How many full days are between
+ * // 2 July 2011 23:59:00 and 3 July 2011 00:01:00?
+ * var result = differenceInDays(
+ * new Date(2011, 6, 3, 0, 1),
+ * new Date(2011, 6, 2, 23, 59)
+ * )
+ * //=> 0
+ * // How many full days are between
+ * // 1 March 2020 0:00 and 1 June 2020 0:00 ?
+ * // Note: because local time is used, the
+ * // result will always be 92 days, even in
+ * // time zones where DST starts and the
+ * // period has only 92*24-1 hours.
+ * var result = differenceInDays(
+ * new Date(2020, 5, 1),
+ * new Date(2020, 2, 1)
+ * )
+ //=> 92
+ */
+
+
+ function differenceInDays(dirtyDateLeft, dirtyDateRight) {
+ requiredArgs(2, arguments);
+ var dateLeft = toDate(dirtyDateLeft);
+ var dateRight = toDate(dirtyDateRight);
+ var sign = compareLocalAsc(dateLeft, dateRight);
+ var difference = Math.abs(differenceInCalendarDays(dateLeft, dateRight));
+ dateLeft.setDate(dateLeft.getDate() - sign * difference); // Math.abs(diff in full days - diff in calendar days) === 1 if last calendar day is not full
+ // If so, result must be decreased by 1 in absolute value
+
+ var isLastDayNotFull = compareLocalAsc(dateLeft, dateRight) === -sign;
+ var result = sign * (difference - isLastDayNotFull); // Prevent negative zero
+
+ return result === 0 ? 0 : result;
+ }
- function addLeadingZeros(number, targetLength) {
- var sign = number < 0 ? '-' : '';
- var output = Math.abs(number).toString();
+ /**
+ * @name differenceInMilliseconds
+ * @category Millisecond Helpers
+ * @summary Get the number of milliseconds between the given dates.
+ *
+ * @description
+ * Get the number of milliseconds between the given dates.
+ *
+ * ### v2.0.0 breaking changes:
+ *
+ * - [Changes that are common for the whole library](https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#Common-Changes).
+ *
+ * @param {Date|Number} dateLeft - the later date
+ * @param {Date|Number} dateRight - the earlier date
+ * @returns {Number} the number of milliseconds
+ * @throws {TypeError} 2 arguments required
+ *
+ * @example
+ * // How many milliseconds are between
+ * // 2 July 2014 12:30:20.600 and 2 July 2014 12:30:21.700?
+ * var result = differenceInMilliseconds(
+ * new Date(2014, 6, 2, 12, 30, 21, 700),
+ * new Date(2014, 6, 2, 12, 30, 20, 600)
+ * )
+ * //=> 1100
+ */
+
+ function differenceInMilliseconds(dirtyDateLeft, dirtyDateRight) {
+ requiredArgs(2, arguments);
+ var dateLeft = toDate(dirtyDateLeft);
+ var dateRight = toDate(dirtyDateRight);
+ return dateLeft.getTime() - dateRight.getTime();
+ }
- while (output.length < targetLength) {
- output = '0' + output;
- }
+ var MILLISECONDS_IN_HOUR = 3600000;
+ /**
+ * @name differenceInHours
+ * @category Hour Helpers
+ * @summary Get the number of hours between the given dates.
+ *
+ * @description
+ * Get the number of hours between the given dates.
+ *
+ * ### v2.0.0 breaking changes:
+ *
+ * - [Changes that are common for the whole library](https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#Common-Changes).
+ *
+ * @param {Date|Number} dateLeft - the later date
+ * @param {Date|Number} dateRight - the earlier date
+ * @returns {Number} the number of hours
+ * @throws {TypeError} 2 arguments required
+ *
+ * @example
+ * // How many hours are between 2 July 2014 06:50:00 and 2 July 2014 19:00:00?
+ * var result = differenceInHours(
+ * new Date(2014, 6, 2, 19, 0),
+ * new Date(2014, 6, 2, 6, 50)
+ * )
+ * //=> 12
+ */
+
+ function differenceInHours(dirtyDateLeft, dirtyDateRight) {
+ requiredArgs(2, arguments);
+ var diff = differenceInMilliseconds(dirtyDateLeft, dirtyDateRight) / MILLISECONDS_IN_HOUR;
+ return diff > 0 ? Math.floor(diff) : Math.ceil(diff);
+ }
- return sign + output;
- }
+ var MILLISECONDS_IN_MINUTE = 60000;
+ /**
+ * @name differenceInMinutes
+ * @category Minute Helpers
+ * @summary Get the number of minutes between the given dates.
+ *
+ * @description
+ * Get the signed number of full (rounded towards 0) minutes between the given dates.
+ *
+ * ### v2.0.0 breaking changes:
+ *
+ * - [Changes that are common for the whole library](https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#Common-Changes).
+ *
+ * @param {Date|Number} dateLeft - the later date
+ * @param {Date|Number} dateRight - the earlier date
+ * @returns {Number} the number of minutes
+ * @throws {TypeError} 2 arguments required
+ *
+ * @example
+ * // How many minutes are between 2 July 2014 12:07:59 and 2 July 2014 12:20:00?
+ * var result = differenceInMinutes(
+ * new Date(2014, 6, 2, 12, 20, 0),
+ * new Date(2014, 6, 2, 12, 7, 59)
+ * )
+ * //=> 12
+ *
+ * @example
+ * // How many minutes are from 10:01:59 to 10:00:00
+ * var result = differenceInMinutes(
+ * new Date(2000, 0, 1, 10, 0, 0),
+ * new Date(2000, 0, 1, 10, 1, 59)
+ * )
+ * //=> -1
+ */
+
+ function differenceInMinutes(dirtyDateLeft, dirtyDateRight) {
+ requiredArgs(2, arguments);
+ var diff = differenceInMilliseconds(dirtyDateLeft, dirtyDateRight) / MILLISECONDS_IN_MINUTE;
+ return diff > 0 ? Math.floor(diff) : Math.ceil(diff);
+ }
- /*
- * | | Unit | | Unit |
- * |-----|--------------------------------|-----|--------------------------------|
- * | a | AM, PM | A* | |
- * | d | Day of month | D | |
- * | h | Hour [1-12] | H | Hour [0-23] |
- * | m | Minute | M | Month |
- * | s | Second | S | Fraction of second |
- * | y | Year (abs) | Y | |
- *
- * Letters marked by * are not implemented but reserved by Unicode standard.
- */
+ /**
+ * @name endOfDay
+ * @category Day Helpers
+ * @summary Return the end of a day for the given date.
+ *
+ * @description
+ * Return the end of a day for the given date.
+ * The result will be in the local timezone.
+ *
+ * ### v2.0.0 breaking changes:
+ *
+ * - [Changes that are common for the whole library](https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#Common-Changes).
+ *
+ * @param {Date|Number} date - the original date
+ * @returns {Date} the end of a day
+ * @throws {TypeError} 1 argument required
+ *
+ * @example
+ * // The end of a day for 2 September 2014 11:55:00:
+ * const result = endOfDay(new Date(2014, 8, 2, 11, 55, 0))
+ * //=> Tue Sep 02 2014 23:59:59.999
+ */
+
+ function endOfDay(dirtyDate) {
+ requiredArgs(1, arguments);
+ var date = toDate(dirtyDate);
+ date.setHours(23, 59, 59, 999);
+ return date;
+ }
- var formatters$2 = {
- // Year
- y: function (date, token) {
- // From http://www.unicode.org/reports/tr35/tr35-31/tr35-dates.html#Date_Format_tokens
- // | Year | y | yy | yyy | yyyy | yyyyy |
- // |----------|-------|----|-------|-------|-------|
- // | AD 1 | 1 | 01 | 001 | 0001 | 00001 |
- // | AD 12 | 12 | 12 | 012 | 0012 | 00012 |
- // | AD 123 | 123 | 23 | 123 | 0123 | 00123 |
- // | AD 1234 | 1234 | 34 | 1234 | 1234 | 01234 |
- // | AD 12345 | 12345 | 45 | 12345 | 12345 | 12345 |
- var signedYear = date.getUTCFullYear(); // Returns 1 for 1 BC (which is year 0 in JavaScript)
+ /**
+ * @name endOfMonth
+ * @category Month Helpers
+ * @summary Return the end of a month for the given date.
+ *
+ * @description
+ * Return the end of a month for the given date.
+ * The result will be in the local timezone.
+ *
+ * ### v2.0.0 breaking changes:
+ *
+ * - [Changes that are common for the whole library](https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#Common-Changes).
+ *
+ * @param {Date|Number} date - the original date
+ * @returns {Date} the end of a month
+ * @throws {TypeError} 1 argument required
+ *
+ * @example
+ * // The end of a month for 2 September 2014 11:55:00:
+ * const result = endOfMonth(new Date(2014, 8, 2, 11, 55, 0))
+ * //=> Tue Sep 30 2014 23:59:59.999
+ */
+
+ function endOfMonth(dirtyDate) {
+ requiredArgs(1, arguments);
+ var date = toDate(dirtyDate);
+ var month = date.getMonth();
+ date.setFullYear(date.getFullYear(), month + 1, 0);
+ date.setHours(23, 59, 59, 999);
+ return date;
+ }
- var year = signedYear > 0 ? signedYear : 1 - signedYear;
- return addLeadingZeros(token === 'yy' ? year % 100 : year, token.length);
- },
- // Month
- M: function (date, token) {
- var month = date.getUTCMonth();
- return token === 'M' ? String(month + 1) : addLeadingZeros(month + 1, 2);
- },
- // Day of the month
- d: function (date, token) {
- return addLeadingZeros(date.getUTCDate(), token.length);
- },
- // AM or PM
- a: function (date, token) {
- var dayPeriodEnumValue = date.getUTCHours() / 12 >= 1 ? 'pm' : 'am';
-
- switch (token) {
- case 'a':
- case 'aa':
- return dayPeriodEnumValue.toUpperCase();
-
- case 'aaa':
- return dayPeriodEnumValue;
-
- case 'aaaaa':
- return dayPeriodEnumValue[0];
-
- case 'aaaa':
- default:
- return dayPeriodEnumValue === 'am' ? 'a.m.' : 'p.m.';
- }
- },
- // Hour [1-12]
- h: function (date, token) {
- return addLeadingZeros(date.getUTCHours() % 12 || 12, token.length);
- },
- // Hour [0-23]
- H: function (date, token) {
- return addLeadingZeros(date.getUTCHours(), token.length);
- },
- // Minute
- m: function (date, token) {
- return addLeadingZeros(date.getUTCMinutes(), token.length);
- },
- // Second
- s: function (date, token) {
- return addLeadingZeros(date.getUTCSeconds(), token.length);
- },
- // Fraction of second
- S: function (date, token) {
- var numberOfDigits = token.length;
- var milliseconds = date.getUTCMilliseconds();
- var fractionalSeconds = Math.floor(milliseconds * Math.pow(10, numberOfDigits - 3));
- return addLeadingZeros(fractionalSeconds, token.length);
- }
- };
- var formatters$3 = formatters$2;
-
- var MILLISECONDS_IN_DAY = 86400000; // This function will be a part of public API when UTC function will be implemented.
- // See issue: https://github.com/date-fns/date-fns/issues/376
-
- function getUTCDayOfYear(dirtyDate) {
- requiredArgs(1, arguments);
- var date = toDate(dirtyDate);
- var timestamp = date.getTime();
- date.setUTCMonth(0, 1);
- date.setUTCHours(0, 0, 0, 0);
- var startOfYearTimestamp = date.getTime();
- var difference = timestamp - startOfYearTimestamp;
- return Math.floor(difference / MILLISECONDS_IN_DAY) + 1;
- }
+ /**
+ * @name isLastDayOfMonth
+ * @category Month Helpers
+ * @summary Is the given date the last day of a month?
+ *
+ * @description
+ * Is the given date the last day of a month?
+ *
+ * ### v2.0.0 breaking changes:
+ *
+ * - [Changes that are common for the whole library](https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#Common-Changes).
+ *
+ * @param {Date|Number} date - the date to check
+ * @returns {Boolean} the date is the last day of a month
+ * @throws {TypeError} 1 argument required
+ *
+ * @example
+ * // Is 28 February 2014 the last day of a month?
+ * var result = isLastDayOfMonth(new Date(2014, 1, 28))
+ * //=> true
+ */
+
+ function isLastDayOfMonth(dirtyDate) {
+ requiredArgs(1, arguments);
+ var date = toDate(dirtyDate);
+ return endOfDay(date).getTime() === endOfMonth(date).getTime();
+ }
- // See issue: https://github.com/date-fns/date-fns/issues/376
+ /**
+ * @name differenceInMonths
+ * @category Month Helpers
+ * @summary Get the number of full months between the given dates.
+ *
+ * @description
+ * Get the number of full months between the given dates.
+ *
+ * ### v2.0.0 breaking changes:
+ *
+ * - [Changes that are common for the whole library](https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#Common-Changes).
+ *
+ * @param {Date|Number} dateLeft - the later date
+ * @param {Date|Number} dateRight - the earlier date
+ * @returns {Number} the number of full months
+ * @throws {TypeError} 2 arguments required
+ *
+ * @example
+ * // How many full months are between 31 January 2014 and 1 September 2014?
+ * var result = differenceInMonths(new Date(2014, 8, 1), new Date(2014, 0, 31))
+ * //=> 7
+ */
+
+ function differenceInMonths(dirtyDateLeft, dirtyDateRight) {
+ requiredArgs(2, arguments);
+ var dateLeft = toDate(dirtyDateLeft);
+ var dateRight = toDate(dirtyDateRight);
+ var sign = compareAsc(dateLeft, dateRight);
+ var difference = Math.abs(differenceInCalendarMonths(dateLeft, dateRight));
+ var result; // Check for the difference of less than month
+
+ if (difference < 1) {
+ result = 0;
+ } else {
+ if (dateLeft.getMonth() === 1 && dateLeft.getDate() > 27) {
+ // This will check if the date is end of Feb and assign a higher end of month date
+ // to compare it with Jan
+ dateLeft.setDate(30);
+ }
- function startOfUTCISOWeek(dirtyDate) {
- requiredArgs(1, arguments);
- var weekStartsOn = 1;
- var date = toDate(dirtyDate);
- var day = date.getUTCDay();
- var diff = (day < weekStartsOn ? 7 : 0) + day - weekStartsOn;
- date.setUTCDate(date.getUTCDate() - diff);
- date.setUTCHours(0, 0, 0, 0);
- return date;
- }
+ dateLeft.setMonth(dateLeft.getMonth() - sign * difference); // Math.abs(diff in full months - diff in calendar months) === 1 if last calendar month is not full
+ // If so, result must be decreased by 1 in absolute value
- // See issue: https://github.com/date-fns/date-fns/issues/376
+ var isLastMonthNotFull = compareAsc(dateLeft, dateRight) === -sign; // Check for cases of one full calendar month
- function getUTCISOWeekYear(dirtyDate) {
- requiredArgs(1, arguments);
- var date = toDate(dirtyDate);
- var year = date.getUTCFullYear();
- var fourthOfJanuaryOfNextYear = new Date(0);
- fourthOfJanuaryOfNextYear.setUTCFullYear(year + 1, 0, 4);
- fourthOfJanuaryOfNextYear.setUTCHours(0, 0, 0, 0);
- var startOfNextYear = startOfUTCISOWeek(fourthOfJanuaryOfNextYear);
- var fourthOfJanuaryOfThisYear = new Date(0);
- fourthOfJanuaryOfThisYear.setUTCFullYear(year, 0, 4);
- fourthOfJanuaryOfThisYear.setUTCHours(0, 0, 0, 0);
- var startOfThisYear = startOfUTCISOWeek(fourthOfJanuaryOfThisYear);
-
- if (date.getTime() >= startOfNextYear.getTime()) {
- return year + 1;
- } else if (date.getTime() >= startOfThisYear.getTime()) {
- return year;
- } else {
- return year - 1;
+ if (isLastDayOfMonth(toDate(dirtyDateLeft)) && difference === 1 && compareAsc(dirtyDateLeft, dateRight) === 1) {
+ isLastMonthNotFull = false;
}
- }
-
- // See issue: https://github.com/date-fns/date-fns/issues/376
- function startOfUTCISOWeekYear(dirtyDate) {
- requiredArgs(1, arguments);
- var year = getUTCISOWeekYear(dirtyDate);
- var fourthOfJanuary = new Date(0);
- fourthOfJanuary.setUTCFullYear(year, 0, 4);
- fourthOfJanuary.setUTCHours(0, 0, 0, 0);
- var date = startOfUTCISOWeek(fourthOfJanuary);
- return date;
- }
+ result = sign * (difference - isLastMonthNotFull);
+ } // Prevent negative zero
- var MILLISECONDS_IN_WEEK$1 = 604800000; // This function will be a part of public API when UTC function will be implemented.
- // See issue: https://github.com/date-fns/date-fns/issues/376
- function getUTCISOWeek(dirtyDate) {
- requiredArgs(1, arguments);
- var date = toDate(dirtyDate);
- var diff = startOfUTCISOWeek(date).getTime() - startOfUTCISOWeekYear(date).getTime(); // Round the number of days to the nearest integer
- // because the number of milliseconds in a week is not constant
- // (e.g. it's different in the week of the daylight saving time clock shift)
+ return result === 0 ? 0 : result;
+ }
- return Math.round(diff / MILLISECONDS_IN_WEEK$1) + 1;
- }
+ /**
+ * @name differenceInSeconds
+ * @category Second Helpers
+ * @summary Get the number of seconds between the given dates.
+ *
+ * @description
+ * Get the number of seconds between the given dates.
+ *
+ * ### v2.0.0 breaking changes:
+ *
+ * - [Changes that are common for the whole library](https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#Common-Changes).
+ *
+ * @param {Date|Number} dateLeft - the later date
+ * @param {Date|Number} dateRight - the earlier date
+ * @returns {Number} the number of seconds
+ * @throws {TypeError} 2 arguments required
+ *
+ * @example
+ * // How many seconds are between
+ * // 2 July 2014 12:30:07.999 and 2 July 2014 12:30:20.000?
+ * var result = differenceInSeconds(
+ * new Date(2014, 6, 2, 12, 30, 20, 0),
+ * new Date(2014, 6, 2, 12, 30, 7, 999)
+ * )
+ * //=> 12
+ */
+
+ function differenceInSeconds(dirtyDateLeft, dirtyDateRight) {
+ requiredArgs(2, arguments);
+ var diff = differenceInMilliseconds(dirtyDateLeft, dirtyDateRight) / 1000;
+ return diff > 0 ? Math.floor(diff) : Math.ceil(diff);
+ }
- // See issue: https://github.com/date-fns/date-fns/issues/376
+ /**
+ * @name differenceInYears
+ * @category Year Helpers
+ * @summary Get the number of full years between the given dates.
+ *
+ * @description
+ * Get the number of full years between the given dates.
+ *
+ * ### v2.0.0 breaking changes:
+ *
+ * - [Changes that are common for the whole library](https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#Common-Changes).
+ *
+ * @param {Date|Number} dateLeft - the later date
+ * @param {Date|Number} dateRight - the earlier date
+ * @returns {Number} the number of full years
+ * @throws {TypeError} 2 arguments required
+ *
+ * @example
+ * // How many full years are between 31 December 2013 and 11 February 2015?
+ * var result = differenceInYears(new Date(2015, 1, 11), new Date(2013, 11, 31))
+ * //=> 1
+ */
+
+ function differenceInYears(dirtyDateLeft, dirtyDateRight) {
+ requiredArgs(2, arguments);
+ var dateLeft = toDate(dirtyDateLeft);
+ var dateRight = toDate(dirtyDateRight);
+ var sign = compareAsc(dateLeft, dateRight);
+ var difference = Math.abs(differenceInCalendarYears(dateLeft, dateRight)); // Set both dates to a valid leap year for accurate comparison when dealing
+ // with leap days
+
+ dateLeft.setFullYear('1584');
+ dateRight.setFullYear('1584'); // Math.abs(diff in full years - diff in calendar years) === 1 if last calendar year is not full
+ // If so, result must be decreased by 1 in absolute value
+
+ var isLastYearNotFull = compareAsc(dateLeft, dateRight) === -sign;
+ var result = sign * (difference - isLastYearNotFull); // Prevent negative zero
+
+ return result === 0 ? 0 : result;
+ }
- function startOfUTCWeek(dirtyDate, dirtyOptions) {
- requiredArgs(1, arguments);
- var options = dirtyOptions || {};
- var locale = options.locale;
- var localeWeekStartsOn = locale && locale.options && locale.options.weekStartsOn;
- var defaultWeekStartsOn = localeWeekStartsOn == null ? 0 : toInteger(localeWeekStartsOn);
- var weekStartsOn = options.weekStartsOn == null ? defaultWeekStartsOn : toInteger(options.weekStartsOn); // Test if weekStartsOn is between 0 and 6 _and_ is not NaN
+ var formatDistanceLocale = {
+ lessThanXSeconds: {
+ one: 'less than a second',
+ other: 'less than {{count}} seconds'
+ },
+ xSeconds: {
+ one: '1 second',
+ other: '{{count}} seconds'
+ },
+ halfAMinute: 'half a minute',
+ lessThanXMinutes: {
+ one: 'less than a minute',
+ other: 'less than {{count}} minutes'
+ },
+ xMinutes: {
+ one: '1 minute',
+ other: '{{count}} minutes'
+ },
+ aboutXHours: {
+ one: 'about 1 hour',
+ other: 'about {{count}} hours'
+ },
+ xHours: {
+ one: '1 hour',
+ other: '{{count}} hours'
+ },
+ xDays: {
+ one: '1 day',
+ other: '{{count}} days'
+ },
+ aboutXWeeks: {
+ one: 'about 1 week',
+ other: 'about {{count}} weeks'
+ },
+ xWeeks: {
+ one: '1 week',
+ other: '{{count}} weeks'
+ },
+ aboutXMonths: {
+ one: 'about 1 month',
+ other: 'about {{count}} months'
+ },
+ xMonths: {
+ one: '1 month',
+ other: '{{count}} months'
+ },
+ aboutXYears: {
+ one: 'about 1 year',
+ other: 'about {{count}} years'
+ },
+ xYears: {
+ one: '1 year',
+ other: '{{count}} years'
+ },
+ overXYears: {
+ one: 'over 1 year',
+ other: 'over {{count}} years'
+ },
+ almostXYears: {
+ one: 'almost 1 year',
+ other: 'almost {{count}} years'
+ }
+ };
+ function formatDistance(token, count, options) {
+ options = options || {};
+ var result;
+
+ if (typeof formatDistanceLocale[token] === 'string') {
+ result = formatDistanceLocale[token];
+ } else if (count === 1) {
+ result = formatDistanceLocale[token].one;
+ } else {
+ result = formatDistanceLocale[token].other.replace('{{count}}', count);
+ }
- if (!(weekStartsOn >= 0 && weekStartsOn <= 6)) {
- throw new RangeError('weekStartsOn must be between 0 and 6 inclusively');
+ if (options.addSuffix) {
+ if (options.comparison > 0) {
+ return 'in ' + result;
+ } else {
+ return result + ' ago';
}
-
- var date = toDate(dirtyDate);
- var day = date.getUTCDay();
- var diff = (day < weekStartsOn ? 7 : 0) + day - weekStartsOn;
- date.setUTCDate(date.getUTCDate() - diff);
- date.setUTCHours(0, 0, 0, 0);
- return date;
}
- // See issue: https://github.com/date-fns/date-fns/issues/376
+ return result;
+ }
- function getUTCWeekYear(dirtyDate, dirtyOptions) {
- requiredArgs(1, arguments);
- var date = toDate(dirtyDate, dirtyOptions);
- var year = date.getUTCFullYear();
+ function buildFormatLongFn(args) {
+ return function (dirtyOptions) {
var options = dirtyOptions || {};
- var locale = options.locale;
- var localeFirstWeekContainsDate = locale && locale.options && locale.options.firstWeekContainsDate;
- var defaultFirstWeekContainsDate = localeFirstWeekContainsDate == null ? 1 : toInteger(localeFirstWeekContainsDate);
- var firstWeekContainsDate = options.firstWeekContainsDate == null ? defaultFirstWeekContainsDate : toInteger(options.firstWeekContainsDate); // Test if weekStartsOn is between 1 and 7 _and_ is not NaN
-
- if (!(firstWeekContainsDate >= 1 && firstWeekContainsDate <= 7)) {
- throw new RangeError('firstWeekContainsDate must be between 1 and 7 inclusively');
- }
-
- var firstWeekOfNextYear = new Date(0);
- firstWeekOfNextYear.setUTCFullYear(year + 1, 0, firstWeekContainsDate);
- firstWeekOfNextYear.setUTCHours(0, 0, 0, 0);
- var startOfNextYear = startOfUTCWeek(firstWeekOfNextYear, dirtyOptions);
- var firstWeekOfThisYear = new Date(0);
- firstWeekOfThisYear.setUTCFullYear(year, 0, firstWeekContainsDate);
- firstWeekOfThisYear.setUTCHours(0, 0, 0, 0);
- var startOfThisYear = startOfUTCWeek(firstWeekOfThisYear, dirtyOptions);
-
- if (date.getTime() >= startOfNextYear.getTime()) {
- return year + 1;
- } else if (date.getTime() >= startOfThisYear.getTime()) {
- return year;
- } else {
- return year - 1;
- }
- }
+ var width = options.width ? String(options.width) : args.defaultWidth;
+ var format = args.formats[width] || args.formats[args.defaultWidth];
+ return format;
+ };
+ }
- // See issue: https://github.com/date-fns/date-fns/issues/376
+ var dateFormats = {
+ full: 'EEEE, MMMM do, y',
+ long: 'MMMM do, y',
+ medium: 'MMM d, y',
+ short: 'MM/dd/yyyy'
+ };
+ var timeFormats = {
+ full: 'h:mm:ss a zzzz',
+ long: 'h:mm:ss a z',
+ medium: 'h:mm:ss a',
+ short: 'h:mm a'
+ };
+ var dateTimeFormats = {
+ full: "{{date}} 'at' {{time}}",
+ long: "{{date}} 'at' {{time}}",
+ medium: '{{date}}, {{time}}',
+ short: '{{date}}, {{time}}'
+ };
+ var formatLong = {
+ date: buildFormatLongFn({
+ formats: dateFormats,
+ defaultWidth: 'full'
+ }),
+ time: buildFormatLongFn({
+ formats: timeFormats,
+ defaultWidth: 'full'
+ }),
+ dateTime: buildFormatLongFn({
+ formats: dateTimeFormats,
+ defaultWidth: 'full'
+ })
+ };
+ var formatLong$1 = formatLong;
+
+ var formatRelativeLocale = {
+ lastWeek: "'last' eeee 'at' p",
+ yesterday: "'yesterday at' p",
+ today: "'today at' p",
+ tomorrow: "'tomorrow at' p",
+ nextWeek: "eeee 'at' p",
+ other: 'P'
+ };
+ function formatRelative(token, _date, _baseDate, _options) {
+ return formatRelativeLocale[token];
+ }
- function startOfUTCWeekYear(dirtyDate, dirtyOptions) {
- requiredArgs(1, arguments);
+ function buildLocalizeFn(args) {
+ return function (dirtyIndex, dirtyOptions) {
var options = dirtyOptions || {};
- var locale = options.locale;
- var localeFirstWeekContainsDate = locale && locale.options && locale.options.firstWeekContainsDate;
- var defaultFirstWeekContainsDate = localeFirstWeekContainsDate == null ? 1 : toInteger(localeFirstWeekContainsDate);
- var firstWeekContainsDate = options.firstWeekContainsDate == null ? defaultFirstWeekContainsDate : toInteger(options.firstWeekContainsDate);
- var year = getUTCWeekYear(dirtyDate, dirtyOptions);
- var firstWeek = new Date(0);
- firstWeek.setUTCFullYear(year, 0, firstWeekContainsDate);
- firstWeek.setUTCHours(0, 0, 0, 0);
- var date = startOfUTCWeek(firstWeek, dirtyOptions);
- return date;
- }
+ var context = options.context ? String(options.context) : 'standalone';
+ var valuesArray;
+
+ if (context === 'formatting' && args.formattingValues) {
+ var defaultWidth = args.defaultFormattingWidth || args.defaultWidth;
+ var width = options.width ? String(options.width) : defaultWidth;
+ valuesArray = args.formattingValues[width] || args.formattingValues[defaultWidth];
+ } else {
+ var _defaultWidth = args.defaultWidth;
- var MILLISECONDS_IN_WEEK = 604800000; // This function will be a part of public API when UTC function will be implemented.
- // See issue: https://github.com/date-fns/date-fns/issues/376
+ var _width = options.width ? String(options.width) : args.defaultWidth;
- function getUTCWeek(dirtyDate, options) {
- requiredArgs(1, arguments);
- var date = toDate(dirtyDate);
- var diff = startOfUTCWeek(date, options).getTime() - startOfUTCWeekYear(date, options).getTime(); // Round the number of days to the nearest integer
- // because the number of milliseconds in a week is not constant
- // (e.g. it's different in the week of the daylight saving time clock shift)
+ valuesArray = args.values[_width] || args.values[_defaultWidth];
+ }
- return Math.round(diff / MILLISECONDS_IN_WEEK) + 1;
- }
+ var index = args.argumentCallback ? args.argumentCallback(dirtyIndex) : dirtyIndex;
+ return valuesArray[index];
+ };
+ }
- var dayPeriodEnum = {
- am: 'am',
- pm: 'pm',
+ var eraValues = {
+ narrow: ['B', 'A'],
+ abbreviated: ['BC', 'AD'],
+ wide: ['Before Christ', 'Anno Domini']
+ };
+ var quarterValues = {
+ narrow: ['1', '2', '3', '4'],
+ abbreviated: ['Q1', 'Q2', 'Q3', 'Q4'],
+ wide: ['1st quarter', '2nd quarter', '3rd quarter', '4th quarter'] // Note: in English, the names of days of the week and months are capitalized.
+ // If you are making a new locale based on this one, check if the same is true for the language you're working on.
+ // Generally, formatted dates should look like they are in the middle of a sentence,
+ // e.g. in Spanish language the weekdays and months should be in the lowercase.
+
+ };
+ var monthValues = {
+ narrow: ['J', 'F', 'M', 'A', 'M', 'J', 'J', 'A', 'S', 'O', 'N', 'D'],
+ abbreviated: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
+ wide: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']
+ };
+ var dayValues = {
+ narrow: ['S', 'M', 'T', 'W', 'T', 'F', 'S'],
+ short: ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'],
+ abbreviated: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'],
+ wide: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday']
+ };
+ var dayPeriodValues = {
+ narrow: {
+ am: 'a',
+ pm: 'p',
+ midnight: 'mi',
+ noon: 'n',
+ morning: 'morning',
+ afternoon: 'afternoon',
+ evening: 'evening',
+ night: 'night'
+ },
+ abbreviated: {
+ am: 'AM',
+ pm: 'PM',
midnight: 'midnight',
noon: 'noon',
morning: 'morning',
afternoon: 'afternoon',
evening: 'evening',
night: 'night'
- /*
- * | | Unit | | Unit |
- * |-----|--------------------------------|-----|--------------------------------|
- * | a | AM, PM | A* | Milliseconds in day |
- * | b | AM, PM, noon, midnight | B | Flexible day period |
- * | c | Stand-alone local day of week | C* | Localized hour w/ day period |
- * | d | Day of month | D | Day of year |
- * | e | Local day of week | E | Day of week |
- * | f | | F* | Day of week in month |
- * | g* | Modified Julian day | G | Era |
- * | h | Hour [1-12] | H | Hour [0-23] |
- * | i! | ISO day of week | I! | ISO week of year |
- * | j* | Localized hour w/ day period | J* | Localized hour w/o day period |
- * | k | Hour [1-24] | K | Hour [0-11] |
- * | l* | (deprecated) | L | Stand-alone month |
- * | m | Minute | M | Month |
- * | n | | N | |
- * | o! | Ordinal number modifier | O | Timezone (GMT) |
- * | p! | Long localized time | P! | Long localized date |
- * | q | Stand-alone quarter | Q | Quarter |
- * | r* | Related Gregorian year | R! | ISO week-numbering year |
- * | s | Second | S | Fraction of second |
- * | t! | Seconds timestamp | T! | Milliseconds timestamp |
- * | u | Extended year | U* | Cyclic year |
- * | v* | Timezone (generic non-locat.) | V* | Timezone (location) |
- * | w | Local week of year | W* | Week of month |
- * | x | Timezone (ISO-8601 w/o Z) | X | Timezone (ISO-8601) |
- * | y | Year (abs) | Y | Local week-numbering year |
- * | z | Timezone (specific non-locat.) | Z* | Timezone (aliases) |
- *
- * Letters marked by * are not implemented but reserved by Unicode standard.
- *
- * Letters marked by ! are non-standard, but implemented by date-fns:
- * - `o` modifies the previous token to turn it into an ordinal (see `format` docs)
- * - `i` is ISO day of week. For `i` and `ii` is returns numeric ISO week days,
- * i.e. 7 for Sunday, 1 for Monday, etc.
- * - `I` is ISO week of year, as opposed to `w` which is local week of year.
- * - `R` is ISO week-numbering year, as opposed to `Y` which is local week-numbering year.
- * `R` is supposed to be used in conjunction with `I` and `i`
- * for universal ISO week-numbering date, whereas
- * `Y` is supposed to be used in conjunction with `w` and `e`
- * for week-numbering date specific to the locale.
- * - `P` is long localized date format
- * - `p` is long localized time format
- */
+ },
+ wide: {
+ am: 'a.m.',
+ pm: 'p.m.',
+ midnight: 'midnight',
+ noon: 'noon',
+ morning: 'morning',
+ afternoon: 'afternoon',
+ evening: 'evening',
+ night: 'night'
+ }
+ };
+ var formattingDayPeriodValues = {
+ narrow: {
+ am: 'a',
+ pm: 'p',
+ midnight: 'mi',
+ noon: 'n',
+ morning: 'in the morning',
+ afternoon: 'in the afternoon',
+ evening: 'in the evening',
+ night: 'at night'
+ },
+ abbreviated: {
+ am: 'AM',
+ pm: 'PM',
+ midnight: 'midnight',
+ noon: 'noon',
+ morning: 'in the morning',
+ afternoon: 'in the afternoon',
+ evening: 'in the evening',
+ night: 'at night'
+ },
+ wide: {
+ am: 'a.m.',
+ pm: 'p.m.',
+ midnight: 'midnight',
+ noon: 'noon',
+ morning: 'in the morning',
+ afternoon: 'in the afternoon',
+ evening: 'in the evening',
+ night: 'at night'
+ }
+ };
+
+ function ordinalNumber(dirtyNumber, _dirtyOptions) {
+ var number = Number(dirtyNumber); // If ordinal numbers depend on context, for example,
+ // if they are different for different grammatical genders,
+ // use `options.unit`:
+ //
+ // var options = dirtyOptions || {}
+ // var unit = String(options.unit)
+ //
+ // where `unit` can be 'year', 'quarter', 'month', 'week', 'date', 'dayOfYear',
+ // 'day', 'hour', 'minute', 'second'
+
+ var rem100 = number % 100;
+
+ if (rem100 > 20 || rem100 < 10) {
+ switch (rem100 % 10) {
+ case 1:
+ return number + 'st';
+
+ case 2:
+ return number + 'nd';
+
+ case 3:
+ return number + 'rd';
+ }
+ }
- };
- var formatters = {
- // Era
- G: function (date, token, localize) {
- var era = date.getUTCFullYear() > 0 ? 1 : 0;
-
- switch (token) {
- // AD, BC
- case 'G':
- case 'GG':
- case 'GGG':
- return localize.era(era, {
- width: 'abbreviated'
- });
- // A, B
+ return number + 'th';
+ }
- case 'GGGGG':
- return localize.era(era, {
- width: 'narrow'
- });
- // Anno Domini, Before Christ
+ var localize = {
+ ordinalNumber: ordinalNumber,
+ era: buildLocalizeFn({
+ values: eraValues,
+ defaultWidth: 'wide'
+ }),
+ quarter: buildLocalizeFn({
+ values: quarterValues,
+ defaultWidth: 'wide',
+ argumentCallback: function (quarter) {
+ return Number(quarter) - 1;
+ }
+ }),
+ month: buildLocalizeFn({
+ values: monthValues,
+ defaultWidth: 'wide'
+ }),
+ day: buildLocalizeFn({
+ values: dayValues,
+ defaultWidth: 'wide'
+ }),
+ dayPeriod: buildLocalizeFn({
+ values: dayPeriodValues,
+ defaultWidth: 'wide',
+ formattingValues: formattingDayPeriodValues,
+ defaultFormattingWidth: 'wide'
+ })
+ };
+ var localize$1 = localize;
+
+ function buildMatchPatternFn(args) {
+ return function (dirtyString, dirtyOptions) {
+ var string = String(dirtyString);
+ var options = dirtyOptions || {};
+ var matchResult = string.match(args.matchPattern);
- case 'GGGG':
- default:
- return localize.era(era, {
- width: 'wide'
- });
- }
- },
- // Year
- y: function (date, token, localize) {
- // Ordinal number
- if (token === 'yo') {
- var signedYear = date.getUTCFullYear(); // Returns 1 for 1 BC (which is year 0 in JavaScript)
-
- var year = signedYear > 0 ? signedYear : 1 - signedYear;
- return localize.ordinalNumber(year, {
- unit: 'year'
- });
- }
+ if (!matchResult) {
+ return null;
+ }
- return formatters$3.y(date, token);
- },
- // Local week-numbering year
- Y: function (date, token, localize, options) {
- var signedWeekYear = getUTCWeekYear(date, options); // Returns 1 for 1 BC (which is year 0 in JavaScript)
+ var matchedString = matchResult[0];
+ var parseResult = string.match(args.parsePattern);
- var weekYear = signedWeekYear > 0 ? signedWeekYear : 1 - signedWeekYear; // Two digit year
+ if (!parseResult) {
+ return null;
+ }
- if (token === 'YY') {
- var twoDigitYear = weekYear % 100;
- return addLeadingZeros(twoDigitYear, 2);
- } // Ordinal number
+ var value = args.valueCallback ? args.valueCallback(parseResult[0]) : parseResult[0];
+ value = options.valueCallback ? options.valueCallback(value) : value;
+ return {
+ value: value,
+ rest: string.slice(matchedString.length)
+ };
+ };
+ }
+ function buildMatchFn(args) {
+ return function (dirtyString, dirtyOptions) {
+ var string = String(dirtyString);
+ var options = dirtyOptions || {};
+ var width = options.width;
+ var matchPattern = width && args.matchPatterns[width] || args.matchPatterns[args.defaultMatchWidth];
+ var matchResult = string.match(matchPattern);
- if (token === 'Yo') {
- return localize.ordinalNumber(weekYear, {
- unit: 'year'
- });
- } // Padding
-
-
- return addLeadingZeros(weekYear, token.length);
- },
- // ISO week-numbering year
- R: function (date, token) {
- var isoWeekYear = getUTCISOWeekYear(date); // Padding
-
- return addLeadingZeros(isoWeekYear, token.length);
- },
- // Extended year. This is a single number designating the year of this calendar system.
- // The main difference between `y` and `u` localizers are B.C. years:
- // | Year | `y` | `u` |
- // |------|-----|-----|
- // | AC 1 | 1 | 1 |
- // | BC 1 | 1 | 0 |
- // | BC 2 | 2 | -1 |
- // Also `yy` always returns the last two digits of a year,
- // while `uu` pads single digit years to 2 characters and returns other years unchanged.
- u: function (date, token) {
- var year = date.getUTCFullYear();
- return addLeadingZeros(year, token.length);
- },
- // Quarter
- Q: function (date, token, localize) {
- var quarter = Math.ceil((date.getUTCMonth() + 1) / 3);
-
- switch (token) {
- // 1, 2, 3, 4
- case 'Q':
- return String(quarter);
- // 01, 02, 03, 04
-
- case 'QQ':
- return addLeadingZeros(quarter, 2);
- // 1st, 2nd, 3rd, 4th
-
- case 'Qo':
- return localize.ordinalNumber(quarter, {
- unit: 'quarter'
- });
- // Q1, Q2, Q3, Q4
+ if (!matchResult) {
+ return null;
+ }
- case 'QQQ':
- return localize.quarter(quarter, {
- width: 'abbreviated',
- context: 'formatting'
- });
- // 1, 2, 3, 4 (narrow quarter; could be not numerical)
+ var matchedString = matchResult[0];
+ var parsePatterns = width && args.parsePatterns[width] || args.parsePatterns[args.defaultParseWidth];
+ var value;
- case 'QQQQQ':
- return localize.quarter(quarter, {
- width: 'narrow',
- context: 'formatting'
- });
- // 1st quarter, 2nd quarter, ...
+ if (Object.prototype.toString.call(parsePatterns) === '[object Array]') {
+ value = findIndex(parsePatterns, function (pattern) {
+ return pattern.test(matchedString);
+ });
+ } else {
+ value = findKey(parsePatterns, function (pattern) {
+ return pattern.test(matchedString);
+ });
+ }
- case 'QQQQ':
- default:
- return localize.quarter(quarter, {
- width: 'wide',
- context: 'formatting'
- });
- }
- },
- // Stand-alone quarter
- q: function (date, token, localize) {
- var quarter = Math.ceil((date.getUTCMonth() + 1) / 3);
-
- switch (token) {
- // 1, 2, 3, 4
- case 'q':
- return String(quarter);
- // 01, 02, 03, 04
-
- case 'qq':
- return addLeadingZeros(quarter, 2);
- // 1st, 2nd, 3rd, 4th
-
- case 'qo':
- return localize.ordinalNumber(quarter, {
- unit: 'quarter'
- });
- // Q1, Q2, Q3, Q4
+ value = args.valueCallback ? args.valueCallback(value) : value;
+ value = options.valueCallback ? options.valueCallback(value) : value;
+ return {
+ value: value,
+ rest: string.slice(matchedString.length)
+ };
+ };
+ }
- case 'qqq':
- return localize.quarter(quarter, {
- width: 'abbreviated',
- context: 'standalone'
- });
- // 1, 2, 3, 4 (narrow quarter; could be not numerical)
+ function findKey(object, predicate) {
+ for (var key in object) {
+ if (object.hasOwnProperty(key) && predicate(object[key])) {
+ return key;
+ }
+ }
+ }
- case 'qqqqq':
- return localize.quarter(quarter, {
- width: 'narrow',
- context: 'standalone'
- });
- // 1st quarter, 2nd quarter, ...
+ function findIndex(array, predicate) {
+ for (var key = 0; key < array.length; key++) {
+ if (predicate(array[key])) {
+ return key;
+ }
+ }
+ }
- case 'qqqq':
- default:
- return localize.quarter(quarter, {
- width: 'wide',
- context: 'standalone'
- });
- }
- },
- // Month
- M: function (date, token, localize) {
- var month = date.getUTCMonth();
-
- switch (token) {
- case 'M':
- case 'MM':
- return formatters$3.M(date, token);
- // 1st, 2nd, ..., 12th
-
- case 'Mo':
- return localize.ordinalNumber(month + 1, {
- unit: 'month'
- });
- // Jan, Feb, ..., Dec
+ var matchOrdinalNumberPattern = /^(\d+)(th|st|nd|rd)?/i;
+ var parseOrdinalNumberPattern = /\d+/i;
+ var matchEraPatterns = {
+ narrow: /^(b|a)/i,
+ abbreviated: /^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,
+ wide: /^(before christ|before common era|anno domini|common era)/i
+ };
+ var parseEraPatterns = {
+ any: [/^b/i, /^(a|c)/i]
+ };
+ var matchQuarterPatterns = {
+ narrow: /^[1234]/i,
+ abbreviated: /^q[1234]/i,
+ wide: /^[1234](th|st|nd|rd)? quarter/i
+ };
+ var parseQuarterPatterns = {
+ any: [/1/i, /2/i, /3/i, /4/i]
+ };
+ var matchMonthPatterns = {
+ narrow: /^[jfmasond]/i,
+ abbreviated: /^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,
+ wide: /^(january|february|march|april|may|june|july|august|september|october|november|december)/i
+ };
+ var parseMonthPatterns = {
+ narrow: [/^j/i, /^f/i, /^m/i, /^a/i, /^m/i, /^j/i, /^j/i, /^a/i, /^s/i, /^o/i, /^n/i, /^d/i],
+ any: [/^ja/i, /^f/i, /^mar/i, /^ap/i, /^may/i, /^jun/i, /^jul/i, /^au/i, /^s/i, /^o/i, /^n/i, /^d/i]
+ };
+ var matchDayPatterns = {
+ narrow: /^[smtwf]/i,
+ short: /^(su|mo|tu|we|th|fr|sa)/i,
+ abbreviated: /^(sun|mon|tue|wed|thu|fri|sat)/i,
+ wide: /^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i
+ };
+ var parseDayPatterns = {
+ narrow: [/^s/i, /^m/i, /^t/i, /^w/i, /^t/i, /^f/i, /^s/i],
+ any: [/^su/i, /^m/i, /^tu/i, /^w/i, /^th/i, /^f/i, /^sa/i]
+ };
+ var matchDayPeriodPatterns = {
+ narrow: /^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,
+ any: /^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i
+ };
+ var parseDayPeriodPatterns = {
+ any: {
+ am: /^a/i,
+ pm: /^p/i,
+ midnight: /^mi/i,
+ noon: /^no/i,
+ morning: /morning/i,
+ afternoon: /afternoon/i,
+ evening: /evening/i,
+ night: /night/i
+ }
+ };
+ var match = {
+ ordinalNumber: buildMatchPatternFn({
+ matchPattern: matchOrdinalNumberPattern,
+ parsePattern: parseOrdinalNumberPattern,
+ valueCallback: function (value) {
+ return parseInt(value, 10);
+ }
+ }),
+ era: buildMatchFn({
+ matchPatterns: matchEraPatterns,
+ defaultMatchWidth: 'wide',
+ parsePatterns: parseEraPatterns,
+ defaultParseWidth: 'any'
+ }),
+ quarter: buildMatchFn({
+ matchPatterns: matchQuarterPatterns,
+ defaultMatchWidth: 'wide',
+ parsePatterns: parseQuarterPatterns,
+ defaultParseWidth: 'any',
+ valueCallback: function (index) {
+ return index + 1;
+ }
+ }),
+ month: buildMatchFn({
+ matchPatterns: matchMonthPatterns,
+ defaultMatchWidth: 'wide',
+ parsePatterns: parseMonthPatterns,
+ defaultParseWidth: 'any'
+ }),
+ day: buildMatchFn({
+ matchPatterns: matchDayPatterns,
+ defaultMatchWidth: 'wide',
+ parsePatterns: parseDayPatterns,
+ defaultParseWidth: 'any'
+ }),
+ dayPeriod: buildMatchFn({
+ matchPatterns: matchDayPeriodPatterns,
+ defaultMatchWidth: 'any',
+ parsePatterns: parseDayPeriodPatterns,
+ defaultParseWidth: 'any'
+ })
+ };
+ var match$1 = match;
+
+ /**
+ * @type {Locale}
+ * @category Locales
+ * @summary English locale (United States).
+ * @language English
+ * @iso-639-2 eng
+ * @author Sasha Koss [@kossnocorp]{@link https://github.com/kossnocorp}
+ * @author Lesha Koss [@leshakoss]{@link https://github.com/leshakoss}
+ */
+
+ var locale = {
+ code: 'en-US',
+ formatDistance: formatDistance,
+ formatLong: formatLong$1,
+ formatRelative: formatRelative,
+ localize: localize$1,
+ match: match$1,
+ options: {
+ weekStartsOn: 0
+ /* Sunday */
+ ,
+ firstWeekContainsDate: 1
+ }
+ };
+ var defaultLocale = locale;
+
+ /**
+ * @name subMilliseconds
+ * @category Millisecond Helpers
+ * @summary Subtract the specified number of milliseconds from the given date.
+ *
+ * @description
+ * Subtract the specified number of milliseconds from the given date.
+ *
+ * ### v2.0.0 breaking changes:
+ *
+ * - [Changes that are common for the whole library](https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#Common-Changes).
+ *
+ * @param {Date|Number} date - the date to be changed
+ * @param {Number} amount - the amount of milliseconds to be subtracted. Positive decimals will be rounded using `Math.floor`, decimals less than zero will be rounded using `Math.ceil`.
+ * @returns {Date} the new date with the milliseconds subtracted
+ * @throws {TypeError} 2 arguments required
+ *
+ * @example
+ * // Subtract 750 milliseconds from 10 July 2014 12:45:30.000:
+ * const result = subMilliseconds(new Date(2014, 6, 10, 12, 45, 30, 0), 750)
+ * //=> Thu Jul 10 2014 12:45:29.250
+ */
+
+ function subMilliseconds(dirtyDate, dirtyAmount) {
+ requiredArgs(2, arguments);
+ var amount = toInteger(dirtyAmount);
+ return addMilliseconds(dirtyDate, -amount);
+ }
- case 'MMM':
- return localize.month(month, {
- width: 'abbreviated',
- context: 'formatting'
- });
- // J, F, ..., D
+ function addLeadingZeros(number, targetLength) {
+ var sign = number < 0 ? '-' : '';
+ var output = Math.abs(number).toString();
- case 'MMMMM':
- return localize.month(month, {
- width: 'narrow',
- context: 'formatting'
- });
- // January, February, ..., December
+ while (output.length < targetLength) {
+ output = '0' + output;
+ }
- case 'MMMM':
- default:
- return localize.month(month, {
- width: 'wide',
- context: 'formatting'
- });
- }
- },
- // Stand-alone month
- L: function (date, token, localize) {
- var month = date.getUTCMonth();
-
- switch (token) {
- // 1, 2, ..., 12
- case 'L':
- return String(month + 1);
- // 01, 02, ..., 12
-
- case 'LL':
- return addLeadingZeros(month + 1, 2);
- // 1st, 2nd, ..., 12th
-
- case 'Lo':
- return localize.ordinalNumber(month + 1, {
- unit: 'month'
- });
- // Jan, Feb, ..., Dec
+ return sign + output;
+ }
- case 'LLL':
- return localize.month(month, {
- width: 'abbreviated',
- context: 'standalone'
- });
- // J, F, ..., D
+ /*
+ * | | Unit | | Unit |
+ * |-----|--------------------------------|-----|--------------------------------|
+ * | a | AM, PM | A* | |
+ * | d | Day of month | D | |
+ * | h | Hour [1-12] | H | Hour [0-23] |
+ * | m | Minute | M | Month |
+ * | s | Second | S | Fraction of second |
+ * | y | Year (abs) | Y | |
+ *
+ * Letters marked by * are not implemented but reserved by Unicode standard.
+ */
+
+ var formatters$2 = {
+ // Year
+ y: function (date, token) {
+ // From http://www.unicode.org/reports/tr35/tr35-31/tr35-dates.html#Date_Format_tokens
+ // | Year | y | yy | yyy | yyyy | yyyyy |
+ // |----------|-------|----|-------|-------|-------|
+ // | AD 1 | 1 | 01 | 001 | 0001 | 00001 |
+ // | AD 12 | 12 | 12 | 012 | 0012 | 00012 |
+ // | AD 123 | 123 | 23 | 123 | 0123 | 00123 |
+ // | AD 1234 | 1234 | 34 | 1234 | 1234 | 01234 |
+ // | AD 12345 | 12345 | 45 | 12345 | 12345 | 12345 |
+ var signedYear = date.getUTCFullYear(); // Returns 1 for 1 BC (which is year 0 in JavaScript)
+
+ var year = signedYear > 0 ? signedYear : 1 - signedYear;
+ return addLeadingZeros(token === 'yy' ? year % 100 : year, token.length);
+ },
+ // Month
+ M: function (date, token) {
+ var month = date.getUTCMonth();
+ return token === 'M' ? String(month + 1) : addLeadingZeros(month + 1, 2);
+ },
+ // Day of the month
+ d: function (date, token) {
+ return addLeadingZeros(date.getUTCDate(), token.length);
+ },
+ // AM or PM
+ a: function (date, token) {
+ var dayPeriodEnumValue = date.getUTCHours() / 12 >= 1 ? 'pm' : 'am';
+
+ switch (token) {
+ case 'a':
+ case 'aa':
+ return dayPeriodEnumValue.toUpperCase();
+
+ case 'aaa':
+ return dayPeriodEnumValue;
+
+ case 'aaaaa':
+ return dayPeriodEnumValue[0];
+
+ case 'aaaa':
+ default:
+ return dayPeriodEnumValue === 'am' ? 'a.m.' : 'p.m.';
+ }
+ },
+ // Hour [1-12]
+ h: function (date, token) {
+ return addLeadingZeros(date.getUTCHours() % 12 || 12, token.length);
+ },
+ // Hour [0-23]
+ H: function (date, token) {
+ return addLeadingZeros(date.getUTCHours(), token.length);
+ },
+ // Minute
+ m: function (date, token) {
+ return addLeadingZeros(date.getUTCMinutes(), token.length);
+ },
+ // Second
+ s: function (date, token) {
+ return addLeadingZeros(date.getUTCSeconds(), token.length);
+ },
+ // Fraction of second
+ S: function (date, token) {
+ var numberOfDigits = token.length;
+ var milliseconds = date.getUTCMilliseconds();
+ var fractionalSeconds = Math.floor(milliseconds * Math.pow(10, numberOfDigits - 3));
+ return addLeadingZeros(fractionalSeconds, token.length);
+ }
+ };
+ var formatters$3 = formatters$2;
+
+ var MILLISECONDS_IN_DAY = 86400000; // This function will be a part of public API when UTC function will be implemented.
+ // See issue: https://github.com/date-fns/date-fns/issues/376
+
+ function getUTCDayOfYear(dirtyDate) {
+ requiredArgs(1, arguments);
+ var date = toDate(dirtyDate);
+ var timestamp = date.getTime();
+ date.setUTCMonth(0, 1);
+ date.setUTCHours(0, 0, 0, 0);
+ var startOfYearTimestamp = date.getTime();
+ var difference = timestamp - startOfYearTimestamp;
+ return Math.floor(difference / MILLISECONDS_IN_DAY) + 1;
+ }
- case 'LLLLL':
- return localize.month(month, {
- width: 'narrow',
- context: 'standalone'
- });
- // January, February, ..., December
+ // See issue: https://github.com/date-fns/date-fns/issues/376
+
+ function startOfUTCISOWeek(dirtyDate) {
+ requiredArgs(1, arguments);
+ var weekStartsOn = 1;
+ var date = toDate(dirtyDate);
+ var day = date.getUTCDay();
+ var diff = (day < weekStartsOn ? 7 : 0) + day - weekStartsOn;
+ date.setUTCDate(date.getUTCDate() - diff);
+ date.setUTCHours(0, 0, 0, 0);
+ return date;
+ }
- case 'LLLL':
- default:
- return localize.month(month, {
- width: 'wide',
- context: 'standalone'
- });
- }
- },
- // Local week of year
- w: function (date, token, localize, options) {
- var week = getUTCWeek(date, options);
-
- if (token === 'wo') {
- return localize.ordinalNumber(week, {
- unit: 'week'
- });
- }
+ // See issue: https://github.com/date-fns/date-fns/issues/376
+
+ function getUTCISOWeekYear(dirtyDate) {
+ requiredArgs(1, arguments);
+ var date = toDate(dirtyDate);
+ var year = date.getUTCFullYear();
+ var fourthOfJanuaryOfNextYear = new Date(0);
+ fourthOfJanuaryOfNextYear.setUTCFullYear(year + 1, 0, 4);
+ fourthOfJanuaryOfNextYear.setUTCHours(0, 0, 0, 0);
+ var startOfNextYear = startOfUTCISOWeek(fourthOfJanuaryOfNextYear);
+ var fourthOfJanuaryOfThisYear = new Date(0);
+ fourthOfJanuaryOfThisYear.setUTCFullYear(year, 0, 4);
+ fourthOfJanuaryOfThisYear.setUTCHours(0, 0, 0, 0);
+ var startOfThisYear = startOfUTCISOWeek(fourthOfJanuaryOfThisYear);
+
+ if (date.getTime() >= startOfNextYear.getTime()) {
+ return year + 1;
+ } else if (date.getTime() >= startOfThisYear.getTime()) {
+ return year;
+ } else {
+ return year - 1;
+ }
+ }
- return addLeadingZeros(week, token.length);
- },
- // ISO week of year
- I: function (date, token, localize) {
- var isoWeek = getUTCISOWeek(date);
+ // See issue: https://github.com/date-fns/date-fns/issues/376
- if (token === 'Io') {
- return localize.ordinalNumber(isoWeek, {
- unit: 'week'
- });
- }
+ function startOfUTCISOWeekYear(dirtyDate) {
+ requiredArgs(1, arguments);
+ var year = getUTCISOWeekYear(dirtyDate);
+ var fourthOfJanuary = new Date(0);
+ fourthOfJanuary.setUTCFullYear(year, 0, 4);
+ fourthOfJanuary.setUTCHours(0, 0, 0, 0);
+ var date = startOfUTCISOWeek(fourthOfJanuary);
+ return date;
+ }
- return addLeadingZeros(isoWeek, token.length);
- },
- // Day of the month
- d: function (date, token, localize) {
- if (token === 'do') {
- return localize.ordinalNumber(date.getUTCDate(), {
- unit: 'date'
- });
- }
+ var MILLISECONDS_IN_WEEK$1 = 604800000; // This function will be a part of public API when UTC function will be implemented.
+ // See issue: https://github.com/date-fns/date-fns/issues/376
- return formatters$3.d(date, token);
- },
- // Day of year
- D: function (date, token, localize) {
- var dayOfYear = getUTCDayOfYear(date);
+ function getUTCISOWeek(dirtyDate) {
+ requiredArgs(1, arguments);
+ var date = toDate(dirtyDate);
+ var diff = startOfUTCISOWeek(date).getTime() - startOfUTCISOWeekYear(date).getTime(); // Round the number of days to the nearest integer
+ // because the number of milliseconds in a week is not constant
+ // (e.g. it's different in the week of the daylight saving time clock shift)
- if (token === 'Do') {
- return localize.ordinalNumber(dayOfYear, {
- unit: 'dayOfYear'
- });
- }
+ return Math.round(diff / MILLISECONDS_IN_WEEK$1) + 1;
+ }
- return addLeadingZeros(dayOfYear, token.length);
- },
- // Day of week
- E: function (date, token, localize) {
- var dayOfWeek = date.getUTCDay();
-
- switch (token) {
- // Tue
- case 'E':
- case 'EE':
- case 'EEE':
- return localize.day(dayOfWeek, {
- width: 'abbreviated',
- context: 'formatting'
- });
- // T
+ // See issue: https://github.com/date-fns/date-fns/issues/376
- case 'EEEEE':
- return localize.day(dayOfWeek, {
- width: 'narrow',
- context: 'formatting'
- });
- // Tu
+ function startOfUTCWeek(dirtyDate, dirtyOptions) {
+ requiredArgs(1, arguments);
+ var options = dirtyOptions || {};
+ var locale = options.locale;
+ var localeWeekStartsOn = locale && locale.options && locale.options.weekStartsOn;
+ var defaultWeekStartsOn = localeWeekStartsOn == null ? 0 : toInteger(localeWeekStartsOn);
+ var weekStartsOn = options.weekStartsOn == null ? defaultWeekStartsOn : toInteger(options.weekStartsOn); // Test if weekStartsOn is between 0 and 6 _and_ is not NaN
- case 'EEEEEE':
- return localize.day(dayOfWeek, {
- width: 'short',
- context: 'formatting'
- });
- // Tuesday
+ if (!(weekStartsOn >= 0 && weekStartsOn <= 6)) {
+ throw new RangeError('weekStartsOn must be between 0 and 6 inclusively');
+ }
- case 'EEEE':
- default:
- return localize.day(dayOfWeek, {
- width: 'wide',
- context: 'formatting'
- });
- }
- },
- // Local day of week
- e: function (date, token, localize, options) {
- var dayOfWeek = date.getUTCDay();
- var localDayOfWeek = (dayOfWeek - options.weekStartsOn + 8) % 7 || 7;
-
- switch (token) {
- // Numerical value (Nth day of week with current locale or weekStartsOn)
- case 'e':
- return String(localDayOfWeek);
- // Padded numerical value
-
- case 'ee':
- return addLeadingZeros(localDayOfWeek, 2);
- // 1st, 2nd, ..., 7th
-
- case 'eo':
- return localize.ordinalNumber(localDayOfWeek, {
- unit: 'day'
- });
+ var date = toDate(dirtyDate);
+ var day = date.getUTCDay();
+ var diff = (day < weekStartsOn ? 7 : 0) + day - weekStartsOn;
+ date.setUTCDate(date.getUTCDate() - diff);
+ date.setUTCHours(0, 0, 0, 0);
+ return date;
+ }
- case 'eee':
- return localize.day(dayOfWeek, {
- width: 'abbreviated',
- context: 'formatting'
- });
- // T
+ // See issue: https://github.com/date-fns/date-fns/issues/376
- case 'eeeee':
- return localize.day(dayOfWeek, {
- width: 'narrow',
- context: 'formatting'
- });
- // Tu
+ function getUTCWeekYear(dirtyDate, dirtyOptions) {
+ requiredArgs(1, arguments);
+ var date = toDate(dirtyDate, dirtyOptions);
+ var year = date.getUTCFullYear();
+ var options = dirtyOptions || {};
+ var locale = options.locale;
+ var localeFirstWeekContainsDate = locale && locale.options && locale.options.firstWeekContainsDate;
+ var defaultFirstWeekContainsDate = localeFirstWeekContainsDate == null ? 1 : toInteger(localeFirstWeekContainsDate);
+ var firstWeekContainsDate = options.firstWeekContainsDate == null ? defaultFirstWeekContainsDate : toInteger(options.firstWeekContainsDate); // Test if weekStartsOn is between 1 and 7 _and_ is not NaN
- case 'eeeeee':
- return localize.day(dayOfWeek, {
- width: 'short',
- context: 'formatting'
- });
- // Tuesday
+ if (!(firstWeekContainsDate >= 1 && firstWeekContainsDate <= 7)) {
+ throw new RangeError('firstWeekContainsDate must be between 1 and 7 inclusively');
+ }
- case 'eeee':
- default:
- return localize.day(dayOfWeek, {
- width: 'wide',
- context: 'formatting'
- });
- }
- },
- // Stand-alone local day of week
- c: function (date, token, localize, options) {
- var dayOfWeek = date.getUTCDay();
- var localDayOfWeek = (dayOfWeek - options.weekStartsOn + 8) % 7 || 7;
-
- switch (token) {
- // Numerical value (same as in `e`)
- case 'c':
- return String(localDayOfWeek);
- // Padded numerical value
-
- case 'cc':
- return addLeadingZeros(localDayOfWeek, token.length);
- // 1st, 2nd, ..., 7th
-
- case 'co':
- return localize.ordinalNumber(localDayOfWeek, {
- unit: 'day'
- });
+ var firstWeekOfNextYear = new Date(0);
+ firstWeekOfNextYear.setUTCFullYear(year + 1, 0, firstWeekContainsDate);
+ firstWeekOfNextYear.setUTCHours(0, 0, 0, 0);
+ var startOfNextYear = startOfUTCWeek(firstWeekOfNextYear, dirtyOptions);
+ var firstWeekOfThisYear = new Date(0);
+ firstWeekOfThisYear.setUTCFullYear(year, 0, firstWeekContainsDate);
+ firstWeekOfThisYear.setUTCHours(0, 0, 0, 0);
+ var startOfThisYear = startOfUTCWeek(firstWeekOfThisYear, dirtyOptions);
+
+ if (date.getTime() >= startOfNextYear.getTime()) {
+ return year + 1;
+ } else if (date.getTime() >= startOfThisYear.getTime()) {
+ return year;
+ } else {
+ return year - 1;
+ }
+ }
- case 'ccc':
- return localize.day(dayOfWeek, {
- width: 'abbreviated',
- context: 'standalone'
- });
- // T
+ // See issue: https://github.com/date-fns/date-fns/issues/376
+
+ function startOfUTCWeekYear(dirtyDate, dirtyOptions) {
+ requiredArgs(1, arguments);
+ var options = dirtyOptions || {};
+ var locale = options.locale;
+ var localeFirstWeekContainsDate = locale && locale.options && locale.options.firstWeekContainsDate;
+ var defaultFirstWeekContainsDate = localeFirstWeekContainsDate == null ? 1 : toInteger(localeFirstWeekContainsDate);
+ var firstWeekContainsDate = options.firstWeekContainsDate == null ? defaultFirstWeekContainsDate : toInteger(options.firstWeekContainsDate);
+ var year = getUTCWeekYear(dirtyDate, dirtyOptions);
+ var firstWeek = new Date(0);
+ firstWeek.setUTCFullYear(year, 0, firstWeekContainsDate);
+ firstWeek.setUTCHours(0, 0, 0, 0);
+ var date = startOfUTCWeek(firstWeek, dirtyOptions);
+ return date;
+ }
- case 'ccccc':
- return localize.day(dayOfWeek, {
- width: 'narrow',
- context: 'standalone'
- });
- // Tu
+ var MILLISECONDS_IN_WEEK = 604800000; // This function will be a part of public API when UTC function will be implemented.
+ // See issue: https://github.com/date-fns/date-fns/issues/376
- case 'cccccc':
- return localize.day(dayOfWeek, {
- width: 'short',
- context: 'standalone'
- });
- // Tuesday
+ function getUTCWeek(dirtyDate, options) {
+ requiredArgs(1, arguments);
+ var date = toDate(dirtyDate);
+ var diff = startOfUTCWeek(date, options).getTime() - startOfUTCWeekYear(date, options).getTime(); // Round the number of days to the nearest integer
+ // because the number of milliseconds in a week is not constant
+ // (e.g. it's different in the week of the daylight saving time clock shift)
- case 'cccc':
- default:
- return localize.day(dayOfWeek, {
- width: 'wide',
- context: 'standalone'
- });
- }
- },
- // ISO day of week
- i: function (date, token, localize) {
- var dayOfWeek = date.getUTCDay();
- var isoDayOfWeek = dayOfWeek === 0 ? 7 : dayOfWeek;
-
- switch (token) {
- // 2
- case 'i':
- return String(isoDayOfWeek);
- // 02
-
- case 'ii':
- return addLeadingZeros(isoDayOfWeek, token.length);
- // 2nd
-
- case 'io':
- return localize.ordinalNumber(isoDayOfWeek, {
- unit: 'day'
- });
- // Tue
+ return Math.round(diff / MILLISECONDS_IN_WEEK) + 1;
+ }
- case 'iii':
- return localize.day(dayOfWeek, {
- width: 'abbreviated',
- context: 'formatting'
- });
- // T
+ var dayPeriodEnum = {
+ am: 'am',
+ pm: 'pm',
+ midnight: 'midnight',
+ noon: 'noon',
+ morning: 'morning',
+ afternoon: 'afternoon',
+ evening: 'evening',
+ night: 'night'
+ /*
+ * | | Unit | | Unit |
+ * |-----|--------------------------------|-----|--------------------------------|
+ * | a | AM, PM | A* | Milliseconds in day |
+ * | b | AM, PM, noon, midnight | B | Flexible day period |
+ * | c | Stand-alone local day of week | C* | Localized hour w/ day period |
+ * | d | Day of month | D | Day of year |
+ * | e | Local day of week | E | Day of week |
+ * | f | | F* | Day of week in month |
+ * | g* | Modified Julian day | G | Era |
+ * | h | Hour [1-12] | H | Hour [0-23] |
+ * | i! | ISO day of week | I! | ISO week of year |
+ * | j* | Localized hour w/ day period | J* | Localized hour w/o day period |
+ * | k | Hour [1-24] | K | Hour [0-11] |
+ * | l* | (deprecated) | L | Stand-alone month |
+ * | m | Minute | M | Month |
+ * | n | | N | |
+ * | o! | Ordinal number modifier | O | Timezone (GMT) |
+ * | p! | Long localized time | P! | Long localized date |
+ * | q | Stand-alone quarter | Q | Quarter |
+ * | r* | Related Gregorian year | R! | ISO week-numbering year |
+ * | s | Second | S | Fraction of second |
+ * | t! | Seconds timestamp | T! | Milliseconds timestamp |
+ * | u | Extended year | U* | Cyclic year |
+ * | v* | Timezone (generic non-locat.) | V* | Timezone (location) |
+ * | w | Local week of year | W* | Week of month |
+ * | x | Timezone (ISO-8601 w/o Z) | X | Timezone (ISO-8601) |
+ * | y | Year (abs) | Y | Local week-numbering year |
+ * | z | Timezone (specific non-locat.) | Z* | Timezone (aliases) |
+ *
+ * Letters marked by * are not implemented but reserved by Unicode standard.
+ *
+ * Letters marked by ! are non-standard, but implemented by date-fns:
+ * - `o` modifies the previous token to turn it into an ordinal (see `format` docs)
+ * - `i` is ISO day of week. For `i` and `ii` is returns numeric ISO week days,
+ * i.e. 7 for Sunday, 1 for Monday, etc.
+ * - `I` is ISO week of year, as opposed to `w` which is local week of year.
+ * - `R` is ISO week-numbering year, as opposed to `Y` which is local week-numbering year.
+ * `R` is supposed to be used in conjunction with `I` and `i`
+ * for universal ISO week-numbering date, whereas
+ * `Y` is supposed to be used in conjunction with `w` and `e`
+ * for week-numbering date specific to the locale.
+ * - `P` is long localized date format
+ * - `p` is long localized time format
+ */
- case 'iiiii':
- return localize.day(dayOfWeek, {
- width: 'narrow',
- context: 'formatting'
- });
- // Tu
+ };
+ var formatters = {
+ // Era
+ G: function (date, token, localize) {
+ var era = date.getUTCFullYear() > 0 ? 1 : 0;
+
+ switch (token) {
+ // AD, BC
+ case 'G':
+ case 'GG':
+ case 'GGG':
+ return localize.era(era, {
+ width: 'abbreviated'
+ });
+ // A, B
- case 'iiiiii':
- return localize.day(dayOfWeek, {
- width: 'short',
- context: 'formatting'
- });
- // Tuesday
+ case 'GGGGG':
+ return localize.era(era, {
+ width: 'narrow'
+ });
+ // Anno Domini, Before Christ
- case 'iiii':
- default:
- return localize.day(dayOfWeek, {
- width: 'wide',
- context: 'formatting'
- });
- }
- },
- // AM or PM
- a: function (date, token, localize) {
- var hours = date.getUTCHours();
- var dayPeriodEnumValue = hours / 12 >= 1 ? 'pm' : 'am';
-
- switch (token) {
- case 'a':
- case 'aa':
- return localize.dayPeriod(dayPeriodEnumValue, {
- width: 'abbreviated',
- context: 'formatting'
- });
+ case 'GGGG':
+ default:
+ return localize.era(era, {
+ width: 'wide'
+ });
+ }
+ },
+ // Year
+ y: function (date, token, localize) {
+ // Ordinal number
+ if (token === 'yo') {
+ var signedYear = date.getUTCFullYear(); // Returns 1 for 1 BC (which is year 0 in JavaScript)
- case 'aaa':
- return localize.dayPeriod(dayPeriodEnumValue, {
- width: 'abbreviated',
- context: 'formatting'
- }).toLowerCase();
+ var year = signedYear > 0 ? signedYear : 1 - signedYear;
+ return localize.ordinalNumber(year, {
+ unit: 'year'
+ });
+ }
- case 'aaaaa':
- return localize.dayPeriod(dayPeriodEnumValue, {
- width: 'narrow',
- context: 'formatting'
- });
+ return formatters$3.y(date, token);
+ },
+ // Local week-numbering year
+ Y: function (date, token, localize, options) {
+ var signedWeekYear = getUTCWeekYear(date, options); // Returns 1 for 1 BC (which is year 0 in JavaScript)
- case 'aaaa':
- default:
- return localize.dayPeriod(dayPeriodEnumValue, {
- width: 'wide',
- context: 'formatting'
- });
- }
- },
- // AM, PM, midnight, noon
- b: function (date, token, localize) {
- var hours = date.getUTCHours();
- var dayPeriodEnumValue;
-
- if (hours === 12) {
- dayPeriodEnumValue = dayPeriodEnum.noon;
- } else if (hours === 0) {
- dayPeriodEnumValue = dayPeriodEnum.midnight;
- } else {
- dayPeriodEnumValue = hours / 12 >= 1 ? 'pm' : 'am';
- }
+ var weekYear = signedWeekYear > 0 ? signedWeekYear : 1 - signedWeekYear; // Two digit year
- switch (token) {
- case 'b':
- case 'bb':
- return localize.dayPeriod(dayPeriodEnumValue, {
- width: 'abbreviated',
- context: 'formatting'
- });
+ if (token === 'YY') {
+ var twoDigitYear = weekYear % 100;
+ return addLeadingZeros(twoDigitYear, 2);
+ } // Ordinal number
- case 'bbb':
- return localize.dayPeriod(dayPeriodEnumValue, {
- width: 'abbreviated',
- context: 'formatting'
- }).toLowerCase();
- case 'bbbbb':
- return localize.dayPeriod(dayPeriodEnumValue, {
- width: 'narrow',
- context: 'formatting'
- });
+ if (token === 'Yo') {
+ return localize.ordinalNumber(weekYear, {
+ unit: 'year'
+ });
+ } // Padding
+
+
+ return addLeadingZeros(weekYear, token.length);
+ },
+ // ISO week-numbering year
+ R: function (date, token) {
+ var isoWeekYear = getUTCISOWeekYear(date); // Padding
+
+ return addLeadingZeros(isoWeekYear, token.length);
+ },
+ // Extended year. This is a single number designating the year of this calendar system.
+ // The main difference between `y` and `u` localizers are B.C. years:
+ // | Year | `y` | `u` |
+ // |------|-----|-----|
+ // | AC 1 | 1 | 1 |
+ // | BC 1 | 1 | 0 |
+ // | BC 2 | 2 | -1 |
+ // Also `yy` always returns the last two digits of a year,
+ // while `uu` pads single digit years to 2 characters and returns other years unchanged.
+ u: function (date, token) {
+ var year = date.getUTCFullYear();
+ return addLeadingZeros(year, token.length);
+ },
+ // Quarter
+ Q: function (date, token, localize) {
+ var quarter = Math.ceil((date.getUTCMonth() + 1) / 3);
+
+ switch (token) {
+ // 1, 2, 3, 4
+ case 'Q':
+ return String(quarter);
+ // 01, 02, 03, 04
+
+ case 'QQ':
+ return addLeadingZeros(quarter, 2);
+ // 1st, 2nd, 3rd, 4th
+
+ case 'Qo':
+ return localize.ordinalNumber(quarter, {
+ unit: 'quarter'
+ });
+ // Q1, Q2, Q3, Q4
- case 'bbbb':
- default:
- return localize.dayPeriod(dayPeriodEnumValue, {
- width: 'wide',
- context: 'formatting'
- });
- }
- },
- // in the morning, in the afternoon, in the evening, at night
- B: function (date, token, localize) {
- var hours = date.getUTCHours();
- var dayPeriodEnumValue;
-
- if (hours >= 17) {
- dayPeriodEnumValue = dayPeriodEnum.evening;
- } else if (hours >= 12) {
- dayPeriodEnumValue = dayPeriodEnum.afternoon;
- } else if (hours >= 4) {
- dayPeriodEnumValue = dayPeriodEnum.morning;
- } else {
- dayPeriodEnumValue = dayPeriodEnum.night;
- }
+ case 'QQQ':
+ return localize.quarter(quarter, {
+ width: 'abbreviated',
+ context: 'formatting'
+ });
+ // 1, 2, 3, 4 (narrow quarter; could be not numerical)
- switch (token) {
- case 'B':
- case 'BB':
- case 'BBB':
- return localize.dayPeriod(dayPeriodEnumValue, {
- width: 'abbreviated',
- context: 'formatting'
- });
+ case 'QQQQQ':
+ return localize.quarter(quarter, {
+ width: 'narrow',
+ context: 'formatting'
+ });
+ // 1st quarter, 2nd quarter, ...
- case 'BBBBB':
- return localize.dayPeriod(dayPeriodEnumValue, {
- width: 'narrow',
- context: 'formatting'
- });
+ case 'QQQQ':
+ default:
+ return localize.quarter(quarter, {
+ width: 'wide',
+ context: 'formatting'
+ });
+ }
+ },
+ // Stand-alone quarter
+ q: function (date, token, localize) {
+ var quarter = Math.ceil((date.getUTCMonth() + 1) / 3);
+
+ switch (token) {
+ // 1, 2, 3, 4
+ case 'q':
+ return String(quarter);
+ // 01, 02, 03, 04
+
+ case 'qq':
+ return addLeadingZeros(quarter, 2);
+ // 1st, 2nd, 3rd, 4th
+
+ case 'qo':
+ return localize.ordinalNumber(quarter, {
+ unit: 'quarter'
+ });
+ // Q1, Q2, Q3, Q4
- case 'BBBB':
- default:
- return localize.dayPeriod(dayPeriodEnumValue, {
- width: 'wide',
- context: 'formatting'
- });
- }
- },
- // Hour [1-12]
- h: function (date, token, localize) {
- if (token === 'ho') {
- var hours = date.getUTCHours() % 12;
- if (hours === 0) hours = 12;
- return localize.ordinalNumber(hours, {
- unit: 'hour'
+ case 'qqq':
+ return localize.quarter(quarter, {
+ width: 'abbreviated',
+ context: 'standalone'
});
- }
+ // 1, 2, 3, 4 (narrow quarter; could be not numerical)
- return formatters$3.h(date, token);
- },
- // Hour [0-23]
- H: function (date, token, localize) {
- if (token === 'Ho') {
- return localize.ordinalNumber(date.getUTCHours(), {
- unit: 'hour'
+ case 'qqqqq':
+ return localize.quarter(quarter, {
+ width: 'narrow',
+ context: 'standalone'
});
- }
+ // 1st quarter, 2nd quarter, ...
- return formatters$3.H(date, token);
- },
- // Hour [0-11]
- K: function (date, token, localize) {
- var hours = date.getUTCHours() % 12;
+ case 'qqqq':
+ default:
+ return localize.quarter(quarter, {
+ width: 'wide',
+ context: 'standalone'
+ });
+ }
+ },
+ // Month
+ M: function (date, token, localize) {
+ var month = date.getUTCMonth();
+
+ switch (token) {
+ case 'M':
+ case 'MM':
+ return formatters$3.M(date, token);
+ // 1st, 2nd, ..., 12th
+
+ case 'Mo':
+ return localize.ordinalNumber(month + 1, {
+ unit: 'month'
+ });
+ // Jan, Feb, ..., Dec
- if (token === 'Ko') {
- return localize.ordinalNumber(hours, {
- unit: 'hour'
+ case 'MMM':
+ return localize.month(month, {
+ width: 'abbreviated',
+ context: 'formatting'
});
- }
+ // J, F, ..., D
- return addLeadingZeros(hours, token.length);
- },
- // Hour [1-24]
- k: function (date, token, localize) {
- var hours = date.getUTCHours();
- if (hours === 0) hours = 24;
+ case 'MMMMM':
+ return localize.month(month, {
+ width: 'narrow',
+ context: 'formatting'
+ });
+ // January, February, ..., December
- if (token === 'ko') {
- return localize.ordinalNumber(hours, {
- unit: 'hour'
+ case 'MMMM':
+ default:
+ return localize.month(month, {
+ width: 'wide',
+ context: 'formatting'
});
- }
+ }
+ },
+ // Stand-alone month
+ L: function (date, token, localize) {
+ var month = date.getUTCMonth();
+
+ switch (token) {
+ // 1, 2, ..., 12
+ case 'L':
+ return String(month + 1);
+ // 01, 02, ..., 12
+
+ case 'LL':
+ return addLeadingZeros(month + 1, 2);
+ // 1st, 2nd, ..., 12th
+
+ case 'Lo':
+ return localize.ordinalNumber(month + 1, {
+ unit: 'month'
+ });
+ // Jan, Feb, ..., Dec
- return addLeadingZeros(hours, token.length);
- },
- // Minute
- m: function (date, token, localize) {
- if (token === 'mo') {
- return localize.ordinalNumber(date.getUTCMinutes(), {
- unit: 'minute'
+ case 'LLL':
+ return localize.month(month, {
+ width: 'abbreviated',
+ context: 'standalone'
});
- }
+ // J, F, ..., D
- return formatters$3.m(date, token);
- },
- // Second
- s: function (date, token, localize) {
- if (token === 'so') {
- return localize.ordinalNumber(date.getUTCSeconds(), {
- unit: 'second'
+ case 'LLLLL':
+ return localize.month(month, {
+ width: 'narrow',
+ context: 'standalone'
});
- }
+ // January, February, ..., December
- return formatters$3.s(date, token);
- },
- // Fraction of second
- S: function (date, token) {
- return formatters$3.S(date, token);
- },
- // Timezone (ISO-8601. If offset is 0, output is always `'Z'`)
- X: function (date, token, _localize, options) {
- var originalDate = options._originalDate || date;
- var timezoneOffset = originalDate.getTimezoneOffset();
-
- if (timezoneOffset === 0) {
- return 'Z';
- }
+ case 'LLLL':
+ default:
+ return localize.month(month, {
+ width: 'wide',
+ context: 'standalone'
+ });
+ }
+ },
+ // Local week of year
+ w: function (date, token, localize, options) {
+ var week = getUTCWeek(date, options);
+
+ if (token === 'wo') {
+ return localize.ordinalNumber(week, {
+ unit: 'week'
+ });
+ }
- switch (token) {
- // Hours and optional minutes
- case 'X':
- return formatTimezoneWithOptionalMinutes(timezoneOffset);
- // Hours, minutes and optional seconds without `:` delimiter
- // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
- // so this token always has the same output as `XX`
-
- case 'XXXX':
- case 'XX':
- // Hours and minutes without `:` delimiter
- return formatTimezone(timezoneOffset);
- // Hours, minutes and optional seconds with `:` delimiter
- // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
- // so this token always has the same output as `XXX`
-
- case 'XXXXX':
- case 'XXX': // Hours and minutes with `:` delimiter
-
- default:
- return formatTimezone(timezoneOffset, ':');
- }
- },
- // Timezone (ISO-8601. If offset is 0, output is `'+00:00'` or equivalent)
- x: function (date, token, _localize, options) {
- var originalDate = options._originalDate || date;
- var timezoneOffset = originalDate.getTimezoneOffset();
-
- switch (token) {
- // Hours and optional minutes
- case 'x':
- return formatTimezoneWithOptionalMinutes(timezoneOffset);
- // Hours, minutes and optional seconds without `:` delimiter
- // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
- // so this token always has the same output as `xx`
-
- case 'xxxx':
- case 'xx':
- // Hours and minutes without `:` delimiter
- return formatTimezone(timezoneOffset);
- // Hours, minutes and optional seconds with `:` delimiter
- // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
- // so this token always has the same output as `xxx`
-
- case 'xxxxx':
- case 'xxx': // Hours and minutes with `:` delimiter
-
- default:
- return formatTimezone(timezoneOffset, ':');
- }
- },
- // Timezone (GMT)
- O: function (date, token, _localize, options) {
- var originalDate = options._originalDate || date;
- var timezoneOffset = originalDate.getTimezoneOffset();
-
- switch (token) {
- // Short
- case 'O':
- case 'OO':
- case 'OOO':
- return 'GMT' + formatTimezoneShort(timezoneOffset, ':');
- // Long
-
- case 'OOOO':
- default:
- return 'GMT' + formatTimezone(timezoneOffset, ':');
- }
- },
- // Timezone (specific non-location)
- z: function (date, token, _localize, options) {
- var originalDate = options._originalDate || date;
- var timezoneOffset = originalDate.getTimezoneOffset();
-
- switch (token) {
- // Short
- case 'z':
- case 'zz':
- case 'zzz':
- return 'GMT' + formatTimezoneShort(timezoneOffset, ':');
- // Long
-
- case 'zzzz':
- default:
- return 'GMT' + formatTimezone(timezoneOffset, ':');
- }
- },
- // Seconds timestamp
- t: function (date, token, _localize, options) {
- var originalDate = options._originalDate || date;
- var timestamp = Math.floor(originalDate.getTime() / 1000);
- return addLeadingZeros(timestamp, token.length);
- },
- // Milliseconds timestamp
- T: function (date, token, _localize, options) {
- var originalDate = options._originalDate || date;
- var timestamp = originalDate.getTime();
- return addLeadingZeros(timestamp, token.length);
+ return addLeadingZeros(week, token.length);
+ },
+ // ISO week of year
+ I: function (date, token, localize) {
+ var isoWeek = getUTCISOWeek(date);
+
+ if (token === 'Io') {
+ return localize.ordinalNumber(isoWeek, {
+ unit: 'week'
+ });
}
- };
- function formatTimezoneShort(offset, dirtyDelimiter) {
- var sign = offset > 0 ? '-' : '+';
- var absOffset = Math.abs(offset);
- var hours = Math.floor(absOffset / 60);
- var minutes = absOffset % 60;
+ return addLeadingZeros(isoWeek, token.length);
+ },
+ // Day of the month
+ d: function (date, token, localize) {
+ if (token === 'do') {
+ return localize.ordinalNumber(date.getUTCDate(), {
+ unit: 'date'
+ });
+ }
+
+ return formatters$3.d(date, token);
+ },
+ // Day of year
+ D: function (date, token, localize) {
+ var dayOfYear = getUTCDayOfYear(date);
- if (minutes === 0) {
- return sign + String(hours);
+ if (token === 'Do') {
+ return localize.ordinalNumber(dayOfYear, {
+ unit: 'dayOfYear'
+ });
}
- var delimiter = dirtyDelimiter || '';
- return sign + String(hours) + delimiter + addLeadingZeros(minutes, 2);
- }
+ return addLeadingZeros(dayOfYear, token.length);
+ },
+ // Day of week
+ E: function (date, token, localize) {
+ var dayOfWeek = date.getUTCDay();
+
+ switch (token) {
+ // Tue
+ case 'E':
+ case 'EE':
+ case 'EEE':
+ return localize.day(dayOfWeek, {
+ width: 'abbreviated',
+ context: 'formatting'
+ });
+ // T
+
+ case 'EEEEE':
+ return localize.day(dayOfWeek, {
+ width: 'narrow',
+ context: 'formatting'
+ });
+ // Tu
+
+ case 'EEEEEE':
+ return localize.day(dayOfWeek, {
+ width: 'short',
+ context: 'formatting'
+ });
+ // Tuesday
- function formatTimezoneWithOptionalMinutes(offset, dirtyDelimiter) {
- if (offset % 60 === 0) {
- var sign = offset > 0 ? '-' : '+';
- return sign + addLeadingZeros(Math.abs(offset) / 60, 2);
+ case 'EEEE':
+ default:
+ return localize.day(dayOfWeek, {
+ width: 'wide',
+ context: 'formatting'
+ });
}
+ },
+ // Local day of week
+ e: function (date, token, localize, options) {
+ var dayOfWeek = date.getUTCDay();
+ var localDayOfWeek = (dayOfWeek - options.weekStartsOn + 8) % 7 || 7;
+
+ switch (token) {
+ // Numerical value (Nth day of week with current locale or weekStartsOn)
+ case 'e':
+ return String(localDayOfWeek);
+ // Padded numerical value
+
+ case 'ee':
+ return addLeadingZeros(localDayOfWeek, 2);
+ // 1st, 2nd, ..., 7th
+
+ case 'eo':
+ return localize.ordinalNumber(localDayOfWeek, {
+ unit: 'day'
+ });
- return formatTimezone(offset, dirtyDelimiter);
- }
+ case 'eee':
+ return localize.day(dayOfWeek, {
+ width: 'abbreviated',
+ context: 'formatting'
+ });
+ // T
- function formatTimezone(offset, dirtyDelimiter) {
- var delimiter = dirtyDelimiter || '';
- var sign = offset > 0 ? '-' : '+';
- var absOffset = Math.abs(offset);
- var hours = addLeadingZeros(Math.floor(absOffset / 60), 2);
- var minutes = addLeadingZeros(absOffset % 60, 2);
- return sign + hours + delimiter + minutes;
- }
+ case 'eeeee':
+ return localize.day(dayOfWeek, {
+ width: 'narrow',
+ context: 'formatting'
+ });
+ // Tu
- var formatters$1 = formatters;
+ case 'eeeeee':
+ return localize.day(dayOfWeek, {
+ width: 'short',
+ context: 'formatting'
+ });
+ // Tuesday
+
+ case 'eeee':
+ default:
+ return localize.day(dayOfWeek, {
+ width: 'wide',
+ context: 'formatting'
+ });
+ }
+ },
+ // Stand-alone local day of week
+ c: function (date, token, localize, options) {
+ var dayOfWeek = date.getUTCDay();
+ var localDayOfWeek = (dayOfWeek - options.weekStartsOn + 8) % 7 || 7;
+
+ switch (token) {
+ // Numerical value (same as in `e`)
+ case 'c':
+ return String(localDayOfWeek);
+ // Padded numerical value
+
+ case 'cc':
+ return addLeadingZeros(localDayOfWeek, token.length);
+ // 1st, 2nd, ..., 7th
+
+ case 'co':
+ return localize.ordinalNumber(localDayOfWeek, {
+ unit: 'day'
+ });
- function dateLongFormatter(pattern, formatLong) {
- switch (pattern) {
- case 'P':
- return formatLong.date({
- width: 'short'
+ case 'ccc':
+ return localize.day(dayOfWeek, {
+ width: 'abbreviated',
+ context: 'standalone'
});
+ // T
- case 'PP':
- return formatLong.date({
- width: 'medium'
+ case 'ccccc':
+ return localize.day(dayOfWeek, {
+ width: 'narrow',
+ context: 'standalone'
});
+ // Tu
- case 'PPP':
- return formatLong.date({
- width: 'long'
+ case 'cccccc':
+ return localize.day(dayOfWeek, {
+ width: 'short',
+ context: 'standalone'
});
+ // Tuesday
- case 'PPPP':
+ case 'cccc':
default:
- return formatLong.date({
- width: 'full'
+ return localize.day(dayOfWeek, {
+ width: 'wide',
+ context: 'standalone'
});
}
- }
+ },
+ // ISO day of week
+ i: function (date, token, localize) {
+ var dayOfWeek = date.getUTCDay();
+ var isoDayOfWeek = dayOfWeek === 0 ? 7 : dayOfWeek;
+
+ switch (token) {
+ // 2
+ case 'i':
+ return String(isoDayOfWeek);
+ // 02
+
+ case 'ii':
+ return addLeadingZeros(isoDayOfWeek, token.length);
+ // 2nd
+
+ case 'io':
+ return localize.ordinalNumber(isoDayOfWeek, {
+ unit: 'day'
+ });
+ // Tue
- function timeLongFormatter(pattern, formatLong) {
- switch (pattern) {
- case 'p':
- return formatLong.time({
- width: 'short'
+ case 'iii':
+ return localize.day(dayOfWeek, {
+ width: 'abbreviated',
+ context: 'formatting'
});
+ // T
- case 'pp':
- return formatLong.time({
- width: 'medium'
+ case 'iiiii':
+ return localize.day(dayOfWeek, {
+ width: 'narrow',
+ context: 'formatting'
});
+ // Tu
- case 'ppp':
- return formatLong.time({
- width: 'long'
+ case 'iiiiii':
+ return localize.day(dayOfWeek, {
+ width: 'short',
+ context: 'formatting'
});
+ // Tuesday
- case 'pppp':
+ case 'iiii':
default:
- return formatLong.time({
- width: 'full'
+ return localize.day(dayOfWeek, {
+ width: 'wide',
+ context: 'formatting'
});
}
- }
+ },
+ // AM or PM
+ a: function (date, token, localize) {
+ var hours = date.getUTCHours();
+ var dayPeriodEnumValue = hours / 12 >= 1 ? 'pm' : 'am';
+
+ switch (token) {
+ case 'a':
+ case 'aa':
+ return localize.dayPeriod(dayPeriodEnumValue, {
+ width: 'abbreviated',
+ context: 'formatting'
+ });
+
+ case 'aaa':
+ return localize.dayPeriod(dayPeriodEnumValue, {
+ width: 'abbreviated',
+ context: 'formatting'
+ }).toLowerCase();
- function dateTimeLongFormatter(pattern, formatLong) {
- var matchResult = pattern.match(/(P+)(p+)?/);
- var datePattern = matchResult[1];
- var timePattern = matchResult[2];
+ case 'aaaaa':
+ return localize.dayPeriod(dayPeriodEnumValue, {
+ width: 'narrow',
+ context: 'formatting'
+ });
- if (!timePattern) {
- return dateLongFormatter(pattern, formatLong);
+ case 'aaaa':
+ default:
+ return localize.dayPeriod(dayPeriodEnumValue, {
+ width: 'wide',
+ context: 'formatting'
+ });
+ }
+ },
+ // AM, PM, midnight, noon
+ b: function (date, token, localize) {
+ var hours = date.getUTCHours();
+ var dayPeriodEnumValue;
+
+ if (hours === 12) {
+ dayPeriodEnumValue = dayPeriodEnum.noon;
+ } else if (hours === 0) {
+ dayPeriodEnumValue = dayPeriodEnum.midnight;
+ } else {
+ dayPeriodEnumValue = hours / 12 >= 1 ? 'pm' : 'am';
}
- var dateTimeFormat;
+ switch (token) {
+ case 'b':
+ case 'bb':
+ return localize.dayPeriod(dayPeriodEnumValue, {
+ width: 'abbreviated',
+ context: 'formatting'
+ });
+
+ case 'bbb':
+ return localize.dayPeriod(dayPeriodEnumValue, {
+ width: 'abbreviated',
+ context: 'formatting'
+ }).toLowerCase();
- switch (datePattern) {
- case 'P':
- dateTimeFormat = formatLong.dateTime({
- width: 'short'
+ case 'bbbbb':
+ return localize.dayPeriod(dayPeriodEnumValue, {
+ width: 'narrow',
+ context: 'formatting'
});
- break;
- case 'PP':
- dateTimeFormat = formatLong.dateTime({
- width: 'medium'
+ case 'bbbb':
+ default:
+ return localize.dayPeriod(dayPeriodEnumValue, {
+ width: 'wide',
+ context: 'formatting'
+ });
+ }
+ },
+ // in the morning, in the afternoon, in the evening, at night
+ B: function (date, token, localize) {
+ var hours = date.getUTCHours();
+ var dayPeriodEnumValue;
+
+ if (hours >= 17) {
+ dayPeriodEnumValue = dayPeriodEnum.evening;
+ } else if (hours >= 12) {
+ dayPeriodEnumValue = dayPeriodEnum.afternoon;
+ } else if (hours >= 4) {
+ dayPeriodEnumValue = dayPeriodEnum.morning;
+ } else {
+ dayPeriodEnumValue = dayPeriodEnum.night;
+ }
+
+ switch (token) {
+ case 'B':
+ case 'BB':
+ case 'BBB':
+ return localize.dayPeriod(dayPeriodEnumValue, {
+ width: 'abbreviated',
+ context: 'formatting'
});
- break;
- case 'PPP':
- dateTimeFormat = formatLong.dateTime({
- width: 'long'
+ case 'BBBBB':
+ return localize.dayPeriod(dayPeriodEnumValue, {
+ width: 'narrow',
+ context: 'formatting'
});
- break;
- case 'PPPP':
+ case 'BBBB':
default:
- dateTimeFormat = formatLong.dateTime({
- width: 'full'
+ return localize.dayPeriod(dayPeriodEnumValue, {
+ width: 'wide',
+ context: 'formatting'
});
- break;
+ }
+ },
+ // Hour [1-12]
+ h: function (date, token, localize) {
+ if (token === 'ho') {
+ var hours = date.getUTCHours() % 12;
+ if (hours === 0) hours = 12;
+ return localize.ordinalNumber(hours, {
+ unit: 'hour'
+ });
}
- return dateTimeFormat.replace('{{date}}', dateLongFormatter(datePattern, formatLong)).replace('{{time}}', timeLongFormatter(timePattern, formatLong));
- }
+ return formatters$3.h(date, token);
+ },
+ // Hour [0-23]
+ H: function (date, token, localize) {
+ if (token === 'Ho') {
+ return localize.ordinalNumber(date.getUTCHours(), {
+ unit: 'hour'
+ });
+ }
- var longFormatters = {
- p: timeLongFormatter,
- P: dateTimeLongFormatter
- };
- var longFormatters$1 = longFormatters;
+ return formatters$3.H(date, token);
+ },
+ // Hour [0-11]
+ K: function (date, token, localize) {
+ var hours = date.getUTCHours() % 12;
- var protectedDayOfYearTokens = ['D', 'DD'];
- var protectedWeekYearTokens = ['YY', 'YYYY'];
- function isProtectedDayOfYearToken(token) {
- return protectedDayOfYearTokens.indexOf(token) !== -1;
- }
- function isProtectedWeekYearToken(token) {
- return protectedWeekYearTokens.indexOf(token) !== -1;
- }
- function throwProtectedError(token, format, input) {
- if (token === 'YYYY') {
- throw new RangeError("Use `yyyy` instead of `YYYY` (in `".concat(format, "`) for formatting years to the input `").concat(input, "`; see: https://git.io/fxCyr"));
- } else if (token === 'YY') {
- throw new RangeError("Use `yy` instead of `YY` (in `".concat(format, "`) for formatting years to the input `").concat(input, "`; see: https://git.io/fxCyr"));
- } else if (token === 'D') {
- throw new RangeError("Use `d` instead of `D` (in `".concat(format, "`) for formatting days of the month to the input `").concat(input, "`; see: https://git.io/fxCyr"));
- } else if (token === 'DD') {
- throw new RangeError("Use `dd` instead of `DD` (in `".concat(format, "`) for formatting days of the month to the input `").concat(input, "`; see: https://git.io/fxCyr"));
+ if (token === 'Ko') {
+ return localize.ordinalNumber(hours, {
+ unit: 'hour'
+ });
}
- }
- // - [yYQqMLwIdDecihHKkms]o matches any available ordinal number token
- // (one of the certain letters followed by `o`)
- // - (\w)\1* matches any sequences of the same letter
- // - '' matches two quote characters in a row
- // - '(''|[^'])+('|$) matches anything surrounded by two quote characters ('),
- // except a single quote symbol, which ends the sequence.
- // Two quote characters do not end the sequence.
- // If there is no matching single quote
- // then the sequence will continue until the end of the string.
- // - . matches any single character unmatched by previous parts of the RegExps
-
- var formattingTokensRegExp = /[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g; // This RegExp catches symbols escaped by quotes, and also
- // sequences of symbols P, p, and the combinations like `PPPPPPPppppp`
-
- var longFormattingTokensRegExp = /P+p+|P+|p+|''|'(''|[^'])+('|$)|./g;
- var escapedStringRegExp = /^'([^]*?)'?$/;
- var doubleQuoteRegExp = /''/g;
- var unescapedLatinCharacterRegExp = /[a-zA-Z]/;
- /**
- * @name format
- * @category Common Helpers
- * @summary Format the date.
- *
- * @description
- * Return the formatted date string in the given format. The result may vary by locale.
- *
- * > ⚠️ Please note that the `format` tokens differ from Moment.js and other libraries.
- * > See: https://git.io/fxCyr
- *
- * The characters wrapped between two single quotes characters (') are escaped.
- * Two single quotes in a row, whether inside or outside a quoted sequence, represent a 'real' single quote.
- * (see the last example)
- *
- * Format of the string is based on Unicode Technical Standard #35:
- * https://www.unicode.org/reports/tr35/tr35-dates.html#Date_Field_Symbol_Table
- * with a few additions (see note 7 below the table).
- *
- * Accepted patterns:
- * | Unit | Pattern | Result examples | Notes |
- * |---------------------------------|---------|-----------------------------------|-------|
- * | Era | G..GGG | AD, BC | |
- * | | GGGG | Anno Domini, Before Christ | 2 |
- * | | GGGGG | A, B | |
- * | Calendar year | y | 44, 1, 1900, 2017 | 5 |
- * | | yo | 44th, 1st, 0th, 17th | 5,7 |
- * | | yy | 44, 01, 00, 17 | 5 |
- * | | yyy | 044, 001, 1900, 2017 | 5 |
- * | | yyyy | 0044, 0001, 1900, 2017 | 5 |
- * | | yyyyy | ... | 3,5 |
- * | Local week-numbering year | Y | 44, 1, 1900, 2017 | 5 |
- * | | Yo | 44th, 1st, 1900th, 2017th | 5,7 |
- * | | YY | 44, 01, 00, 17 | 5,8 |
- * | | YYY | 044, 001, 1900, 2017 | 5 |
- * | | YYYY | 0044, 0001, 1900, 2017 | 5,8 |
- * | | YYYYY | ... | 3,5 |
- * | ISO week-numbering year | R | -43, 0, 1, 1900, 2017 | 5,7 |
- * | | RR | -43, 00, 01, 1900, 2017 | 5,7 |
- * | | RRR | -043, 000, 001, 1900, 2017 | 5,7 |
- * | | RRRR | -0043, 0000, 0001, 1900, 2017 | 5,7 |
- * | | RRRRR | ... | 3,5,7 |
- * | Extended year | u | -43, 0, 1, 1900, 2017 | 5 |
- * | | uu | -43, 01, 1900, 2017 | 5 |
- * | | uuu | -043, 001, 1900, 2017 | 5 |
- * | | uuuu | -0043, 0001, 1900, 2017 | 5 |
- * | | uuuuu | ... | 3,5 |
- * | Quarter (formatting) | Q | 1, 2, 3, 4 | |
- * | | Qo | 1st, 2nd, 3rd, 4th | 7 |
- * | | QQ | 01, 02, 03, 04 | |
- * | | QQQ | Q1, Q2, Q3, Q4 | |
- * | | QQQQ | 1st quarter, 2nd quarter, ... | 2 |
- * | | QQQQQ | 1, 2, 3, 4 | 4 |
- * | Quarter (stand-alone) | q | 1, 2, 3, 4 | |
- * | | qo | 1st, 2nd, 3rd, 4th | 7 |
- * | | qq | 01, 02, 03, 04 | |
- * | | qqq | Q1, Q2, Q3, Q4 | |
- * | | qqqq | 1st quarter, 2nd quarter, ... | 2 |
- * | | qqqqq | 1, 2, 3, 4 | 4 |
- * | Month (formatting) | M | 1, 2, ..., 12 | |
- * | | Mo | 1st, 2nd, ..., 12th | 7 |
- * | | MM | 01, 02, ..., 12 | |
- * | | MMM | Jan, Feb, ..., Dec | |
- * | | MMMM | January, February, ..., December | 2 |
- * | | MMMMM | J, F, ..., D | |
- * | Month (stand-alone) | L | 1, 2, ..., 12 | |
- * | | Lo | 1st, 2nd, ..., 12th | 7 |
- * | | LL | 01, 02, ..., 12 | |
- * | | LLL | Jan, Feb, ..., Dec | |
- * | | LLLL | January, February, ..., December | 2 |
- * | | LLLLL | J, F, ..., D | |
- * | Local week of year | w | 1, 2, ..., 53 | |
- * | | wo | 1st, 2nd, ..., 53th | 7 |
- * | | ww | 01, 02, ..., 53 | |
- * | ISO week of year | I | 1, 2, ..., 53 | 7 |
- * | | Io | 1st, 2nd, ..., 53th | 7 |
- * | | II | 01, 02, ..., 53 | 7 |
- * | Day of month | d | 1, 2, ..., 31 | |
- * | | do | 1st, 2nd, ..., 31st | 7 |
- * | | dd | 01, 02, ..., 31 | |
- * | Day of year | D | 1, 2, ..., 365, 366 | 9 |
- * | | Do | 1st, 2nd, ..., 365th, 366th | 7 |
- * | | DD | 01, 02, ..., 365, 366 | 9 |
- * | | DDD | 001, 002, ..., 365, 366 | |
- * | | DDDD | ... | 3 |
- * | Day of week (formatting) | E..EEE | Mon, Tue, Wed, ..., Sun | |
- * | | EEEE | Monday, Tuesday, ..., Sunday | 2 |
- * | | EEEEE | M, T, W, T, F, S, S | |
- * | | EEEEEE | Mo, Tu, We, Th, Fr, Su, Sa | |
- * | ISO day of week (formatting) | i | 1, 2, 3, ..., 7 | 7 |
- * | | io | 1st, 2nd, ..., 7th | 7 |
- * | | ii | 01, 02, ..., 07 | 7 |
- * | | iii | Mon, Tue, Wed, ..., Sun | 7 |
- * | | iiii | Monday, Tuesday, ..., Sunday | 2,7 |
- * | | iiiii | M, T, W, T, F, S, S | 7 |
- * | | iiiiii | Mo, Tu, We, Th, Fr, Su, Sa | 7 |
- * | Local day of week (formatting) | e | 2, 3, 4, ..., 1 | |
- * | | eo | 2nd, 3rd, ..., 1st | 7 |
- * | | ee | 02, 03, ..., 01 | |
- * | | eee | Mon, Tue, Wed, ..., Sun | |
- * | | eeee | Monday, Tuesday, ..., Sunday | 2 |
- * | | eeeee | M, T, W, T, F, S, S | |
- * | | eeeeee | Mo, Tu, We, Th, Fr, Su, Sa | |
- * | Local day of week (stand-alone) | c | 2, 3, 4, ..., 1 | |
- * | | co | 2nd, 3rd, ..., 1st | 7 |
- * | | cc | 02, 03, ..., 01 | |
- * | | ccc | Mon, Tue, Wed, ..., Sun | |
- * | | cccc | Monday, Tuesday, ..., Sunday | 2 |
- * | | ccccc | M, T, W, T, F, S, S | |
- * | | cccccc | Mo, Tu, We, Th, Fr, Su, Sa | |
- * | AM, PM | a..aa | AM, PM | |
- * | | aaa | am, pm | |
- * | | aaaa | a.m., p.m. | 2 |
- * | | aaaaa | a, p | |
- * | AM, PM, noon, midnight | b..bb | AM, PM, noon, midnight | |
- * | | bbb | am, pm, noon, midnight | |
- * | | bbbb | a.m., p.m., noon, midnight | 2 |
- * | | bbbbb | a, p, n, mi | |
- * | Flexible day period | B..BBB | at night, in the morning, ... | |
- * | | BBBB | at night, in the morning, ... | 2 |
- * | | BBBBB | at night, in the morning, ... | |
- * | Hour [1-12] | h | 1, 2, ..., 11, 12 | |
- * | | ho | 1st, 2nd, ..., 11th, 12th | 7 |
- * | | hh | 01, 02, ..., 11, 12 | |
- * | Hour [0-23] | H | 0, 1, 2, ..., 23 | |
- * | | Ho | 0th, 1st, 2nd, ..., 23rd | 7 |
- * | | HH | 00, 01, 02, ..., 23 | |
- * | Hour [0-11] | K | 1, 2, ..., 11, 0 | |
- * | | Ko | 1st, 2nd, ..., 11th, 0th | 7 |
- * | | KK | 01, 02, ..., 11, 00 | |
- * | Hour [1-24] | k | 24, 1, 2, ..., 23 | |
- * | | ko | 24th, 1st, 2nd, ..., 23rd | 7 |
- * | | kk | 24, 01, 02, ..., 23 | |
- * | Minute | m | 0, 1, ..., 59 | |
- * | | mo | 0th, 1st, ..., 59th | 7 |
- * | | mm | 00, 01, ..., 59 | |
- * | Second | s | 0, 1, ..., 59 | |
- * | | so | 0th, 1st, ..., 59th | 7 |
- * | | ss | 00, 01, ..., 59 | |
- * | Fraction of second | S | 0, 1, ..., 9 | |
- * | | SS | 00, 01, ..., 99 | |
- * | | SSS | 000, 001, ..., 999 | |
- * | | SSSS | ... | 3 |
- * | Timezone (ISO-8601 w/ Z) | X | -08, +0530, Z | |
- * | | XX | -0800, +0530, Z | |
- * | | XXX | -08:00, +05:30, Z | |
- * | | XXXX | -0800, +0530, Z, +123456 | 2 |
- * | | XXXXX | -08:00, +05:30, Z, +12:34:56 | |
- * | Timezone (ISO-8601 w/o Z) | x | -08, +0530, +00 | |
- * | | xx | -0800, +0530, +0000 | |
- * | | xxx | -08:00, +05:30, +00:00 | 2 |
- * | | xxxx | -0800, +0530, +0000, +123456 | |
- * | | xxxxx | -08:00, +05:30, +00:00, +12:34:56 | |
- * | Timezone (GMT) | O...OOO | GMT-8, GMT+5:30, GMT+0 | |
- * | | OOOO | GMT-08:00, GMT+05:30, GMT+00:00 | 2 |
- * | Timezone (specific non-locat.) | z...zzz | GMT-8, GMT+5:30, GMT+0 | 6 |
- * | | zzzz | GMT-08:00, GMT+05:30, GMT+00:00 | 2,6 |
- * | Seconds timestamp | t | 512969520 | 7 |
- * | | tt | ... | 3,7 |
- * | Milliseconds timestamp | T | 512969520900 | 7 |
- * | | TT | ... | 3,7 |
- * | Long localized date | P | 04/29/1453 | 7 |
- * | | PP | Apr 29, 1453 | 7 |
- * | | PPP | April 29th, 1453 | 7 |
- * | | PPPP | Friday, April 29th, 1453 | 2,7 |
- * | Long localized time | p | 12:00 AM | 7 |
- * | | pp | 12:00:00 AM | 7 |
- * | | ppp | 12:00:00 AM GMT+2 | 7 |
- * | | pppp | 12:00:00 AM GMT+02:00 | 2,7 |
- * | Combination of date and time | Pp | 04/29/1453, 12:00 AM | 7 |
- * | | PPpp | Apr 29, 1453, 12:00:00 AM | 7 |
- * | | PPPppp | April 29th, 1453 at ... | 7 |
- * | | PPPPpppp| Friday, April 29th, 1453 at ... | 2,7 |
- * Notes:
- * 1. "Formatting" units (e.g. formatting quarter) in the default en-US locale
- * are the same as "stand-alone" units, but are different in some languages.
- * "Formatting" units are declined according to the rules of the language
- * in the context of a date. "Stand-alone" units are always nominative singular:
- *
- * `format(new Date(2017, 10, 6), 'do LLLL', {locale: cs}) //=> '6. listopad'`
- *
- * `format(new Date(2017, 10, 6), 'do MMMM', {locale: cs}) //=> '6. listopadu'`
- *
- * 2. Any sequence of the identical letters is a pattern, unless it is escaped by
- * the single quote characters (see below).
- * If the sequence is longer than listed in table (e.g. `EEEEEEEEEEE`)
- * the output will be the same as default pattern for this unit, usually
- * the longest one (in case of ISO weekdays, `EEEE`). Default patterns for units
- * are marked with "2" in the last column of the table.
- *
- * `format(new Date(2017, 10, 6), 'MMM') //=> 'Nov'`
- *
- * `format(new Date(2017, 10, 6), 'MMMM') //=> 'November'`
- *
- * `format(new Date(2017, 10, 6), 'MMMMM') //=> 'N'`
- *
- * `format(new Date(2017, 10, 6), 'MMMMMM') //=> 'November'`
- *
- * `format(new Date(2017, 10, 6), 'MMMMMMM') //=> 'November'`
- *
- * 3. Some patterns could be unlimited length (such as `yyyyyyyy`).
- * The output will be padded with zeros to match the length of the pattern.
- *
- * `format(new Date(2017, 10, 6), 'yyyyyyyy') //=> '00002017'`
- *
- * 4. `QQQQQ` and `qqqqq` could be not strictly numerical in some locales.
- * These tokens represent the shortest form of the quarter.
- *
- * 5. The main difference between `y` and `u` patterns are B.C. years:
- *
- * | Year | `y` | `u` |
- * |------|-----|-----|
- * | AC 1 | 1 | 1 |
- * | BC 1 | 1 | 0 |
- * | BC 2 | 2 | -1 |
- *
- * Also `yy` always returns the last two digits of a year,
- * while `uu` pads single digit years to 2 characters and returns other years unchanged:
- *
- * | Year | `yy` | `uu` |
- * |------|------|------|
- * | 1 | 01 | 01 |
- * | 14 | 14 | 14 |
- * | 376 | 76 | 376 |
- * | 1453 | 53 | 1453 |
- *
- * The same difference is true for local and ISO week-numbering years (`Y` and `R`),
- * except local week-numbering years are dependent on `options.weekStartsOn`
- * and `options.firstWeekContainsDate` (compare [getISOWeekYear]{@link https://date-fns.org/docs/getISOWeekYear}
- * and [getWeekYear]{@link https://date-fns.org/docs/getWeekYear}).
- *
- * 6. Specific non-location timezones are currently unavailable in `date-fns`,
- * so right now these tokens fall back to GMT timezones.
- *
- * 7. These patterns are not in the Unicode Technical Standard #35:
- * - `i`: ISO day of week
- * - `I`: ISO week of year
- * - `R`: ISO week-numbering year
- * - `t`: seconds timestamp
- * - `T`: milliseconds timestamp
- * - `o`: ordinal number modifier
- * - `P`: long localized date
- * - `p`: long localized time
- *
- * 8. `YY` and `YYYY` tokens represent week-numbering years but they are often confused with years.
- * You should enable `options.useAdditionalWeekYearTokens` to use them. See: https://git.io/fxCyr
- *
- * 9. `D` and `DD` tokens represent days of the year but they are ofthen confused with days of the month.
- * You should enable `options.useAdditionalDayOfYearTokens` to use them. See: https://git.io/fxCyr
- *
- * ### v2.0.0 breaking changes:
- *
- * - [Changes that are common for the whole library](https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#Common-Changes).
- *
- * - The second argument is now required for the sake of explicitness.
- *
- * ```javascript
- * // Before v2.0.0
- * format(new Date(2016, 0, 1))
- *
- * // v2.0.0 onward
- * format(new Date(2016, 0, 1), "yyyy-MM-dd'T'HH:mm:ss.SSSxxx")
- * ```
- *
- * - New format string API for `format` function
- * which is based on [Unicode Technical Standard #35](https://www.unicode.org/reports/tr35/tr35-dates.html#Date_Field_Symbol_Table).
- * See [this post](https://blog.date-fns.org/post/unicode-tokens-in-date-fns-v2-sreatyki91jg) for more details.
- *
- * - Characters are now escaped using single quote symbols (`'`) instead of square brackets.
- *
- * @param {Date|Number} date - the original date
- * @param {String} format - the string of tokens
- * @param {Object} [options] - an object with options.
- * @param {Locale} [options.locale=defaultLocale] - the locale object. See [Locale]{@link https://date-fns.org/docs/Locale}
- * @param {0|1|2|3|4|5|6} [options.weekStartsOn=0] - the index of the first day of the week (0 - Sunday)
- * @param {Number} [options.firstWeekContainsDate=1] - the day of January, which is
- * @param {Boolean} [options.useAdditionalWeekYearTokens=false] - if true, allows usage of the week-numbering year tokens `YY` and `YYYY`;
- * see: https://git.io/fxCyr
- * @param {Boolean} [options.useAdditionalDayOfYearTokens=false] - if true, allows usage of the day of year tokens `D` and `DD`;
- * see: https://git.io/fxCyr
- * @returns {String} the formatted date string
- * @throws {TypeError} 2 arguments required
- * @throws {RangeError} `date` must not be Invalid Date
- * @throws {RangeError} `options.locale` must contain `localize` property
- * @throws {RangeError} `options.locale` must contain `formatLong` property
- * @throws {RangeError} `options.weekStartsOn` must be between 0 and 6
- * @throws {RangeError} `options.firstWeekContainsDate` must be between 1 and 7
- * @throws {RangeError} use `yyyy` instead of `YYYY` for formatting years using [format provided] to the input [input provided]; see: https://git.io/fxCyr
- * @throws {RangeError} use `yy` instead of `YY` for formatting years using [format provided] to the input [input provided]; see: https://git.io/fxCyr
- * @throws {RangeError} use `d` instead of `D` for formatting days of the month using [format provided] to the input [input provided]; see: https://git.io/fxCyr
- * @throws {RangeError} use `dd` instead of `DD` for formatting days of the month using [format provided] to the input [input provided]; see: https://git.io/fxCyr
- * @throws {RangeError} format string contains an unescaped latin alphabet character
- *
- * @example
- * // Represent 11 February 2014 in middle-endian format:
- * var result = format(new Date(2014, 1, 11), 'MM/dd/yyyy')
- * //=> '02/11/2014'
- *
- * @example
- * // Represent 2 July 2014 in Esperanto:
- * import { eoLocale } from 'date-fns/locale/eo'
- * var result = format(new Date(2014, 6, 2), "do 'de' MMMM yyyy", {
- * locale: eoLocale
- * })
- * //=> '2-a de julio 2014'
- *
- * @example
- * // Escape string by single quote characters:
- * var result = format(new Date(2014, 6, 2, 15), "h 'o''clock'")
- * //=> "3 o'clock"
- */
+ return addLeadingZeros(hours, token.length);
+ },
+ // Hour [1-24]
+ k: function (date, token, localize) {
+ var hours = date.getUTCHours();
+ if (hours === 0) hours = 24;
- function format(dirtyDate, dirtyFormatStr, dirtyOptions) {
- requiredArgs(2, arguments);
- var formatStr = String(dirtyFormatStr);
- var options = dirtyOptions || {};
- var locale = options.locale || defaultLocale;
- var localeFirstWeekContainsDate = locale.options && locale.options.firstWeekContainsDate;
- var defaultFirstWeekContainsDate = localeFirstWeekContainsDate == null ? 1 : toInteger(localeFirstWeekContainsDate);
- var firstWeekContainsDate = options.firstWeekContainsDate == null ? defaultFirstWeekContainsDate : toInteger(options.firstWeekContainsDate); // Test if weekStartsOn is between 1 and 7 _and_ is not NaN
+ if (token === 'ko') {
+ return localize.ordinalNumber(hours, {
+ unit: 'hour'
+ });
+ }
- if (!(firstWeekContainsDate >= 1 && firstWeekContainsDate <= 7)) {
- throw new RangeError('firstWeekContainsDate must be between 1 and 7 inclusively');
+ return addLeadingZeros(hours, token.length);
+ },
+ // Minute
+ m: function (date, token, localize) {
+ if (token === 'mo') {
+ return localize.ordinalNumber(date.getUTCMinutes(), {
+ unit: 'minute'
+ });
}
- var localeWeekStartsOn = locale.options && locale.options.weekStartsOn;
- var defaultWeekStartsOn = localeWeekStartsOn == null ? 0 : toInteger(localeWeekStartsOn);
- var weekStartsOn = options.weekStartsOn == null ? defaultWeekStartsOn : toInteger(options.weekStartsOn); // Test if weekStartsOn is between 0 and 6 _and_ is not NaN
+ return formatters$3.m(date, token);
+ },
+ // Second
+ s: function (date, token, localize) {
+ if (token === 'so') {
+ return localize.ordinalNumber(date.getUTCSeconds(), {
+ unit: 'second'
+ });
+ }
- if (!(weekStartsOn >= 0 && weekStartsOn <= 6)) {
- throw new RangeError('weekStartsOn must be between 0 and 6 inclusively');
+ return formatters$3.s(date, token);
+ },
+ // Fraction of second
+ S: function (date, token) {
+ return formatters$3.S(date, token);
+ },
+ // Timezone (ISO-8601. If offset is 0, output is always `'Z'`)
+ X: function (date, token, _localize, options) {
+ var originalDate = options._originalDate || date;
+ var timezoneOffset = originalDate.getTimezoneOffset();
+
+ if (timezoneOffset === 0) {
+ return 'Z';
}
- if (!locale.localize) {
- throw new RangeError('locale must contain localize property');
+ switch (token) {
+ // Hours and optional minutes
+ case 'X':
+ return formatTimezoneWithOptionalMinutes(timezoneOffset);
+ // Hours, minutes and optional seconds without `:` delimiter
+ // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
+ // so this token always has the same output as `XX`
+
+ case 'XXXX':
+ case 'XX':
+ // Hours and minutes without `:` delimiter
+ return formatTimezone(timezoneOffset);
+ // Hours, minutes and optional seconds with `:` delimiter
+ // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
+ // so this token always has the same output as `XXX`
+
+ case 'XXXXX':
+ case 'XXX': // Hours and minutes with `:` delimiter
+
+ default:
+ return formatTimezone(timezoneOffset, ':');
}
+ },
+ // Timezone (ISO-8601. If offset is 0, output is `'+00:00'` or equivalent)
+ x: function (date, token, _localize, options) {
+ var originalDate = options._originalDate || date;
+ var timezoneOffset = originalDate.getTimezoneOffset();
+
+ switch (token) {
+ // Hours and optional minutes
+ case 'x':
+ return formatTimezoneWithOptionalMinutes(timezoneOffset);
+ // Hours, minutes and optional seconds without `:` delimiter
+ // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
+ // so this token always has the same output as `xx`
+
+ case 'xxxx':
+ case 'xx':
+ // Hours and minutes without `:` delimiter
+ return formatTimezone(timezoneOffset);
+ // Hours, minutes and optional seconds with `:` delimiter
+ // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
+ // so this token always has the same output as `xxx`
+
+ case 'xxxxx':
+ case 'xxx': // Hours and minutes with `:` delimiter
- if (!locale.formatLong) {
- throw new RangeError('locale must contain formatLong property');
+ default:
+ return formatTimezone(timezoneOffset, ':');
}
+ },
+ // Timezone (GMT)
+ O: function (date, token, _localize, options) {
+ var originalDate = options._originalDate || date;
+ var timezoneOffset = originalDate.getTimezoneOffset();
+
+ switch (token) {
+ // Short
+ case 'O':
+ case 'OO':
+ case 'OOO':
+ return 'GMT' + formatTimezoneShort(timezoneOffset, ':');
+ // Long
+
+ case 'OOOO':
+ default:
+ return 'GMT' + formatTimezone(timezoneOffset, ':');
+ }
+ },
+ // Timezone (specific non-location)
+ z: function (date, token, _localize, options) {
+ var originalDate = options._originalDate || date;
+ var timezoneOffset = originalDate.getTimezoneOffset();
+
+ switch (token) {
+ // Short
+ case 'z':
+ case 'zz':
+ case 'zzz':
+ return 'GMT' + formatTimezoneShort(timezoneOffset, ':');
+ // Long
+
+ case 'zzzz':
+ default:
+ return 'GMT' + formatTimezone(timezoneOffset, ':');
+ }
+ },
+ // Seconds timestamp
+ t: function (date, token, _localize, options) {
+ var originalDate = options._originalDate || date;
+ var timestamp = Math.floor(originalDate.getTime() / 1000);
+ return addLeadingZeros(timestamp, token.length);
+ },
+ // Milliseconds timestamp
+ T: function (date, token, _localize, options) {
+ var originalDate = options._originalDate || date;
+ var timestamp = originalDate.getTime();
+ return addLeadingZeros(timestamp, token.length);
+ }
+ };
- var originalDate = toDate(dirtyDate);
+ function formatTimezoneShort(offset, dirtyDelimiter) {
+ var sign = offset > 0 ? '-' : '+';
+ var absOffset = Math.abs(offset);
+ var hours = Math.floor(absOffset / 60);
+ var minutes = absOffset % 60;
- if (!isValid(originalDate)) {
- throw new RangeError('Invalid time value');
- } // Convert the date in system timezone to the same date in UTC+00:00 timezone.
- // This ensures that when UTC functions will be implemented, locales will be compatible with them.
- // See an issue about UTC functions: https://github.com/date-fns/date-fns/issues/376
+ if (minutes === 0) {
+ return sign + String(hours);
+ }
+ var delimiter = dirtyDelimiter || '';
+ return sign + String(hours) + delimiter + addLeadingZeros(minutes, 2);
+ }
- var timezoneOffset = getTimezoneOffsetInMilliseconds(originalDate);
- var utcDate = subMilliseconds(originalDate, timezoneOffset);
- var formatterOptions = {
- firstWeekContainsDate: firstWeekContainsDate,
- weekStartsOn: weekStartsOn,
- locale: locale,
- _originalDate: originalDate
- };
- var result = formatStr.match(longFormattingTokensRegExp).map(function (substring) {
- var firstCharacter = substring[0];
+ function formatTimezoneWithOptionalMinutes(offset, dirtyDelimiter) {
+ if (offset % 60 === 0) {
+ var sign = offset > 0 ? '-' : '+';
+ return sign + addLeadingZeros(Math.abs(offset) / 60, 2);
+ }
- if (firstCharacter === 'p' || firstCharacter === 'P') {
- var longFormatter = longFormatters$1[firstCharacter];
- return longFormatter(substring, locale.formatLong, formatterOptions);
- }
+ return formatTimezone(offset, dirtyDelimiter);
+ }
- return substring;
- }).join('').match(formattingTokensRegExp).map(function (substring) {
- // Replace two single quote characters with one single quote character
- if (substring === "''") {
- return "'";
- }
+ function formatTimezone(offset, dirtyDelimiter) {
+ var delimiter = dirtyDelimiter || '';
+ var sign = offset > 0 ? '-' : '+';
+ var absOffset = Math.abs(offset);
+ var hours = addLeadingZeros(Math.floor(absOffset / 60), 2);
+ var minutes = addLeadingZeros(absOffset % 60, 2);
+ return sign + hours + delimiter + minutes;
+ }
- var firstCharacter = substring[0];
+ var formatters$1 = formatters;
- if (firstCharacter === "'") {
- return cleanEscapedString(substring);
- }
+ function dateLongFormatter(pattern, formatLong) {
+ switch (pattern) {
+ case 'P':
+ return formatLong.date({
+ width: 'short'
+ });
+
+ case 'PP':
+ return formatLong.date({
+ width: 'medium'
+ });
- var formatter = formatters$1[firstCharacter];
+ case 'PPP':
+ return formatLong.date({
+ width: 'long'
+ });
- if (formatter) {
- if (!options.useAdditionalWeekYearTokens && isProtectedWeekYearToken(substring)) {
- throwProtectedError(substring, dirtyFormatStr, dirtyDate);
- }
+ case 'PPPP':
+ default:
+ return formatLong.date({
+ width: 'full'
+ });
+ }
+ }
- if (!options.useAdditionalDayOfYearTokens && isProtectedDayOfYearToken(substring)) {
- throwProtectedError(substring, dirtyFormatStr, dirtyDate);
- }
+ function timeLongFormatter(pattern, formatLong) {
+ switch (pattern) {
+ case 'p':
+ return formatLong.time({
+ width: 'short'
+ });
- return formatter(utcDate, substring, locale.localize, formatterOptions);
- }
+ case 'pp':
+ return formatLong.time({
+ width: 'medium'
+ });
- if (firstCharacter.match(unescapedLatinCharacterRegExp)) {
- throw new RangeError('Format string contains an unescaped latin alphabet character `' + firstCharacter + '`');
- }
+ case 'ppp':
+ return formatLong.time({
+ width: 'long'
+ });
- return substring;
- }).join('');
- return result;
+ case 'pppp':
+ default:
+ return formatLong.time({
+ width: 'full'
+ });
}
+ }
+
+ function dateTimeLongFormatter(pattern, formatLong) {
+ var matchResult = pattern.match(/(P+)(p+)?/);
+ var datePattern = matchResult[1];
+ var timePattern = matchResult[2];
- function cleanEscapedString(input) {
- return input.match(escapedStringRegExp)[1].replace(doubleQuoteRegExp, "'");
+ if (!timePattern) {
+ return dateLongFormatter(pattern, formatLong);
}
- /*
- This file is part of GNU Taler
- (C) 2021 Taler Systems S.A.
+ var dateTimeFormat;
- GNU Taler is free software; you can redistribute it and/or modify it under the
- terms of the GNU General Public License as published by the Free Software
- Foundation; either version 3, or (at your option) any later version.
+ switch (datePattern) {
+ case 'P':
+ dateTimeFormat = formatLong.dateTime({
+ width: 'short'
+ });
+ break;
- GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY
- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+ case 'PP':
+ dateTimeFormat = formatLong.dateTime({
+ width: 'medium'
+ });
+ break;
- You should have received a copy of the GNU General Public License along with
- GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
- */
- function ShowOrderDetails({ order_summary, refund_amount, contract_terms }) {
- var _a;
- const pay_deadline = (contract_terms === null || contract_terms === void 0 ? void 0 : contract_terms.pay_deadline.t_ms) === 'never' || (contract_terms === null || contract_terms === void 0 ? void 0 : contract_terms.pay_deadline.t_ms) === undefined ? undefined :
- format(new Date(contract_terms === null || contract_terms === void 0 ? void 0 : contract_terms.pay_deadline.t_ms), 'dd/MM/yyyy HH:mm:ss');
- return a$2(y$1, null,
- a$2("h1", null, "Order details"),
- a$2("div", null,
- "This is the default status page for your order for ",
- a$2("b", null, order_summary ? order_summary : `{{ order_summary }}`),
- "."),
- a$2("h2", null, "Refund status"),
- a$2("div", null,
- "The merchant has granted you refunds on the purchase of ",
- a$2("b", null, refund_amount ? refund_amount : `{{ refund_amount }}`),
- "."),
- a$2("h2", null, "Full contract details"),
- a$2("pre", null,
- a$2("table", null,
- a$2("tr", null,
- a$2("td", null, "amount"),
- a$2("td", null, (contract_terms === null || contract_terms === void 0 ? void 0 : contract_terms.amount) || `{{ contract_terms.amount }}`)),
- a$2("tr", null,
- a$2("td", null, "summary"),
- a$2("td", null, (contract_terms === null || contract_terms === void 0 ? void 0 : contract_terms.summary) || `{{ contract_terms.summary }}`)),
- a$2("tr", null,
- a$2("td", null, "pay deadline"),
- a$2("td", null, pay_deadline || `{{ contract_terms.pay_deadline.t_ms }}`)),
- a$2("tr", null,
- a$2("td", null, "merchant name"),
- a$2("td", null, ((_a = contract_terms === null || contract_terms === void 0 ? void 0 : contract_terms.merchant) === null || _a === void 0 ? void 0 : _a.name) || `{{ contract_terms.merchant.name }}`))),
- a$2("div", null, `{{{contract_terms!stringify }}}`)));
+ case 'PPP':
+ dateTimeFormat = formatLong.dateTime({
+ width: 'long'
+ });
+ break;
+
+ case 'PPPP':
+ default:
+ dateTimeFormat = formatLong.dateTime({
+ width: 'full'
+ });
+ break;
}
- /*
- This file is part of GNU Taler
- (C) 2021 Taler Systems S.A.
+ return dateTimeFormat.replace('{{date}}', dateLongFormatter(datePattern, formatLong)).replace('{{time}}', timeLongFormatter(timePattern, formatLong));
+ }
- GNU Taler is free software; you can redistribute it and/or modify it under the
- terms of the GNU General Public License as published by the Free Software
- Foundation; either version 3, or (at your option) any later version.
+ var longFormatters = {
+ p: timeLongFormatter,
+ P: dateTimeLongFormatter
+ };
+ var longFormatters$1 = longFormatters;
- GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY
- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+ var protectedDayOfYearTokens = ['D', 'DD'];
+ var protectedWeekYearTokens = ['YY', 'YYYY'];
+ function isProtectedDayOfYearToken(token) {
+ return protectedDayOfYearTokens.indexOf(token) !== -1;
+ }
+ function isProtectedWeekYearToken(token) {
+ return protectedWeekYearTokens.indexOf(token) !== -1;
+ }
+ function throwProtectedError(token, format, input) {
+ if (token === 'YYYY') {
+ throw new RangeError("Use `yyyy` instead of `YYYY` (in `".concat(format, "`) for formatting years to the input `").concat(input, "`; see: https://git.io/fxCyr"));
+ } else if (token === 'YY') {
+ throw new RangeError("Use `yy` instead of `YY` (in `".concat(format, "`) for formatting years to the input `").concat(input, "`; see: https://git.io/fxCyr"));
+ } else if (token === 'D') {
+ throw new RangeError("Use `d` instead of `D` (in `".concat(format, "`) for formatting days of the month to the input `").concat(input, "`; see: https://git.io/fxCyr"));
+ } else if (token === 'DD') {
+ throw new RangeError("Use `dd` instead of `DD` (in `".concat(format, "`) for formatting days of the month to the input `").concat(input, "`; see: https://git.io/fxCyr"));
+ }
+ }
- You should have received a copy of the GNU General Public License along with
- GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
- */
- function Head() {
- return a$2(y$1, null,
- a$2("meta", { charSet: "UTF-8" }),
- a$2("meta", { name: "viewport", content: "width=device-width, initial-scale=1.0" }),
- a$2("noscript", null,
- a$2("meta", { "http-equiv": "refresh", content: "1" })),
- a$2("title", null, "Tip available"));
+ // - [yYQqMLwIdDecihHKkms]o matches any available ordinal number token
+ // (one of the certain letters followed by `o`)
+ // - (\w)\1* matches any sequences of the same letter
+ // - '' matches two quote characters in a row
+ // - '(''|[^'])+('|$) matches anything surrounded by two quote characters ('),
+ // except a single quote symbol, which ends the sequence.
+ // Two quote characters do not end the sequence.
+ // If there is no matching single quote
+ // then the sequence will continue until the end of the string.
+ // - . matches any single character unmatched by previous parts of the RegExps
+
+ var formattingTokensRegExp = /[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g; // This RegExp catches symbols escaped by quotes, and also
+ // sequences of symbols P, p, and the combinations like `PPPPPPPppppp`
+
+ var longFormattingTokensRegExp = /P+p+|P+|p+|''|'(''|[^'])+('|$)|./g;
+ var escapedStringRegExp = /^'([^]*?)'?$/;
+ var doubleQuoteRegExp = /''/g;
+ var unescapedLatinCharacterRegExp = /[a-zA-Z]/;
+ /**
+ * @name format
+ * @category Common Helpers
+ * @summary Format the date.
+ *
+ * @description
+ * Return the formatted date string in the given format. The result may vary by locale.
+ *
+ * > ⚠️ Please note that the `format` tokens differ from Moment.js and other libraries.
+ * > See: https://git.io/fxCyr
+ *
+ * The characters wrapped between two single quotes characters (') are escaped.
+ * Two single quotes in a row, whether inside or outside a quoted sequence, represent a 'real' single quote.
+ * (see the last example)
+ *
+ * Format of the string is based on Unicode Technical Standard #35:
+ * https://www.unicode.org/reports/tr35/tr35-dates.html#Date_Field_Symbol_Table
+ * with a few additions (see note 7 below the table).
+ *
+ * Accepted patterns:
+ * | Unit | Pattern | Result examples | Notes |
+ * |---------------------------------|---------|-----------------------------------|-------|
+ * | Era | G..GGG | AD, BC | |
+ * | | GGGG | Anno Domini, Before Christ | 2 |
+ * | | GGGGG | A, B | |
+ * | Calendar year | y | 44, 1, 1900, 2017 | 5 |
+ * | | yo | 44th, 1st, 0th, 17th | 5,7 |
+ * | | yy | 44, 01, 00, 17 | 5 |
+ * | | yyy | 044, 001, 1900, 2017 | 5 |
+ * | | yyyy | 0044, 0001, 1900, 2017 | 5 |
+ * | | yyyyy | ... | 3,5 |
+ * | Local week-numbering year | Y | 44, 1, 1900, 2017 | 5 |
+ * | | Yo | 44th, 1st, 1900th, 2017th | 5,7 |
+ * | | YY | 44, 01, 00, 17 | 5,8 |
+ * | | YYY | 044, 001, 1900, 2017 | 5 |
+ * | | YYYY | 0044, 0001, 1900, 2017 | 5,8 |
+ * | | YYYYY | ... | 3,5 |
+ * | ISO week-numbering year | R | -43, 0, 1, 1900, 2017 | 5,7 |
+ * | | RR | -43, 00, 01, 1900, 2017 | 5,7 |
+ * | | RRR | -043, 000, 001, 1900, 2017 | 5,7 |
+ * | | RRRR | -0043, 0000, 0001, 1900, 2017 | 5,7 |
+ * | | RRRRR | ... | 3,5,7 |
+ * | Extended year | u | -43, 0, 1, 1900, 2017 | 5 |
+ * | | uu | -43, 01, 1900, 2017 | 5 |
+ * | | uuu | -043, 001, 1900, 2017 | 5 |
+ * | | uuuu | -0043, 0001, 1900, 2017 | 5 |
+ * | | uuuuu | ... | 3,5 |
+ * | Quarter (formatting) | Q | 1, 2, 3, 4 | |
+ * | | Qo | 1st, 2nd, 3rd, 4th | 7 |
+ * | | QQ | 01, 02, 03, 04 | |
+ * | | QQQ | Q1, Q2, Q3, Q4 | |
+ * | | QQQQ | 1st quarter, 2nd quarter, ... | 2 |
+ * | | QQQQQ | 1, 2, 3, 4 | 4 |
+ * | Quarter (stand-alone) | q | 1, 2, 3, 4 | |
+ * | | qo | 1st, 2nd, 3rd, 4th | 7 |
+ * | | qq | 01, 02, 03, 04 | |
+ * | | qqq | Q1, Q2, Q3, Q4 | |
+ * | | qqqq | 1st quarter, 2nd quarter, ... | 2 |
+ * | | qqqqq | 1, 2, 3, 4 | 4 |
+ * | Month (formatting) | M | 1, 2, ..., 12 | |
+ * | | Mo | 1st, 2nd, ..., 12th | 7 |
+ * | | MM | 01, 02, ..., 12 | |
+ * | | MMM | Jan, Feb, ..., Dec | |
+ * | | MMMM | January, February, ..., December | 2 |
+ * | | MMMMM | J, F, ..., D | |
+ * | Month (stand-alone) | L | 1, 2, ..., 12 | |
+ * | | Lo | 1st, 2nd, ..., 12th | 7 |
+ * | | LL | 01, 02, ..., 12 | |
+ * | | LLL | Jan, Feb, ..., Dec | |
+ * | | LLLL | January, February, ..., December | 2 |
+ * | | LLLLL | J, F, ..., D | |
+ * | Local week of year | w | 1, 2, ..., 53 | |
+ * | | wo | 1st, 2nd, ..., 53th | 7 |
+ * | | ww | 01, 02, ..., 53 | |
+ * | ISO week of year | I | 1, 2, ..., 53 | 7 |
+ * | | Io | 1st, 2nd, ..., 53th | 7 |
+ * | | II | 01, 02, ..., 53 | 7 |
+ * | Day of month | d | 1, 2, ..., 31 | |
+ * | | do | 1st, 2nd, ..., 31st | 7 |
+ * | | dd | 01, 02, ..., 31 | |
+ * | Day of year | D | 1, 2, ..., 365, 366 | 9 |
+ * | | Do | 1st, 2nd, ..., 365th, 366th | 7 |
+ * | | DD | 01, 02, ..., 365, 366 | 9 |
+ * | | DDD | 001, 002, ..., 365, 366 | |
+ * | | DDDD | ... | 3 |
+ * | Day of week (formatting) | E..EEE | Mon, Tue, Wed, ..., Sun | |
+ * | | EEEE | Monday, Tuesday, ..., Sunday | 2 |
+ * | | EEEEE | M, T, W, T, F, S, S | |
+ * | | EEEEEE | Mo, Tu, We, Th, Fr, Su, Sa | |
+ * | ISO day of week (formatting) | i | 1, 2, 3, ..., 7 | 7 |
+ * | | io | 1st, 2nd, ..., 7th | 7 |
+ * | | ii | 01, 02, ..., 07 | 7 |
+ * | | iii | Mon, Tue, Wed, ..., Sun | 7 |
+ * | | iiii | Monday, Tuesday, ..., Sunday | 2,7 |
+ * | | iiiii | M, T, W, T, F, S, S | 7 |
+ * | | iiiiii | Mo, Tu, We, Th, Fr, Su, Sa | 7 |
+ * | Local day of week (formatting) | e | 2, 3, 4, ..., 1 | |
+ * | | eo | 2nd, 3rd, ..., 1st | 7 |
+ * | | ee | 02, 03, ..., 01 | |
+ * | | eee | Mon, Tue, Wed, ..., Sun | |
+ * | | eeee | Monday, Tuesday, ..., Sunday | 2 |
+ * | | eeeee | M, T, W, T, F, S, S | |
+ * | | eeeeee | Mo, Tu, We, Th, Fr, Su, Sa | |
+ * | Local day of week (stand-alone) | c | 2, 3, 4, ..., 1 | |
+ * | | co | 2nd, 3rd, ..., 1st | 7 |
+ * | | cc | 02, 03, ..., 01 | |
+ * | | ccc | Mon, Tue, Wed, ..., Sun | |
+ * | | cccc | Monday, Tuesday, ..., Sunday | 2 |
+ * | | ccccc | M, T, W, T, F, S, S | |
+ * | | cccccc | Mo, Tu, We, Th, Fr, Su, Sa | |
+ * | AM, PM | a..aa | AM, PM | |
+ * | | aaa | am, pm | |
+ * | | aaaa | a.m., p.m. | 2 |
+ * | | aaaaa | a, p | |
+ * | AM, PM, noon, midnight | b..bb | AM, PM, noon, midnight | |
+ * | | bbb | am, pm, noon, midnight | |
+ * | | bbbb | a.m., p.m., noon, midnight | 2 |
+ * | | bbbbb | a, p, n, mi | |
+ * | Flexible day period | B..BBB | at night, in the morning, ... | |
+ * | | BBBB | at night, in the morning, ... | 2 |
+ * | | BBBBB | at night, in the morning, ... | |
+ * | Hour [1-12] | h | 1, 2, ..., 11, 12 | |
+ * | | ho | 1st, 2nd, ..., 11th, 12th | 7 |
+ * | | hh | 01, 02, ..., 11, 12 | |
+ * | Hour [0-23] | H | 0, 1, 2, ..., 23 | |
+ * | | Ho | 0th, 1st, 2nd, ..., 23rd | 7 |
+ * | | HH | 00, 01, 02, ..., 23 | |
+ * | Hour [0-11] | K | 1, 2, ..., 11, 0 | |
+ * | | Ko | 1st, 2nd, ..., 11th, 0th | 7 |
+ * | | KK | 01, 02, ..., 11, 00 | |
+ * | Hour [1-24] | k | 24, 1, 2, ..., 23 | |
+ * | | ko | 24th, 1st, 2nd, ..., 23rd | 7 |
+ * | | kk | 24, 01, 02, ..., 23 | |
+ * | Minute | m | 0, 1, ..., 59 | |
+ * | | mo | 0th, 1st, ..., 59th | 7 |
+ * | | mm | 00, 01, ..., 59 | |
+ * | Second | s | 0, 1, ..., 59 | |
+ * | | so | 0th, 1st, ..., 59th | 7 |
+ * | | ss | 00, 01, ..., 59 | |
+ * | Fraction of second | S | 0, 1, ..., 9 | |
+ * | | SS | 00, 01, ..., 99 | |
+ * | | SSS | 000, 001, ..., 999 | |
+ * | | SSSS | ... | 3 |
+ * | Timezone (ISO-8601 w/ Z) | X | -08, +0530, Z | |
+ * | | XX | -0800, +0530, Z | |
+ * | | XXX | -08:00, +05:30, Z | |
+ * | | XXXX | -0800, +0530, Z, +123456 | 2 |
+ * | | XXXXX | -08:00, +05:30, Z, +12:34:56 | |
+ * | Timezone (ISO-8601 w/o Z) | x | -08, +0530, +00 | |
+ * | | xx | -0800, +0530, +0000 | |
+ * | | xxx | -08:00, +05:30, +00:00 | 2 |
+ * | | xxxx | -0800, +0530, +0000, +123456 | |
+ * | | xxxxx | -08:00, +05:30, +00:00, +12:34:56 | |
+ * | Timezone (GMT) | O...OOO | GMT-8, GMT+5:30, GMT+0 | |
+ * | | OOOO | GMT-08:00, GMT+05:30, GMT+00:00 | 2 |
+ * | Timezone (specific non-locat.) | z...zzz | GMT-8, GMT+5:30, GMT+0 | 6 |
+ * | | zzzz | GMT-08:00, GMT+05:30, GMT+00:00 | 2,6 |
+ * | Seconds timestamp | t | 512969520 | 7 |
+ * | | tt | ... | 3,7 |
+ * | Milliseconds timestamp | T | 512969520900 | 7 |
+ * | | TT | ... | 3,7 |
+ * | Long localized date | P | 04/29/1453 | 7 |
+ * | | PP | Apr 29, 1453 | 7 |
+ * | | PPP | April 29th, 1453 | 7 |
+ * | | PPPP | Friday, April 29th, 1453 | 2,7 |
+ * | Long localized time | p | 12:00 AM | 7 |
+ * | | pp | 12:00:00 AM | 7 |
+ * | | ppp | 12:00:00 AM GMT+2 | 7 |
+ * | | pppp | 12:00:00 AM GMT+02:00 | 2,7 |
+ * | Combination of date and time | Pp | 04/29/1453, 12:00 AM | 7 |
+ * | | PPpp | Apr 29, 1453, 12:00:00 AM | 7 |
+ * | | PPPppp | April 29th, 1453 at ... | 7 |
+ * | | PPPPpppp| Friday, April 29th, 1453 at ... | 2,7 |
+ * Notes:
+ * 1. "Formatting" units (e.g. formatting quarter) in the default en-US locale
+ * are the same as "stand-alone" units, but are different in some languages.
+ * "Formatting" units are declined according to the rules of the language
+ * in the context of a date. "Stand-alone" units are always nominative singular:
+ *
+ * `format(new Date(2017, 10, 6), 'do LLLL', {locale: cs}) //=> '6. listopad'`
+ *
+ * `format(new Date(2017, 10, 6), 'do MMMM', {locale: cs}) //=> '6. listopadu'`
+ *
+ * 2. Any sequence of the identical letters is a pattern, unless it is escaped by
+ * the single quote characters (see below).
+ * If the sequence is longer than listed in table (e.g. `EEEEEEEEEEE`)
+ * the output will be the same as default pattern for this unit, usually
+ * the longest one (in case of ISO weekdays, `EEEE`). Default patterns for units
+ * are marked with "2" in the last column of the table.
+ *
+ * `format(new Date(2017, 10, 6), 'MMM') //=> 'Nov'`
+ *
+ * `format(new Date(2017, 10, 6), 'MMMM') //=> 'November'`
+ *
+ * `format(new Date(2017, 10, 6), 'MMMMM') //=> 'N'`
+ *
+ * `format(new Date(2017, 10, 6), 'MMMMMM') //=> 'November'`
+ *
+ * `format(new Date(2017, 10, 6), 'MMMMMMM') //=> 'November'`
+ *
+ * 3. Some patterns could be unlimited length (such as `yyyyyyyy`).
+ * The output will be padded with zeros to match the length of the pattern.
+ *
+ * `format(new Date(2017, 10, 6), 'yyyyyyyy') //=> '00002017'`
+ *
+ * 4. `QQQQQ` and `qqqqq` could be not strictly numerical in some locales.
+ * These tokens represent the shortest form of the quarter.
+ *
+ * 5. The main difference between `y` and `u` patterns are B.C. years:
+ *
+ * | Year | `y` | `u` |
+ * |------|-----|-----|
+ * | AC 1 | 1 | 1 |
+ * | BC 1 | 1 | 0 |
+ * | BC 2 | 2 | -1 |
+ *
+ * Also `yy` always returns the last two digits of a year,
+ * while `uu` pads single digit years to 2 characters and returns other years unchanged:
+ *
+ * | Year | `yy` | `uu` |
+ * |------|------|------|
+ * | 1 | 01 | 01 |
+ * | 14 | 14 | 14 |
+ * | 376 | 76 | 376 |
+ * | 1453 | 53 | 1453 |
+ *
+ * The same difference is true for local and ISO week-numbering years (`Y` and `R`),
+ * except local week-numbering years are dependent on `options.weekStartsOn`
+ * and `options.firstWeekContainsDate` (compare [getISOWeekYear]{@link https://date-fns.org/docs/getISOWeekYear}
+ * and [getWeekYear]{@link https://date-fns.org/docs/getWeekYear}).
+ *
+ * 6. Specific non-location timezones are currently unavailable in `date-fns`,
+ * so right now these tokens fall back to GMT timezones.
+ *
+ * 7. These patterns are not in the Unicode Technical Standard #35:
+ * - `i`: ISO day of week
+ * - `I`: ISO week of year
+ * - `R`: ISO week-numbering year
+ * - `t`: seconds timestamp
+ * - `T`: milliseconds timestamp
+ * - `o`: ordinal number modifier
+ * - `P`: long localized date
+ * - `p`: long localized time
+ *
+ * 8. `YY` and `YYYY` tokens represent week-numbering years but they are often confused with years.
+ * You should enable `options.useAdditionalWeekYearTokens` to use them. See: https://git.io/fxCyr
+ *
+ * 9. `D` and `DD` tokens represent days of the year but they are ofthen confused with days of the month.
+ * You should enable `options.useAdditionalDayOfYearTokens` to use them. See: https://git.io/fxCyr
+ *
+ * ### v2.0.0 breaking changes:
+ *
+ * - [Changes that are common for the whole library](https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#Common-Changes).
+ *
+ * - The second argument is now required for the sake of explicitness.
+ *
+ * ```javascript
+ * // Before v2.0.0
+ * format(new Date(2016, 0, 1))
+ *
+ * // v2.0.0 onward
+ * format(new Date(2016, 0, 1), "yyyy-MM-dd'T'HH:mm:ss.SSSxxx")
+ * ```
+ *
+ * - New format string API for `format` function
+ * which is based on [Unicode Technical Standard #35](https://www.unicode.org/reports/tr35/tr35-dates.html#Date_Field_Symbol_Table).
+ * See [this post](https://blog.date-fns.org/post/unicode-tokens-in-date-fns-v2-sreatyki91jg) for more details.
+ *
+ * - Characters are now escaped using single quote symbols (`'`) instead of square brackets.
+ *
+ * @param {Date|Number} date - the original date
+ * @param {String} format - the string of tokens
+ * @param {Object} [options] - an object with options.
+ * @param {Locale} [options.locale=defaultLocale] - the locale object. See [Locale]{@link https://date-fns.org/docs/Locale}
+ * @param {0|1|2|3|4|5|6} [options.weekStartsOn=0] - the index of the first day of the week (0 - Sunday)
+ * @param {Number} [options.firstWeekContainsDate=1] - the day of January, which is
+ * @param {Boolean} [options.useAdditionalWeekYearTokens=false] - if true, allows usage of the week-numbering year tokens `YY` and `YYYY`;
+ * see: https://git.io/fxCyr
+ * @param {Boolean} [options.useAdditionalDayOfYearTokens=false] - if true, allows usage of the day of year tokens `D` and `DD`;
+ * see: https://git.io/fxCyr
+ * @returns {String} the formatted date string
+ * @throws {TypeError} 2 arguments required
+ * @throws {RangeError} `date` must not be Invalid Date
+ * @throws {RangeError} `options.locale` must contain `localize` property
+ * @throws {RangeError} `options.locale` must contain `formatLong` property
+ * @throws {RangeError} `options.weekStartsOn` must be between 0 and 6
+ * @throws {RangeError} `options.firstWeekContainsDate` must be between 1 and 7
+ * @throws {RangeError} use `yyyy` instead of `YYYY` for formatting years using [format provided] to the input [input provided]; see: https://git.io/fxCyr
+ * @throws {RangeError} use `yy` instead of `YY` for formatting years using [format provided] to the input [input provided]; see: https://git.io/fxCyr
+ * @throws {RangeError} use `d` instead of `D` for formatting days of the month using [format provided] to the input [input provided]; see: https://git.io/fxCyr
+ * @throws {RangeError} use `dd` instead of `DD` for formatting days of the month using [format provided] to the input [input provided]; see: https://git.io/fxCyr
+ * @throws {RangeError} format string contains an unescaped latin alphabet character
+ *
+ * @example
+ * // Represent 11 February 2014 in middle-endian format:
+ * var result = format(new Date(2014, 1, 11), 'MM/dd/yyyy')
+ * //=> '02/11/2014'
+ *
+ * @example
+ * // Represent 2 July 2014 in Esperanto:
+ * import { eoLocale } from 'date-fns/locale/eo'
+ * var result = format(new Date(2014, 6, 2), "do 'de' MMMM yyyy", {
+ * locale: eoLocale
+ * })
+ * //=> '2-a de julio 2014'
+ *
+ * @example
+ * // Escape string by single quote characters:
+ * var result = format(new Date(2014, 6, 2, 15), "h 'o''clock'")
+ * //=> "3 o'clock"
+ */
+
+ function format(dirtyDate, dirtyFormatStr, dirtyOptions) {
+ requiredArgs(2, arguments);
+ var formatStr = String(dirtyFormatStr);
+ var options = dirtyOptions || {};
+ var locale = options.locale || defaultLocale;
+ var localeFirstWeekContainsDate = locale.options && locale.options.firstWeekContainsDate;
+ var defaultFirstWeekContainsDate = localeFirstWeekContainsDate == null ? 1 : toInteger(localeFirstWeekContainsDate);
+ var firstWeekContainsDate = options.firstWeekContainsDate == null ? defaultFirstWeekContainsDate : toInteger(options.firstWeekContainsDate); // Test if weekStartsOn is between 1 and 7 _and_ is not NaN
+
+ if (!(firstWeekContainsDate >= 1 && firstWeekContainsDate <= 7)) {
+ throw new RangeError('firstWeekContainsDate must be between 1 and 7 inclusively');
}
- function OfferTip({ tipURI, qr_code, tip_status_url }) {
- y(() => {
- let checkUrl;
- try {
- checkUrl = new URL(tip_status_url ? tip_status_url : "{{& tip_status_url }}");
- }
- catch (e) {
- return;
- }
- const delayMs = 500;
- function check() {
- let retried = false;
- function retryOnce() {
- if (!retried) {
- retried = true;
- check();
- }
- }
- const req = new XMLHttpRequest();
- req.onreadystatechange = function () {
- if (req.readyState === XMLHttpRequest.DONE) {
- if (req.status === 410) {
- window.location.reload();
- }
- setTimeout(retryOnce, delayMs);
- }
- };
- req.onerror = function () {
- setTimeout(retryOnce, delayMs);
- };
- req.open("GET", checkUrl.href);
- req.send();
- }
- setTimeout(check, delayMs);
- });
- return a$2(y$1, null,
- a$2("section", { id: "main", class: "content" },
- a$2("h1", { style: { textAlign: 'center' } }, "Collect Taler tip"),
- a$2("div", { style: { textAlign: 'center' }, class: "taler-installed-hide" },
- a$2("p", null, "Scan this QR code with your Taler mobile wallet:"),
- a$2("div", { class: "qr", dangerouslySetInnerHTML: { __html: qr_code ? qr_code : `{{{ taler_tip_qrcode_svg }}}` } }),
- a$2("p", null,
- a$2("a", { class: "pure-button pure-button-active success", href: tipURI ? tipURI : `{{ taler_tip_uri }}` }, "Or open your Taller wallet")),
- a$2("p", null,
- a$2("a", { href: "https://wallet.taler.net/" }, "Don't have a Taler wallet yet? Install it!"))),
- a$2("hr", null)),
- a$2(Footer, null));
+
+ var localeWeekStartsOn = locale.options && locale.options.weekStartsOn;
+ var defaultWeekStartsOn = localeWeekStartsOn == null ? 0 : toInteger(localeWeekStartsOn);
+ var weekStartsOn = options.weekStartsOn == null ? defaultWeekStartsOn : toInteger(options.weekStartsOn); // Test if weekStartsOn is between 0 and 6 _and_ is not NaN
+
+ if (!(weekStartsOn >= 0 && weekStartsOn <= 6)) {
+ throw new RangeError('weekStartsOn must be between 0 and 6 inclusively');
}
- function mount() {
- try {
- const fromLocation = new URL(window.location.href).searchParams;
- const uri = fromLocation.get('tip_uri') || undefined;
- const tsu = fromLocation.get('tip_status_url') || undefined;
- N(a$2(OfferTip, { tipURI: uri, tip_status_url: tsu }), document.body);
+
+ if (!locale.localize) {
+ throw new RangeError('locale must contain localize property');
+ }
+
+ if (!locale.formatLong) {
+ throw new RangeError('locale must contain formatLong property');
+ }
+
+ var originalDate = toDate(dirtyDate);
+
+ if (!isValid(originalDate)) {
+ throw new RangeError('Invalid time value');
+ } // Convert the date in system timezone to the same date in UTC+00:00 timezone.
+ // This ensures that when UTC functions will be implemented, locales will be compatible with them.
+ // See an issue about UTC functions: https://github.com/date-fns/date-fns/issues/376
+
+
+ var timezoneOffset = getTimezoneOffsetInMilliseconds(originalDate);
+ var utcDate = subMilliseconds(originalDate, timezoneOffset);
+ var formatterOptions = {
+ firstWeekContainsDate: firstWeekContainsDate,
+ weekStartsOn: weekStartsOn,
+ locale: locale,
+ _originalDate: originalDate
+ };
+ var result = formatStr.match(longFormattingTokensRegExp).map(function (substring) {
+ var firstCharacter = substring[0];
+
+ if (firstCharacter === 'p' || firstCharacter === 'P') {
+ var longFormatter = longFormatters$1[firstCharacter];
+ return longFormatter(substring, locale.formatLong, formatterOptions);
+ }
+
+ return substring;
+ }).join('').match(formattingTokensRegExp).map(function (substring) {
+ // Replace two single quote characters with one single quote character
+ if (substring === "''") {
+ return "'";
+ }
+
+ var firstCharacter = substring[0];
+
+ if (firstCharacter === "'") {
+ return cleanEscapedString(substring);
+ }
+
+ var formatter = formatters$1[firstCharacter];
+
+ if (formatter) {
+ if (!options.useAdditionalWeekYearTokens && isProtectedWeekYearToken(substring)) {
+ throwProtectedError(substring, dirtyFormatStr, dirtyDate);
}
- catch (e) {
- console.error("got error", e);
- document.body.innerText = `Fatal error: "${e.message}". Please report this bug at https://bugs.gnunet.org/.`;
+
+ if (!options.useAdditionalDayOfYearTokens && isProtectedDayOfYearToken(substring)) {
+ throwProtectedError(substring, dirtyFormatStr, dirtyDate);
}
+
+ return formatter(utcDate, substring, locale.localize, formatterOptions);
+ }
+
+ if (firstCharacter.match(unescapedLatinCharacterRegExp)) {
+ throw new RangeError('Format string contains an unescaped latin alphabet character `' + firstCharacter + '`');
+ }
+
+ return substring;
+ }).join('');
+ return result;
+ }
+
+ function cleanEscapedString(input) {
+ return input.match(escapedStringRegExp)[1].replace(doubleQuoteRegExp, "'");
+ }
+
+ var defaultFormat = ['years', 'months', 'weeks', 'days', 'hours', 'minutes', 'seconds'];
+ /**
+ * @name formatDuration
+ * @category Common Helpers
+ * @summary Formats a duration in human-readable format
+ *
+ * @description
+ * Return human-readable duration string i.e. "9 months 2 days"
+ *
+ * @param {Duration} duration - the duration to format
+ * @param {Object} [options] - an object with options.
+
+ * @param {string[]} [options.format=['years', 'months', 'weeks', 'days', 'hours', 'minutes', 'seconds']] - the array of units to format
+ * @param {boolean} [options.zero=false] - should be zeros be included in the output?
+ * @param {string} [options.delimiter=' '] - delimiter string
+ * @param {Locale} [options.locale=defaultLocale] - the locale object. See [Locale]{@link https://date-fns.org/docs/Locale}
+ * @returns {string} the formatted date string
+ * @throws {TypeError} 1 argument required
+ *
+ * @example
+ * // Format full duration
+ * formatDuration({
+ * years: 2,
+ * months: 9,
+ * weeks: 1,
+ * days: 7,
+ * hours: 5,
+ * minutes: 9,
+ * seconds: 30
+ * })
+ * //=> '2 years 9 months 1 week 7 days 5 hours 9 minutes 30 seconds
+ *
+ * @example
+ * // Format partial duration
+ * formatDuration({ months: 9, days: 2 })
+ * //=> '9 months 2 days'
+ *
+ * @example
+ * // Customize the format
+ * formatDuration(
+ * {
+ * years: 2,
+ * months: 9,
+ * weeks: 1,
+ * days: 7,
+ * hours: 5,
+ * minutes: 9,
+ * seconds: 30
+ * },
+ * { format: ['months', 'weeks'] }
+ * ) === '9 months 1 week'
+ *
+ * @example
+ * // Customize the zeros presence
+ * formatDuration({ years: 0, months: 9 })
+ * //=> '9 months'
+ * formatDuration({ years: 0, months: 9 }, { zero: true })
+ * //=> '0 years 9 months'
+ *
+ * @example
+ * // Customize the delimiter
+ * formatDuration({ years: 2, months: 9, weeks: 3 }, { delimiter: ', ' })
+ * //=> '2 years, 9 months, 3 weeks'
+ */
+
+ function formatDuration(duration, options) {
+ if (arguments.length < 1) {
+ throw new TypeError("1 argument required, but only ".concat(arguments.length, " present"));
+ }
+
+ var format = (options === null || options === void 0 ? void 0 : options.format) || defaultFormat;
+ var locale = (options === null || options === void 0 ? void 0 : options.locale) || defaultLocale;
+ var zero = (options === null || options === void 0 ? void 0 : options.zero) || false;
+ var delimiter = (options === null || options === void 0 ? void 0 : options.delimiter) || ' ';
+ var result = format.reduce(function (acc, unit) {
+ var token = "x".concat(unit.replace(/(^.)/, function (m) {
+ return m.toUpperCase();
+ }));
+ var addChunk = typeof duration[unit] === 'number' && (zero || duration[unit]);
+ return addChunk ? acc.concat(locale.formatDistance(token, duration[unit])) : acc;
+ }, []).join(delimiter);
+ return result;
+ }
+
+ /**
+ * @name subDays
+ * @category Day Helpers
+ * @summary Subtract the specified number of days from the given date.
+ *
+ * @description
+ * Subtract the specified number of days from the given date.
+ *
+ * ### v2.0.0 breaking changes:
+ *
+ * - [Changes that are common for the whole library](https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#Common-Changes).
+ *
+ * @param {Date|Number} date - the date to be changed
+ * @param {Number} amount - the amount of days to be subtracted. Positive decimals will be rounded using `Math.floor`, decimals less than zero will be rounded using `Math.ceil`.
+ * @returns {Date} the new date with the days subtracted
+ * @throws {TypeError} 2 arguments required
+ *
+ * @example
+ * // Subtract 10 days from 1 September 2014:
+ * const result = subDays(new Date(2014, 8, 1), 10)
+ * //=> Fri Aug 22 2014 00:00:00
+ */
+
+ function subDays(dirtyDate, dirtyAmount) {
+ requiredArgs(2, arguments);
+ var amount = toInteger(dirtyAmount);
+ return addDays(dirtyDate, -amount);
+ }
+
+ /**
+ * @name subMonths
+ * @category Month Helpers
+ * @summary Subtract the specified number of months from the given date.
+ *
+ * @description
+ * Subtract the specified number of months from the given date.
+ *
+ * ### v2.0.0 breaking changes:
+ *
+ * - [Changes that are common for the whole library](https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#Common-Changes).
+ *
+ * @param {Date|Number} date - the date to be changed
+ * @param {Number} amount - the amount of months to be subtracted. Positive decimals will be rounded using `Math.floor`, decimals less than zero will be rounded using `Math.ceil`.
+ * @returns {Date} the new date with the months subtracted
+ * @throws {TypeError} 2 arguments required
+ *
+ * @example
+ * // Subtract 5 months from 1 February 2015:
+ * const result = subMonths(new Date(2015, 1, 1), 5)
+ * //=> Mon Sep 01 2014 00:00:00
+ */
+
+ function subMonths(dirtyDate, dirtyAmount) {
+ requiredArgs(2, arguments);
+ var amount = toInteger(dirtyAmount);
+ return addMonths(dirtyDate, -amount);
+ }
+
+ /**
+ * @name sub
+ * @category Common Helpers
+ * @summary Subtract the specified years, months, weeks, days, hours, minutes and seconds from the given date.
+ *
+ * @description
+ * Subtract the specified years, months, weeks, days, hours, minutes and seconds from the given date.
+ *
+ * @param {Date|Number} date - the date to be changed
+ * @param {Duration} duration - the object with years, months, weeks, days, hours, minutes and seconds to be subtracted
+ *
+ * | Key | Description |
+ * |---------|------------------------------------|
+ * | years | Amount of years to be subtracted |
+ * | months | Amount of months to be subtracted |
+ * | weeks | Amount of weeks to be subtracted |
+ * | days | Amount of days to be subtracted |
+ * | hours | Amount of hours to be subtracted |
+ * | minutes | Amount of minutes to be subtracted |
+ * | seconds | Amount of seconds to be subtracted |
+ *
+ * All values default to 0
+ *
+ * @returns {Date} the new date with the seconds subtracted
+ * @throws {TypeError} 2 arguments required
+ *
+ * @example
+ * // Subtract the following duration from 15 June 2017 15:29:20
+ * const result = sub(new Date(2017, 5, 15, 15, 29, 20), {
+ * years: 2,
+ * months: 9,
+ * weeks: 1,
+ * days: 7,
+ * hours: 5,
+ * minutes: 9,
+ * seconds: 30
+ * })
+ * //=> Mon Sep 1 2014 10:19:50
+ */
+
+ function sub(dirtyDate, duration) {
+ requiredArgs(2, arguments);
+ if (!duration || typeof duration !== 'object') return new Date(NaN);
+ var years = 'years' in duration ? toInteger(duration.years) : 0;
+ var months = 'months' in duration ? toInteger(duration.months) : 0;
+ var weeks = 'weeks' in duration ? toInteger(duration.weeks) : 0;
+ var days = 'days' in duration ? toInteger(duration.days) : 0;
+ var hours = 'hours' in duration ? toInteger(duration.hours) : 0;
+ var minutes = 'minutes' in duration ? toInteger(duration.minutes) : 0;
+ var seconds = 'seconds' in duration ? toInteger(duration.seconds) : 0; // Subtract years and months
+
+ var dateWithoutMonths = subMonths(toDate(dirtyDate), months + years * 12); // Subtract weeks and days
+
+ var dateWithoutDays = subDays(dateWithoutMonths, days + weeks * 7); // Subtract hours, minutes and seconds
+
+ var minutestoSub = minutes + hours * 60;
+ var secondstoSub = seconds + minutestoSub * 60;
+ var mstoSub = secondstoSub * 1000;
+ var finalDate = new Date(dateWithoutDays.getTime() - mstoSub);
+ return finalDate;
+ }
+
+ /**
+ * @name intervalToDuration
+ * @category Common Helpers
+ * @summary Convert interval to duration
+ *
+ * @description
+ * Convert a interval object to a duration object.
+ *
+ * @param {Interval} interval - the interval to convert to duration
+ *
+ * @returns {Duration} The duration Object
+ * @throws {TypeError} Requires 2 arguments
+ * @throws {RangeError} `start` must not be Invalid Date
+ * @throws {RangeError} `end` must not be Invalid Date
+ *
+ * @example
+ * // Get the duration between January 15, 1929 and April 4, 1968.
+ * intervalToDuration({
+ * start: new Date(1929, 0, 15, 12, 0, 0),
+ * end: new Date(1968, 3, 4, 19, 5, 0)
+ * })
+ * // => { years: 39, months: 2, days: 20, hours: 7, minutes: 5, seconds: 0 }
+ */
+
+ function intervalToDuration(_ref) {
+ var start = _ref.start,
+ end = _ref.end;
+ requiredArgs(1, arguments);
+ var dateLeft = toDate(start);
+ var dateRight = toDate(end);
+
+ if (!isValid(dateLeft)) {
+ throw new RangeError('Start Date is invalid');
}
- function buildTimeRendering() {
- return {
- head: m$1(a$2(Head, null)),
- body: m$1(a$2(ShowOrderDetails, null))
- };
+
+ if (!isValid(dateRight)) {
+ throw new RangeError('End Date is invalid');
}
- exports.Head = Head;
- exports.OfferTip = OfferTip;
- exports.buildTimeRendering = buildTimeRendering;
- exports.mount = mount;
+ var duration = {
+ years: 0,
+ months: 0,
+ days: 0,
+ hours: 0,
+ minutes: 0,
+ seconds: 0
+ };
+ var sign = compareAsc(dateLeft, dateRight);
+ duration.years = Math.abs(differenceInYears(dateLeft, dateRight));
+ var remainingMonths = sub(dateLeft, {
+ years: sign * duration.years
+ });
+ duration.months = Math.abs(differenceInMonths(remainingMonths, dateRight));
+ var remainingDays = sub(remainingMonths, {
+ months: sign * duration.months
+ });
+ duration.days = Math.abs(differenceInDays(remainingDays, dateRight));
+ var remainingHours = sub(remainingDays, {
+ days: sign * duration.days
+ });
+ duration.hours = Math.abs(differenceInHours(remainingHours, dateRight));
+ var remainingMinutes = sub(remainingHours, {
+ hours: sign * duration.hours
+ });
+ duration.minutes = Math.abs(differenceInMinutes(remainingMinutes, dateRight));
+ var remainingSeconds = sub(remainingMinutes, {
+ minutes: sign * duration.minutes
+ });
+ duration.seconds = Math.abs(differenceInSeconds(remainingSeconds, dateRight));
+ return duration;
+ }
+
+ /*
+ This file is part of GNU Taler
+ (C) 2021 Taler Systems S.A.
+
+ GNU Taler is free software; you can redistribute it and/or modify it under the
+ terms of the GNU General Public License as published by the Free Software
+ Foundation; either version 3, or (at your option) any later version.
+
+ GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along with
+ GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
+ */
+ function Location({ templateName, location, btr }) {
+ //FIXME: mustache strings show be constructed in a way that ends in the final output of the html but is not present in the
+ // javascript code, otherwise when mustache render engine run over the html it will also replace string in the javascript code
+ // that is made to run when the browser has javascript enable leading into undefined behavior.
+ // that's why in the next fields we are using concatenations to build the mustache placeholder.
+ return a$2(y$1, null,
+ btr && `{{` + `#${templateName}.building_name}}`,
+ a$2("dd", null,
+ (location === null || location === void 0 ? void 0 : location.building_name) || (btr && `{{ ${templateName}.building_name }}`),
+ " ",
+ (location === null || location === void 0 ? void 0 : location.building_number) || (btr && `{{ ${templateName}.building_number }}`)),
+ btr && `{{` + `/${templateName}.building_name}}`,
+ btr && `{{` + `#${templateName}.country}}`,
+ a$2("dd", null,
+ (location === null || location === void 0 ? void 0 : location.country) || (btr && `{{ ${templateName}.country }}`),
+ " ",
+ (location === null || location === void 0 ? void 0 : location.country_subdivision) || (btr && `{{ ${templateName}.country_subdivision }}`)),
+ btr && `{{` + `/${templateName}.country}}`,
+ btr && `{{` + `#${templateName}.district}}`,
+ a$2("dd", null, (location === null || location === void 0 ? void 0 : location.district) || (btr && `{{ ${templateName}.district }}`)),
+ btr && `{{` + `/${templateName}.district}}`,
+ btr && `{{` + `#${templateName}.post_code}}`,
+ a$2("dd", null, (location === null || location === void 0 ? void 0 : location.post_code) || (btr && `{{ ${templateName}.post_code }}`)),
+ btr && `{{` + `/${templateName}.post_code}}`,
+ btr && `{{` + `#${templateName}.street}}`,
+ a$2("dd", null, (location === null || location === void 0 ? void 0 : location.street) || (btr && `{{ ${templateName}.street }}`)),
+ btr && `{{` + `/${templateName}.street}}`,
+ btr && `{{` + `#${templateName}.town}}`,
+ a$2("dd", null, (location === null || location === void 0 ? void 0 : location.town) || (btr && `{{ ${templateName}.town }}`)),
+ btr && `{{` + `/${templateName}.town}}`,
+ btr && `{{` + `#${templateName}.town_location}}`,
+ a$2("dd", null, (location === null || location === void 0 ? void 0 : location.town_location) || (btr && `{{ ${templateName}.town_location }}`)),
+ btr && `{{` + `/${templateName}.town_location}}`);
+ }
+ function ShowOrderDetails({ order_summary, refund_amount, contract_terms, btr }) {
+ const productList = (btr ? [{}] : ((contract_terms === null || contract_terms === void 0 ? void 0 : contract_terms.products) || []));
+ const auditorsList = (btr ? [{}] : ((contract_terms === null || contract_terms === void 0 ? void 0 : contract_terms.auditors) || []));
+ const exchangesList = (btr ? [{}] : ((contract_terms === null || contract_terms === void 0 ? void 0 : contract_terms.exchanges) || []));
+ const hasDeliveryInfo = btr || !!(contract_terms === null || contract_terms === void 0 ? void 0 : contract_terms.delivery_date) || !!(contract_terms === null || contract_terms === void 0 ? void 0 : contract_terms.delivery_location);
+ return a$2(Page, null,
+ a$2("header", null,
+ a$2("h1", null,
+ "Details of order ",
+ (contract_terms === null || contract_terms === void 0 ? void 0 : contract_terms.order_id) || `{{ contract_terms.order_id }}`)),
+ a$2("section", null,
+ btr && `{{#refund_amount}}`,
+ (btr || refund_amount) && a$2("section", null,
+ a$2(InfoBox, null,
+ a$2("b", null, "Refunded:"),
+ " The merchant refunded you ",
+ a$2("b", null, refund_amount || `{{ refund_amount }}`),
+ ".")),
+ btr && `{{/refund_amount}}`,
+ a$2("section", null,
+ a$2(TableExpanded, null,
+ a$2("dt", null, "Order summary:"),
+ a$2("dd", null, (contract_terms === null || contract_terms === void 0 ? void 0 : contract_terms.summary) || `{{ contract_terms.summary }}`),
+ a$2("dt", null, "Amount paid:"),
+ a$2("dd", null, (contract_terms === null || contract_terms === void 0 ? void 0 : contract_terms.amount) || `{{ contract_terms.amount }}`),
+ a$2("dt", null, "Order date:"),
+ a$2("dd", null,
+ (contract_terms === null || contract_terms === void 0 ? void 0 : contract_terms.timestamp) ?
+ ((contract_terms === null || contract_terms === void 0 ? void 0 : contract_terms.timestamp.t_ms) != 'never' ?
+ format(contract_terms === null || contract_terms === void 0 ? void 0 : contract_terms.timestamp.t_ms, 'dd MMM yyyy HH:mm:ss') :
+ 'never')
+ : `{{ contract_terms.timestamp_str }}`,
+ " "),
+ a$2("dt", null, "Merchant name:"),
+ a$2("dd", null, (contract_terms === null || contract_terms === void 0 ? void 0 : contract_terms.merchant.name) || `{{ contract_terms.merchant.name }}`))),
+ btr && `{{#contract_terms.hasProducts}}`,
+ !productList.length ? null : a$2("section", null,
+ a$2("h2", null, "Products purchased"),
+ a$2(TableSimple, null,
+ btr && '{{' + '#contract_terms.products' + '}}',
+ productList.map((p, i) => {
+ const taxList = (btr ? [{}] : (p.taxes || []));
+ return a$2(y$1, { key: i },
+ a$2("p", null, p.description || `{{description}}`),
+ a$2("dl", null,
+ a$2("dt", null, "Quantity:"),
+ a$2("dd", null, p.quantity || `{{quantity}}`),
+ a$2("dt", null, "Price:"),
+ a$2("dd", null, p.price || `{{price}}`),
+ btr && `{{#hasTaxes}}`,
+ !taxList.length ? null : a$2(y$1, null,
+ btr && '{{' + '#taxes' + '}}',
+ taxList.map((t, i) => {
+ return a$2(y$1, { key: i },
+ a$2("dt", null, t.name || `{{name}}`),
+ a$2("dd", null, t.tax || `{{tax}}`));
+ }),
+ btr && '{{' + '/taxes' + '}}'),
+ btr && `{{/hasTaxes}}`,
+ btr && `{{#delivery_date}}`,
+ (btr || p.delivery_date) && a$2(y$1, null,
+ a$2("dt", null, "Delivered on:"),
+ a$2("dd", null,
+ p.delivery_date ?
+ (p.delivery_date.t_ms != 'never' ?
+ format(p.delivery_date.t_ms, 'dd MMM yyyy HH:mm:ss') :
+ 'never')
+ : `{{ delivery_date_str }}`,
+ " ")),
+ btr && `{{/delivery_date}}`,
+ btr && `{{#unit}}`,
+ (btr || p.unit) && a$2(y$1, null,
+ a$2("dt", null, "Product unit:"),
+ a$2("dd", null, p.unit || `{{.}}`)),
+ btr && `{{/unit}}`,
+ btr && `{{#product_id}}`,
+ (btr || p.product_id) && a$2(y$1, null,
+ a$2("dt", null, "Product ID:"),
+ a$2("dd", null, p.product_id || `{{.}}`)),
+ btr && `{{/product_id}}`));
+ }),
+ btr && '{{' + '/contract_terms.products' + '}}')),
+ btr && `{{/contract_terms.hasProducts}}`,
+ btr && `{{#contract_terms.has_delivery_info}}`,
+ !hasDeliveryInfo ? null : a$2("section", null,
+ a$2("h2", null, "Delivery information"),
+ a$2(TableExpanded, null,
+ btr && `{{#contract_terms.delivery_date}}`,
+ (btr || (contract_terms === null || contract_terms === void 0 ? void 0 : contract_terms.delivery_date)) && a$2(y$1, null,
+ a$2("dt", null, "Delivery date:"),
+ a$2("dd", null,
+ (contract_terms === null || contract_terms === void 0 ? void 0 : contract_terms.delivery_date) ?
+ ((contract_terms === null || contract_terms === void 0 ? void 0 : contract_terms.delivery_date.t_ms) != 'never' ?
+ format(contract_terms === null || contract_terms === void 0 ? void 0 : contract_terms.delivery_date.t_ms, 'dd MMM yyyy HH:mm:ss') :
+ 'never')
+ : `{{ contract_terms.delivery_date_str }}`,
+ " ")),
+ btr && `{{/contract_terms.delivery_date}}`,
+ btr && `{{#contract_terms.delivery_location}}`,
+ (btr || (contract_terms === null || contract_terms === void 0 ? void 0 : contract_terms.delivery_location)) && a$2(y$1, null,
+ a$2("dt", null, "Delivery address:"),
+ a$2(Location, { btr: btr, location: contract_terms === null || contract_terms === void 0 ? void 0 : contract_terms.delivery_location, templateName: "contract_terms.delivery_location" })),
+ btr && `{{/contract_terms.delivery_location}}`)),
+ btr && `{{/contract_terms.has_delivery_info}}`,
+ a$2("section", null,
+ a$2("h2", null, "Full payment information"),
+ a$2(TableExpanded, null,
+ a$2("dt", null, "Amount paid:"),
+ a$2("dd", null, (contract_terms === null || contract_terms === void 0 ? void 0 : contract_terms.amount) || `{{ contract_terms.amount }}`),
+ a$2("dt", null, "Wire transfer method:"),
+ a$2("dd", null, (contract_terms === null || contract_terms === void 0 ? void 0 : contract_terms.wire_method) || `{{ contract_terms.wire_method }}`),
+ a$2("dt", null, "Payment deadline:"),
+ a$2("dd", null,
+ (contract_terms === null || contract_terms === void 0 ? void 0 : contract_terms.pay_deadline) ?
+ ((contract_terms === null || contract_terms === void 0 ? void 0 : contract_terms.pay_deadline.t_ms) != 'never' ?
+ format(contract_terms === null || contract_terms === void 0 ? void 0 : contract_terms.pay_deadline.t_ms, 'dd MMM yyyy HH:mm:ss') :
+ 'never')
+ : `{{ contract_terms.pay_deadline_str }}`,
+ " "),
+ a$2("dt", null, "Exchange transfer deadline:"),
+ a$2("dd", null,
+ (contract_terms === null || contract_terms === void 0 ? void 0 : contract_terms.wire_transfer_deadline) ?
+ ((contract_terms === null || contract_terms === void 0 ? void 0 : contract_terms.wire_transfer_deadline.t_ms) != 'never' ?
+ format(contract_terms === null || contract_terms === void 0 ? void 0 : contract_terms.wire_transfer_deadline.t_ms, 'dd MMM yyyy HH:mm:ss') :
+ 'never')
+ : `{{ contract_terms.wire_transfer_deadline_str }}`,
+ " "),
+ a$2("dt", null, "Maximum deposit fee:"),
+ a$2("dd", null, (contract_terms === null || contract_terms === void 0 ? void 0 : contract_terms.max_fee) || `{{ contract_terms.max_fee }}`),
+ a$2("dt", null, "Maximum wire fee:"),
+ a$2("dd", null, (contract_terms === null || contract_terms === void 0 ? void 0 : contract_terms.max_wire_fee) || `{{ contract_terms.max_wire_fee }}`),
+ a$2("dt", null, "Wire fee amortization:"),
+ a$2("dd", null,
+ (contract_terms === null || contract_terms === void 0 ? void 0 : contract_terms.wire_fee_amortization) || `{{ contract_terms.wire_fee_amortization }}`,
+ " transactions"))),
+ a$2("section", null,
+ a$2("h2", null, "Refund information"),
+ a$2(TableExpanded, null,
+ a$2("dt", null, "Refund deadline:"),
+ a$2("dd", null,
+ (contract_terms === null || contract_terms === void 0 ? void 0 : contract_terms.refund_deadline) ?
+ ((contract_terms === null || contract_terms === void 0 ? void 0 : contract_terms.refund_deadline.t_ms) != 'never' ?
+ format(contract_terms === null || contract_terms === void 0 ? void 0 : contract_terms.refund_deadline.t_ms, 'dd MMM yyyy HH:mm:ss') :
+ 'never')
+ : `{{ contract_terms.refund_deadline_str }}`,
+ " "),
+ btr && `{{#contract_terms.auto_refund}}`,
+ (btr || (contract_terms === null || contract_terms === void 0 ? void 0 : contract_terms.auto_refund)) && a$2(y$1, null,
+ a$2("dt", null, "Attempt autorefund for:"),
+ a$2("dd", null,
+ (contract_terms === null || contract_terms === void 0 ? void 0 : contract_terms.auto_refund) ?
+ ((contract_terms === null || contract_terms === void 0 ? void 0 : contract_terms.auto_refund.d_ms) != 'forever' ?
+ formatDuration(intervalToDuration({ start: 0, end: contract_terms === null || contract_terms === void 0 ? void 0 : contract_terms.auto_refund.d_ms })) :
+ 'forever')
+ : `{{ contract_terms.auto_refund_str }}`,
+ " ")),
+ btr && `{{/contract_terms.auto_refund}}`)),
+ a$2("section", null,
+ a$2("h2", null, "Additional order details"),
+ a$2(TableExpanded, null,
+ a$2("dt", null, "Public reorder URL:"),
+ a$2("dd", null, " -- not defined yet -- "),
+ btr && `{{#contract_terms.fulfillment_url}}`,
+ (btr || (contract_terms === null || contract_terms === void 0 ? void 0 : contract_terms.fulfillment_url)) && a$2(y$1, null,
+ a$2("dt", null, "Fulfillment URL:"),
+ a$2("dd", null, (contract_terms === null || contract_terms === void 0 ? void 0 : contract_terms.fulfillment_url) || (btr && `{{ contract_terms.fulfillment_url }}`))),
+ btr && `{{/contract_terms.fulfillment_url}}`)),
+ a$2("section", null,
+ a$2("h2", null, "Full merchant information"),
+ a$2(TableExpanded, null,
+ a$2("dt", null, "Merchant name:"),
+ a$2("dd", null, (contract_terms === null || contract_terms === void 0 ? void 0 : contract_terms.merchant.name) || `{{ contract_terms.merchant.name }}`),
+ a$2("dt", null, "Merchant address:"),
+ a$2(Location, { btr: btr, location: contract_terms === null || contract_terms === void 0 ? void 0 : contract_terms.merchant.address, templateName: "contract_terms.merchant.address" }),
+ a$2("dt", null, "Merchant's jurisdiction:"),
+ a$2(Location, { btr: btr, location: contract_terms === null || contract_terms === void 0 ? void 0 : contract_terms.merchant.jurisdiction, templateName: "contract_terms.merchant.jurisdiction" }),
+ a$2("dt", null, "Merchant URI:"),
+ a$2("dd", null, (contract_terms === null || contract_terms === void 0 ? void 0 : contract_terms.merchant_base_url) || `{{ contract_terms.merchant_base_url }}`),
+ a$2("dt", null, "Merchant's public key:"),
+ a$2("dd", null, (contract_terms === null || contract_terms === void 0 ? void 0 : contract_terms.merchant_pub) || `{{ contract_terms.merchant_pub }}`))),
+ btr && `{{#contract_terms.hasAuditors}}`,
+ !auditorsList.length ? null : a$2("section", null,
+ a$2("h2", null, "Auditors accepted by the merchant"),
+ a$2(TableExpanded, null,
+ btr && '{{' + '#contract_terms.auditors' + '}}',
+ auditorsList.map((p, i) => {
+ return a$2(y$1, { key: i },
+ a$2("p", null, p.name || `{{name}}`),
+ a$2("dt", null, "Auditor's public key:"),
+ a$2("dd", null, p.auditor_pub || `{{auditor_pub}}`),
+ a$2("dt", null, "Auditor's URL:"),
+ a$2("dd", null, p.url || `{{url}}`));
+ }),
+ btr && '{{' + '/contract_terms.auditors' + '}}')),
+ btr && `{{/contract_terms.hasAuditors}}`,
+ btr && `{{#contract_terms.hasExchanges}}`,
+ !exchangesList.length ? null : a$2("section", null,
+ a$2("h2", null, "Exchanges accepted by the merchant"),
+ a$2(TableExpanded, null,
+ btr && '{{' + '#contract_terms.exchanges' + '}}',
+ exchangesList.map((p, i) => {
+ return a$2(y$1, { key: i },
+ a$2("dt", null, "Exchange's URL:"),
+ a$2("dd", null, p.url || `{{url}}`),
+ a$2("dt", null, "Public key:"),
+ a$2("dd", null, p.master_pub || `{{master_pub}}`));
+ }),
+ btr && '{{' + '/contract_terms.exchanges' + '}}')),
+ btr && `{{/contract_terms.hasExchanges}}`),
+ a$2(Footer, null));
+ }
+
+ /*
+ This file is part of GNU Taler
+ (C) 2021 Taler Systems S.A.
+
+ GNU Taler is free software; you can redistribute it and/or modify it under the
+ terms of the GNU General Public License as published by the Free Software
+ Foundation; either version 3, or (at your option) any later version.
+
+ GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along with
+ GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
+ */
+ function Head() {
+ return a$2(y$1, null,
+ a$2("meta", { charSet: "UTF-8" }),
+ a$2("meta", { name: "viewport", content: "width=device-width, initial-scale=1.0" }),
+ a$2("noscript", null,
+ a$2("meta", { "http-equiv": "refresh", content: "1" })),
+ a$2("title", null, "Tip available"));
+ }
+ function OfferTip({ tipURI, qr_code, tip_status_url }) {
+ y(() => {
+ let checkUrl;
+ try {
+ checkUrl = new URL(tip_status_url ? tip_status_url : "{{& tip_status_url }}");
+ }
+ catch (e) {
+ return;
+ }
+ const delayMs = 500;
+ function check() {
+ let retried = false;
+ function retryOnce() {
+ if (!retried) {
+ retried = true;
+ check();
+ }
+ }
+ const req = new XMLHttpRequest();
+ req.onreadystatechange = function () {
+ if (req.readyState === XMLHttpRequest.DONE) {
+ if (req.status === 410) {
+ window.location.reload();
+ }
+ setTimeout(retryOnce, delayMs);
+ }
+ };
+ req.onerror = function () {
+ setTimeout(retryOnce, delayMs);
+ };
+ req.open("GET", checkUrl.href);
+ req.send();
+ }
+ setTimeout(check, delayMs);
+ });
+ return a$2(Page, null,
+ a$2("section", null,
+ a$2("h1", null, "Collect Taler tip"),
+ a$2("p", null, "Scan this QR code with your Taler mobile wallet:"),
+ a$2(QRPlaceholder, { dangerouslySetInnerHTML: { __html: qr_code ? qr_code : `{{{ taler_tip_qrcode_svg }}}` } }),
+ a$2("p", null,
+ a$2(WalletLink, { href: tipURI ? tipURI : `{{ taler_tip_uri }}` }, "Or open your Taller wallet")),
+ a$2("p", null,
+ a$2("a", { href: "https://wallet.taler.net/" }, "Don't have a Taler wallet yet? Install it!"))),
+ a$2(Footer, null));
+ }
+ function mount() {
+ try {
+ const fromLocation = new URL(window.location.href).searchParams;
+ const uri = fromLocation.get('tip_uri') || undefined;
+ const tsu = fromLocation.get('tip_status_url') || undefined;
+ N(a$2(OfferTip, { tipURI: uri, tip_status_url: tsu }), document.body);
+ }
+ catch (e) {
+ console.error("got error", e);
+ if (e instanceof Error) {
+ document.body.innerText = `Fatal error: "${e.message}". Please report this bug at https://bugs.gnunet.org/.`;
+ }
+ }
+ }
+ function buildTimeRendering() {
+ return {
+ head: m$1(a$2(Head, null)),
+ body: m$1(a$2(ShowOrderDetails, null))
+ };
+ }
+
+ exports.Head = Head;
+ exports.OfferTip = OfferTip;
+ exports.buildTimeRendering = buildTimeRendering;
+ exports.mount = mount;
- Object.defineProperty(exports, '__esModule', { value: true });
+ Object.defineProperty(exports, '__esModule', { value: true });
- return exports;
+ return exports;
}({}));
</script>