<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>JSDoc: Source: Utility/appUtil.js</title>

    <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">Source: Utility/appUtil.js</h1>

    



    
    <section>
        <article>
            <pre class="prettyprint source linenums"><code>/**
 * Returns the last day of the month.
 * @param {number} year  The year.
 * @param {number} month  The month.
 * @returns {number}  The last day of the month.
 */
function getLastDayOfMonth(year, month) {
    return (new Date(Date.UTC(year, month, 0))).getUTCDate();
}

/**
 * Returns the current date in the UTC timezone.
 * @returns {number}
 */
function getCurrDateUTC() {
    const currDate = new Date();
    return currDate.getUTCDate();
}

/**
 * Returns the date from a given ISOString.
 * @param {string} dateISOString  The callback for the authorized client.
 * @returns {number}
 */
function getDateFromISO(dateISOString) {
    const date = new Date(dateISOString);
    return date.getUTCDate();
}

/**
 * Returns the next date (i.e the day after).
 * @param {Date} date  The date to get the next day of.
 * @returns {Date}
 */
function getNextDay(date) {
    let tomorrow = new Date(date);
    tomorrow.setDate(date.getUTCDate() + 1); // Returns epoch value.
    return new Date(tomorrow); // Convert from epoch to Date.
}

/**
 * Creates and returns a Google Calendars 'events resource'.
 * @param {string} date  A string in the following format: 'Year-month-day'.
 * @param {string} startTime  The start time to associate with the 'start dateTime'.
 * @param {string} endTime  The end time to associate with the 'end dateTime'.
 * @returns {object}  A Google Calendars 'events resource'.
 */
function makeEventResource(date, startTime, endTime) {
    return {
        'summary': 'appointment',
        'start': {
            'dateTime': date + startTime,
            'timeZone': 'UTC',
        },
        'end': {
            'dateTime': date + endTime,
            'timeZone': 'UTC',
        }
    };
}

module.exports = {
    getLastDayOfMonth,
    getCurrDateUTC,
    getDateFromISO,
    getNextDay,
    makeEventResource
};</code></pre>
        </article>
    </section>




</div>

<nav>
    <h2><a href="index.html">Home</a></h2><h3>Global</h3><ul><li><a href="global.html#authorize">authorize</a></li><li><a href="global.html#bookAppointment">bookAppointment</a></li><li><a href="global.html#checkMissingInputs">checkMissingInputs</a></li><li><a href="global.html#findMatchingTimeslot">findMatchingTimeslot</a></li><li><a href="global.html#fs">fs</a></li><li><a href="global.html#getAccessToken">getAccessToken</a></li><li><a href="global.html#getAvailTimeslots">getAvailTimeslots</a></li><li><a href="global.html#getBookableDays">getBookableDays</a></li><li><a href="global.html#getBookedDays">getBookedDays</a></li><li><a href="global.html#getCurrDateUTC">getCurrDateUTC</a></li><li><a href="global.html#getDateFromISO">getDateFromISO</a></li><li><a href="global.html#getLastDayOfMonth">getLastDayOfMonth</a></li><li><a href="global.html#getNextDay">getNextDay</a></li><li><a href="global.html#getResult">getResult</a></li><li><a href="global.html#handleBookAppointment">handleBookAppointment</a></li><li><a href="global.html#handleGetDays">handleGetDays</a></li><li><a href="global.html#handleGetTimeslots">handleGetTimeslots</a></li><li><a href="global.html#is24HoursInAdvance">is24HoursInAdvance</a></li><li><a href="global.html#isInBookableTimeframe">isInBookableTimeframe</a></li><li><a href="global.html#isInPast">isInPast</a></li><li><a href="global.html#makeDaysArr">makeDaysArr</a></li><li><a href="global.html#makeEventResource">makeEventResource</a></li><li><a href="global.html#validateBooking">validateBooking</a></li><li><a href="global.html#validateGetDays">validateGetDays</a></li><li><a href="global.html#validateGetTimeslots">validateGetTimeslots</a></li></ul>
</nav>

<br class="clear">

<footer>
    Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.3</a> on Mon Oct 14 2019 11:51:21 GMT+1100 (Australian Eastern Daylight Time)
</footer>

<script> prettyPrint(); </script>
<script src="scripts/linenumber.js"> </script>
</body>
</html>
