diff-ymd-package
Version:
A javascript library for calculating the difference between two dates in formatted ways like (aY bM cD)(aYears bMonths cDays) or customized desired formats like aY-bM-cD or aYears-bMonths-cDays or kDays or mWeeks or nMonths etc.
329 lines (269 loc) • 9.99 kB
HTML
<html lang="en">
<head>
<meta charset="utf-8" />
<title>diff-ymd-package Documentation</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<script src="scripts/prettify/prettify.js"></script>
<script src="scripts/prettify/lang-css.js"></script>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link
type="text/css"
rel="stylesheet"
href="styles/prettify-tomorrow.css"
/>
<link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css" />
</head>
<body>
<div id="main">
<h1 class="page-title">diff-ymd-package Documentation</h1>
<section>
<header>
<h4>diff-ymd-package provides APIs for calculating the difference between two dates in formatted ways like (aY bM cD)(aYears bMonths cDays) or customized desired formats like aY-bM-cD or aYears-bMonths-cDays or kDays or mWeeks or nMonths etc.</h4>
</header>
</section>
<section>
<header>
<h2>Classes</h2>
<h3>
<span class="attribs"><span class="type-signature"></span></span
>DatesYMD<span class="signature">(firstDate, secondDate)</span
><span class="type-signature"></span>
</h3>
<div class="class-description">
Represents a utility class for calculating the difference between
two dates in (aYears bMonths cDays)(aY bM cD) format.
</div>
</header>
<article>
<div class="container-overview">
<h3>Constructor</h3>
<h4 class="name" id="DatesYMD">
<span class="type-signature"></span>new DatesYMD<span
class="signature"
>(firstDate, secondDate)</span
><span class="type-signature"></span>
</h4>
<div class="description">Creates an instance of DatesYMD.</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>firstDate</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="description last">
The first date in the format 'yyyy-mm-dd' or 'yyyy/mm/dd' or
yyyy.mm.dd .
</td>
</tr>
<tr>
<td class="name"><code>secondDate</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="description last">
The second date in the format 'yyyy-mm-dd' or 'yyyy/mm/dd'or
yyyy.mm.dd .
</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source">
<ul class="dummy">
<li>
<a href="diff-ymd.js.html">diff-ymd.js</a>,
<a href="diff-ymd.js.html#line6">line 6</a>
</li>
</ul>
</dd>
</dl>
</div>
<h3 class="subsection-title">Methods</h3>
<h4 class="name" id="customizeFormat">
<span class="type-signature"></span>customizeFormat<span
class="signature"
>(yearUnit, monthUnit, dayUnit, partSeparator)</span
><span class="type-signature"> → {string}</span>
</h4>
<div class="description">
Customizes the difference using specified units and separators like
(a + yearUnit + partSeparator + b + monthUnit + partSeparator + c +
dayUnit), eg. aYs-bMs-cDs etc.
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>yearUnit</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="description last">The unit for years.</td>
</tr>
<tr>
<td class="name"><code>monthUnit</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="description last">The unit for months.</td>
</tr>
<tr>
<td class="name"><code>dayUnit</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="description last">The unit for days.</td>
</tr>
<tr>
<td class="name"><code>partSeparator</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="description last">
The separator between year, month, and day parts.
</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source">
<ul class="dummy">
<li>
<a href="diff-ymd.js.html">diff-ymd.js</a>,
<a href="diff-ymd.js.html#line158">line 158</a>
</li>
</ul>
</dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">The customized formatted difference.</div>
<dl>
<dt>Type</dt>
<dd>
<span class="param-type">string</span>
</dd>
</dl>
<h4 class="name" id="diffArray">
<span class="type-signature"></span>diffArray<span class="signature"
>()</span
><span class="type-signature"> → {Array}</span>
</h4>
<div class="description">
Calculates the difference between two dates and returns an array
containing Y, M, D, and a formatted 'aY bM cD' difference string.
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source">
<ul class="dummy">
<li>
<a href="diff-ymd.js.html">diff-ymd.js</a>,
<a href="diff-ymd.js.html#line25">line 25</a>
</li>
</ul>
</dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
An array containing the calculated years, months, days, and the
formatted difference.
</div>
<dl>
<dt>Type</dt>
<dd>
<span class="param-type">Array</span>
</dd>
</dl>
<h4 class="name" id="formattedYMD">
<span class="type-signature"></span>formattedYMD<span
class="signature"
>()</span
><span class="type-signature"> → {string}</span>
</h4>
<div class="description">
Returns the formatted difference between two dates.
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source">
<ul class="dummy">
<li>
<a href="diff-ymd.js.html">diff-ymd.js</a>,
<a href="diff-ymd.js.html#line144">line 144</a>
</li>
</ul>
</dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
The formatted difference in the format 'aY bM cD'.
</div>
<dl>
<dt>Type</dt>
<dd>
<span class="param-type">string</span>
</dd>
</dl>
</article>
</section>
</div>
<nav>
<h2><a href="index.html">Home</a></h2>
<h3>Classes</h3>
<ul>
<li><a href="global.html#DatesYMD">DatesYMD</a></li>
</ul>
<h3>Global</h3>
<ul>
<li><a href="global.html#DatesYMD">DatesYMD</a></li>
</ul>
<h3>Global object special method</h3>
<ul>
<li><a href="global.html#diffDates">diffDates</a></li>
</ul>
<h3>DatesYMD Methods</h3>
<ul>
<li><a href="global.html#customizeFormat">customizeFormat</a></li>
<li><a href="global.html#diffArray">diffArray</a></li>
<li><a href="global.html#diffInDays">diffInDays</a></li>
<li><a href="global.html#diffInHours">diffInHours</a></li>
<li><a href="global.html#diffInMinutes">diffInMinutes</a></li>
<li><a href="global.html#diffInMonths">diffInMonths</a></li>
<li><a href="global.html#diffInSeconds">diffInSeconds</a></li>
<li><a href="global.html#diffInWeeks">diffInWeeks</a></li>
<li><a href="global.html#diffInYears">diffInYears</a></li>
<li><a href="global.html#formattedYMD">formattedYMD</a></li>
</ul>
</nav>
<br class="clear" />
<footer>
Documentation generated by
<a href="https://github.com/jsdoc/jsdoc">JSDoc 4.0.2</a>
</footer>
<script>
prettyPrint();
</script>
<script src="scripts/linenumber.js"></script>
</body>
</html>