css Audio - Active file-generic CSS - Active Generic - Active HTML - Active JS - Active SVG - Active Text - Active file-generic Video - Active header Love html icon-new-collection icon-person icon-team numbered-list123 pop-out spinner split-screen star tv

Pen Settings

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation

     

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

            
              <body onload="startTime(), weekNames(), startCal(), createLanguageSelector(), languageSwap(), ajax()">
  <div class="container" onload="startTime()">
    <div class="today__container">
      <div class="clockdate__container">
        <div class="clockdate__title__container">
          <h2 id="clock__time__label" class="text-bold">Current Time</h2>
        </div>
        <div id="clock__numbers" class="clockdate__string__container">
          <div class="clockdate__digit__container">
            <h1 id="clock__num__hour" class="clockdate__digit--num">10</h1>
            <h3 id="clock__word__hour" class="clockdate__digit--word">ten</h3>
          </div>
          <div class="clockdate__digit__container">
            <h1 id="clock__num__spacer1" class="clockdate__digit--num">:</h1>
            <h3 id="clock__word__spacer1" class="clockdate__digit--word">:</h3>
          </div>
          <div class="clockdate__digit__container">
            <h1 id="clock__num__min" class="clockdate__digit--num">10</h1>
            <h3 id="clock__word__min" class="clockdate__digit--word">ten</h3>
          </div>
          <div class="clockdate__digit__container">
            <h1 id="clock__num__spacer2" class="clockdate__digit--num">:</h1>
            <h3 id="clock__word__spacer2" class="clockdate__digit--word">:</h3>
          </div>
          <div class="clockdate__digit__container">
            <h1 id="clock__num__sec" class="clockdate__digit--num">25</h1>
            <h3 id="clock__word__sec" class="clockdate__digit--word">twenty-five</h3>
          </div>
        </div>
      </div>
      <div class="clockdate__container">
        <div class="clockdate__title__container">
          <h2 id="date__yesterday__label" class="text-bold">Yesterday</h2>
        </div>
        <div class="clockdate__string__container">
          <div id="clockdate__digit__container--yesterday--month" class="clockdate__digit__container clockdate__digit__container--first">
            <h1 id="date__num__month--yesterday" class="clockdate__digit--num">10</h1>
            <h3 id="date__word__month--yesterday" class="clockdate__digit--word">October</h3>
          </div>
          <div class="clockdate__digit__container clockdate__digit__container--second">
            <h1 id="date__num__spacer1--yesterday" class="clockdate__digit--num">/</h1>
            <h3 id="date__num__spacer1--yesterday" class="clockdate__digit--num"></h3>
          </div>
          <div id="clockdate__digit__container--yesterday--day" class="clockdate__digit__container clockdate__digit__container--third">
            <h1 id="date__num__day--yesterday" class="clockdate__digit--num">9</h1>
            <h3 id="date__word__day--yesterday" class="clockdate__digit--word">Ninth</h3>
          </div>
          <div class="clockdate__digit__container clockdate__digit__container--fourth">
            <h1 id="date__num__spacer2--yesterday" class="clockdate__digit--num">/</h1>
            <h3 id="date__word__spacer1--yesterday" class="clockdate__digit--word">,</h3>
          </div>
          <div class="clockdate__digit__container clockdate__digit__container--fifth">
            <h1 id="date__num__year--yesterday" class="clockdate__digit--num">2016</h1>
            <h3 id="date__word__year--yesterday" class="clockdate__digit--word">Two thousand sixteen</h3>
          </div>
        </div>
      </div>
      <div class="clockdate__container">
        <div class="clockdate__title__container">
          <h2 id="date__today__label" class="text-bold">Today</h2>
        </div>
        <div class="clockdate__string__container">
          <div id="clockdate__digit__container--today--month" class="clockdate__digit__container clockdate__digit__container--first">
            <h1 id="date__num__month--today" class="clockdate__digit--num">10</h1>
            <h3 id="date__word__month--today" class="clockdate__digit--word">October</h3>
          </div>
          <div class="clockdate__digit__container clockdate__digit__container--second">
            <h1 id="date__num__spacer1--today" class="clockdate__digit--num">/</h1>
            <h3 id="date__num__spacer1--today" class="clockdate__digit--num"></h3>
          </div>
          <div id="clockdate__digit__container--today--day" class="clockdate__digit__container clockdate__digit__container--third">
            <h1 id="date__num__day--today" class="clockdate__digit--num">9</h1>
            <h3 id="date__word__day--today" class="clockdate__digit--word">Ninth</h3>
          </div>
          <div class="clockdate__digit__container clockdate__digit__container--fourth">
            <h1 id="date__num__spacer2--today" class="clockdate__digit--num">/</h1>
            <h3 id="date__word__spacer1--today" class="clockdate__digit--word">,</h3>
          </div>
          <div class="clockdate__digit__container clockdate__digit__container--fifth">
            <h1 id="date__num__year--today" class="clockdate__digit--num">2016</h1>
            <h3 id="date__word__year--today" class="clockdate__digit--word">Two thousand sixteen</h3>
          </div>
        </div>
      </div>
      <div class="clockdate__container">
        <div class="clockdate__title__container">
          <h2 id="date__tomorrow__label" class="text-bold">Tomorrow</h2>
        </div>
        <div class="clockdate__string__container">
          <div id="clockdate__digit__container--tomorrow--month" class="clockdate__digit__container clockdate__digit__container--first">
            <h1 id="date__num__month--tomorrow" class="clockdate__digit--num">10</h1>
            <h3 id="date__word__month--tomorrow" class="clockdate__digit--word">October</h3>
          </div>
          <div class="clockdate__digit__container clockdate__digit__container--second">
            <h1 id="date__num__spacer1--tomorrow" class="clockdate__digit--num">/</h1>
            <h3 id="date__num__spacer1--tomorrow" class="clockdate__digit--num"></h3>
          </div>
          <div id="clockdate__digit__container--tomorrow--day" class="clockdate__digit__container clockdate__digit__container--third">
            <h1 id="date__num__day--tomorrow" class="clockdate__digit--num">9</h1>
            <h3 id="date__word__day--tomorrow" class="clockdate__digit--word">Ninth</h3>
          </div>
          <div class="clockdate__digit__container clockdate__digit__container--fourth">
            <h1 id="date__num__spacer2--tomorrow" class="clockdate__digit--num">/</h1>
            <h3 id="date__word__spacer1--tomorrow" class="clockdate__digit--word">,</h3>
          </div>
          <div class="clockdate__digit__container clockdate__digit__container--fifth">
            <h1 id="date__num__year--tomorrow" class="clockdate__digit--num">2016</h1>
            <h3 id="date__word__year--tomorrow" class="clockdate__digit--word">Two thousand sixteen</h3>
          </div>
        </div>
      </div>
    </div>

    <div class="cal__container">
      <div class="cal__heading__container">
        <div class="cal__heading">
          <h2 id="cal__heading--month">Month</h2>
          <h2>:</h2>
          <h2 id="cal__heading--monthName">October</h2>
        </div>
        <div class="cal__heading cal__heading--larger">
          <div class="cal__heading--box">
            <h3>Options:</h3></div>
          <div id="languageSelectorContainer" class="cal__heading--box">
            <h4>Language:</h4>
            <!-- <select id="languageSelector" name="">
                      <option value="english" selected>English</option>
                      <option value="french">French</option>
                    </select> -->
          </div>
          <div class="cal__heading--box">
            <h4>Week Start Day</h4>
            <form action="">
              <input type="radio" name="day" value="sun" onclick="if(this.checked){startWeekDay('sun')}" checked> Sunday<br>
              <input type="radio" name="day" value="sun" onclick="if(this.checked){startWeekDay('mon')}"> Monday<br>
            </form>
          </div>

          <div class="cal__heading--box">
            <h4>Date Order:</h4>
            <form action="">
              <input type="radio" name="order" value="mdy" onclick="if(this.checked){dateDigitSwap('mdy'), weekNames('english')}" checked> Month, Day, Year<br>
              <input type="radio" name="order" value="dmy" onclick="if(this.checked){dateDigitSwap('dmy'), weekNames('french')}"> Day, Month, Year<br>
            </form>
          </div>

          <div class="github-mention">
            <p>
              <a href="https://github.com/rlahoda/multilingual-calendar" target="_blank">Check out the source files on Github and add more languages!</a>
            </p>

          </div>
        </div>
      </div>
      <div class="cal__week">
        <div id="cal__week__day--sun" class="cal__week__day cal__week__day--first">
          <h3 id="cal__week__day--0" class="cal__week__day--text">Sunday</h3>
        </div>
        <div class="cal__week__day">
          <h3 id="cal__week__day--1" class="cal__week__day--text">Monday</h3>
        </div>
        <div class="cal__week__day">
          <h3 id="cal__week__day--2" class="cal__week__day--text">Tuesday</h3>
        </div>
        <div class="cal__week__day">
          <h3 id="cal__week__day--3" class="cal__week__day--text">Wednesday</h3>
        </div>
        <div class="cal__week__day">
          <h3 id="cal__week__day--4" class="cal__week__day--text">Thursday</h3>
        </div>
        <div class="cal__week__day">
          <h3 id="cal__week__day--5" class="cal__week__day--text">Friday</h3>
        </div>
        <div class="cal__week__day">
          <h3 id="cal__week__day--6" class="cal__week__day--text">Saturday</h3>
        </div>
      </div>
      <div id="cal__days__grid" class="cal__days__grid">
        <!-- <div class="cal__days__day cal__days__day--weekend">
                    <h3 class="cal__days__day--num">1</h3>
                    <h4 class="cal__days__day--text">One</h4>
                    <h5 class="cal__days__day--ordinal">First</h5>
                </div> -->
      </div>
    </div>
  </div>
</body>
            
          
!
            
              @mixin respond-at($media) {
  @media only screen and (min-width: $media) {
    @content;
  }
}

@mixin respond-ht($media) {
  @media only screen and (min-height: $media) {
    @content;
  }
}

html {
  box-sizing: border-box;
}

*,
*::before,
*::after {
  box-sizing: inherit;
}

$base-clr: #2ca8c8;
$base-20l: (lighten($base-clr, 20%));
$base-20d: (darken($base-clr, 20%));
$accent-clr: #e71414;
$accent-20l: (lighten($accent-clr, 20%));
$accent-20d: (darken($accent-clr, 20%));
$primary-grey: #6f6f6f;
$light-grey: #c0c0c0;
// Width Breakpoints
$bp-xsmall: 600px;
$bp-small: 780px;
$bp-med: 1060px;
$bp-large: 1400px;
// Height Breakpoints
$bph-small: 740px;
$bph-med: 825px;
body {
  font-family: 'Josefin Sans', sans-serif;
  font-style: normal;
  font-weight: 400;
  line-height: 1.25;
  color: $primary-grey;
}

a,
a:visited {
  color: $primary-grey;
}

.light-grey {
  color: $light-grey;
}

h1 {
  font-size: 1.7em;
  &::first-letter {
    text-transform: capitalize;
  }
  // @include respond-at($bp-med) {
  //   font-size: 2em;
  // }
  // @include respond-at($bp-large) {
  //   font-size: 4em;
  // }
}

h2 {
  font-size: 1em;
  margin: 2px;
  &::first-letter {
    text-transform: capitalize;
  }
  @include respond-at($bp-med) {
    font-size: 1.5em;
  }
  // @include respond-at($bp-large) {
  //   font-size: 2em;
  // }
}

h3 {
  font-size: 0.8em;
  &::first-letter {
    text-transform: capitalize;
  }
  @include respond-at($bp-med) {
    font-size: 1em;
  }
  // @include respond-at($bp-large) {
  //   font-size: 1.5em;
  // }
}

h4 {
  font-size: 0.5em;
  font-weight: 600;
  &::first-letter {
    text-transform: capitalize;
  }
  @include respond-at($bp-med) {
    font-size: 0.7em;
  }
  // @include respond-at($bp-large) {
  //   font-size: 1em;
  // }
}

.text-bold {
  font-weight: 600;
}

.container {
  display: flex;
  flex-direction: column;
  width: 100%;
  min-height: 100vh;
  @supports (display: grid) {
    display: grid;
    grid-template-columns: 1fr;
    grid-gap: 10px;
  }

  @include respond-at($bp-med) {
    min-height: 100vh;
    flex-direction: row;
    @supports (display: grid) {
      display: grid;
      grid-template-columns: 1fr 3fr;
      grid-gap: 10px;
    }
  }
}


/* calendar */

.cal__container {
  flex: 1 1 auto;
  width: 98%;
  margin: 5px;
  border-radius: 25px;
  border-style: solid;
  border-width: 1px;
  border-color: $light-grey;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  @supports (display: grid) {
    margin: 0;
  }
  @include respond-at($bp-med) {
    width: 60%;
    @supports (display: grid) {
      width: 100%;
      margin: 0;
    }
  }
}

.cal__heading__container {
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  background-color: #ededed;
  flex-direction: column;
  @include respond-at($bp-small) {
    flex-direction: row;
  }
}

.cal__heading {
  display: flex;
  justify-content: center;
  width: 100%;
  @include respond-at($bp-small) {
    width: 25%;
  }
  flex: 1 1 auto;
  padding: 5px;
  overflow: hidden;
}

.cal__heading--larger {
  flex: 2 1 auto;
  width: 100%;
  @include respond-at($bp-small) {
    width: 50%;
  }
  justify-content: space-around;
  align-items: flex-start;
  @supports (display: grid) {
    display: grid;
    grid-template-rows: auto;
    grid-template-columns: repeat(3, 1fr);
    grid-template-areas:
      "options options options"
      "language weekstart dateorder"
      "github github github";
  }
  @include respond-at($bp-med) {
      grid-template-columns: repeat(5, 1fr);
      grid-template-areas:
        "options language weekstart dateorder github";

    }
}

#languageSelectorContainer {
  padding: 0 5px;
  grid-area: language;
}

.github-mention {
  background-color: #edf3fe;
  border-style: solid;
  border-radius: 5px;
  border-color: blue;
  display: flex;
  align-items: center;
  padding: 5px;
  width: 30%;
  @supports (display: grid) {
    grid-area: github;
    width: 100%;
  }

}

.cal__heading--box {
  text-align: center;
}
.cal__heading--options {
  grid-area: options;
}

.cal__heading--weekstart {
  grid-area: weekstart;
}

.cal__heading--dateOrder {
  grid-area: dateorder;
}

.cal__week {
  display: flex;
  justify-content: center;
  @supports (display: grid) {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    grid-gap: 1em;
  }
}

.cal__week__day {
  margin: 5px;
  flex: 1 1 auto;
  width: 12%;
  display: flex;
  justify-content: center;
  @include respond-at($bp-small) {
    margin: 10px;
  }
  //grid
  @supports (display: grid){
    justify-self: end;
    width: 100%;
    @include respond-at($bp-small) {
      justify-self: center;
      width: auto;
    }

  }


}

.cal__week__day--text {
  font-size: 0;
  width: 0;
  &::first-letter {
    font-size: 20px;
  }
  @include respond-at($bp-xsmall) {
    font-size: inherit;
    width: auto;
    &::first-letter {
      font-size: inherit;
    }
  }
}

.cal__days__grid {
  //flexbox
  display: flex;
  flex-wrap: wrap;
  //grid if supported
  @supports (display: grid) {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    grid-gap: 5px;
    @include respond-at($bp-small) {
      grid-gap: 1em;
    }
  }

  height: auto;
  padding: 0.5%;
  width: 100%;
}

.cal__days__spacer {
  padding: auto;
  margin: 10px 1% 0 0;
  display: flex;
  flex: 1 1 auto;
  // width: 12%;
  width: auto;
  box-shadow: 2px 2px 5px 0 rgba(0, 0, 0, 0);
  order: 0;
  @supports (display: grid) {
    // display: grid;
    // grid-template-columns: repeat(7, 1fr);
    // grid-gap: 5px;
    // overflow: scroll;
    @include respond-at($bp-small) {
      padding: 1em;
    }
  }
}

.cal__days__day {
  @extend .cal__days__spacer;
  background-color: #dff8fd;
  justify-content: center;
  flex-direction: column;
  align-items: center;
  border-radius: 20px;
  border-style: solid;
  border-width: 1px;
  border-color: #c3f3fd;
  box-shadow: 2px 2px 5px 0 rgba(0, 0, 0, 0.15);
  order: 1;
  text-align: center;
}

.cal__days__spacer--end {
  @extend .cal__days__spacer;
  order: 2;
}

.cal__days__day--text {
  visibility: hidden;
  height: 0;
  width: 0;
  @include respond-at($bp-xsmall) {
    visibility: visible;
    height: auto;
    width: auto;
  }
}

.cal__days__day--ordinal {
  visibility: hidden;
  height: 0;
  width: 0;
  @include respond-at($bp-xsmall) {
    visibility: visible;
    height: auto;
    width: auto;
  }
}

.cal__days__day--weekend {
  background-color: #fefde6;
  border-color: #fefabd;
}

.cal__days__day--today {
  background-color: #fddfed;
  border-color: #febddb;
}

.cal__week__day {
  order: 1;
}

.cal__week__day--first {
  order: 0;
}

.cal__week__day--last {
  order: 2;
}

.today__container {
  display: flex;
  flex: 1 1 auto;
  flex-wrap: wrap;
  width: 98%;
  flex-direction: row;
  align-items: flex-start;
  text-align: center;
  margin: 5px;
  padding: 10px;
  border-radius: 25px;
  border-style: solid;
  border-width: 1px;
  border-color: $light-grey;
  // @include respond-at($bp-med) {
  //   flex-direction: row;
  //   align-items: center;
  // }
  @supports (display: grid) {
    margin: 0;
  }
  @include respond-at($bp-med) {
    flex-direction: column;
    width: 10%;
    flex-wrap: nowrap;
    align-items: center;
    @supports (display: grid) {
      width: 100%;
      margin: 0;
    }
  }
}

.clockdate__container {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  width: 55%;
  margin-bottom: 5px;
  margin-top: 5px;
  align-items: center;
  justify-content: center;
  @include respond-at($bp-xsmall) {
    width: 45%;
  }
  // @include respond-at($bp-med) {
  //   width: 45%;
  // }
  @include respond-at($bp-med) {
    width: 100%;
  }
}

.clockdate__string__container {
  display: flex;
  justify-content: space-around;
  width: 80%;
  min-height: 20%;
  @supports (display: grid) {
    display: grid;
    grid-template-columns: 4fr 1fr 4fr 1fr 4fr;
    
  }
}

.clockdate__digit__container {
  flex: 1 1 auto;
  flex-direction: column;
  display: flex;
  justify-content: left;
  align-items: center;
}

.clockdate__digit__container--first {
  order: 1;
}

.clockdate__digit__container--second {
  order: 2;
}

.clockdate__digit__container--third {
  order: 3;
}

.clockdate__digit__container--fourth {
  order: 4;
}

.clockdate__digit__container--fifth {
  order: 5;
}

            
          
!
            
              var info = {
  "english": {
    "month": "month",
    "currenttime": "current time",
    "today": "today",
    "yesterday": "yesterday",
    "tomorrow": "tomorrow",
    "days": ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"],
    "months": ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"],
    "years": ["two thousand sixteen", "two thousand seventeen", "two thousand eighteen"],
    "numbers": ["zero", "one", "two", "three", "four", "five", "six", "Seven", "eight", "nine", "ten", "eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", "nineteen", "twenty", "twenty-one", "twenty-two", "twenty-three", "twenty-four", "twenty-five", "twenty-six", "twenty-seven", "twenty-eight", "twenty-nine", "thirty", "thirty-one", "thirty-two", "thirty-three", "thirty-four", "thirty-five", "thirty-six", "thirty-seven", "thirty-eight", "thirty-nine", "forty", "forty-one", "forty-two", "forty-three", "forty-four", "forty-five", "forty-six", "forty-seven", "forty-eight", "forty-nine", "fifty", "fifty-one", "fifty-two", "fifty-three", "fifty-four", "fifty-five", "fifty-six", "fifty-seven", "fifty-eight", "fifty-nine", "sixty", "sixty-one", "sixty-two", "sixty-three", "sixty-four", "sixty-five", "sixty-six", "sixty-seven", "sixty-eight", "sixty-nine", "seventy", "seventy-one", "seventy-two", "seventy-three", "seventy-four", "seventy-five", "seventy-six", "seventy-seven", "seventy-eight", "seventy-nine", "eighty", "eighty-one", "eighty-two", "eighty-three", "eighty-four", "eighty-five", "eighty-six", "eighty-seven", "eighty-eight", "eighty-nine", "ninety", "ninety-one", "ninety-two", "ninety-three", "ninety-four", "ninety-five", "ninety-six", "ninety-seven", "ninety-eight", "ninety-nine", "hundred"],
    "ordinals": ["zero", "first", "second", "third", "fourth", "fifth", "sixth", "seventh", "eighth", "ninth", "tenth", "eleventh", "twelfth", "thirteenth", "fourteenth", "fifteenth", "sixteenth", "seventeenth", "eighteenth", "nineteenth", "twentyeth", "twenty-first", "twenty-second", "twenty-third", "twenty-fourth", "twenty-fifth", "twenty-sixth", "twenty-seventh", "twenty-eighth", "twenty-ninth", "thirtieth", "thirty-first"]
  }
}

// To change the request, edit this url
var url = "https://raw.githubusercontent.com/rlahoda/multilingual-calendar/master/languages.json";

// the ajax request
function ajax() {
  var xhr = new XMLHttpRequest();
  // console.log(xhr);
  xhr.open("GET", url, true);
  xhr.onreadystatechange = callback;
  // console.log(xhr.readyState, xhr.status, xhr.statusText);
  xhr.send();

  function callback() {
    // console.log(xhr.readyState, xhr.status, xhr.statusText);
    if (xhr.readyState == 4) {
      var response = JSON.parse(xhr.responseText);
      console.log(response);
      info = response;
      console.log(info);
      reCreateLanguageSelector();
      languageSwap();
    }
  }
}

var languageGlobal = 'english';
var runFirstTime = true;

var mon = 'sun';
var dateOrder = 'mdy';

function leapYear(year) {
  if (year % 4 == 0) // basic rule
    return true // is leap year
    /* else */ // else not needed when statement is "return"
  return false // is not leap year
}

function monthDays(month, year) {
  var ar = new Array(12)
  ar[0] = 31 // January
  ar[1] = (leapYear(year)) ? 29 : 28 // February
  ar[2] = 31 // March
  ar[3] = 30 // April
  ar[4] = 31 // May
  ar[5] = 30 // June
  ar[6] = 31 // July
  ar[7] = 31 // August
  ar[8] = 30 // September
  ar[9] = 31 // October
  ar[10] = 30 // November
  ar[11] = 31 // December

  // return number of days in the specified month (parameter)
  return ar[month]
}

function masterDate() {
  var today = new Date();
  // var today = new Date("January 14, 2017");
  // var today = new Date("April 14, 2017");
  var year = today.getYear();
  if (year < 1000)
    year += 1900;
  var day = today.getDay() + 2;

  var month = today.getMonth() + 1;
  if (month < 10)
    month = "0" + month;
  var month1 = today.getMonth();
  var day1 = today.getDate();
  // console.log(day1);
  var firstDay = new Date(year, month1, 1);
  var firstDayNumber = firstDay.getDay();
  // console.log(mon + '3');
  if (mon === 'mon') {
    if (firstDayNumber === 0) {
      firstDayNumber = firstDayNumber + 6;
    } else {
      firstDayNumber = firstDayNumber - 1;
    }

  }

  var monthLength = monthDays(month1, year);
  // console.log(firstDayNumber);

  var daysLeft = 42 - (monthLength + firstDayNumber);

  return {
    today: today,
    year: year,
    day: day,
    month: month,
    month1: month1,
    day1: day1,
    firstDay: firstDay,
    firstDayNumber: firstDayNumber
  }

}

function startWeekDay(day) {
  startWeekDaySwap(day);
  var overallDate = masterDate();
  var today = overallDate.today;
  // console.log(overallDate.firstDayNumber);
  if (day !== mon) {
    if (day === 'mon') {
      if (overallDate.firstDayNumber === 0) {
        for (var i = 0; i < 6; i++) {
          createSpacer(i);
        }
      } else {
        var parent = document.getElementById('cal__days__grid');
        var child = document.getElementById("cal__days__spacer0");
        parent.removeChild(child);
      }

    } else if (day === 'sun') {
      if (overallDate.firstDayNumber === 6) {
        for (var i = 0; i < 6; i++) {
          var parent = document.getElementById('cal__days__grid');
          var child = document.getElementById("cal__days__spacer" + i);
          parent.removeChild(child);
        }
      } else {
        createSpacer(0);
      }

    }
    mon = day;
  }
}

function dateDigitSwap(order) {
  if (order !== dateOrder) {
    if (order === 'dmy') {
      document.getElementById('clockdate__digit__container--yesterday--month').classList.add("clockdate__digit__container--third");
      document.getElementById('clockdate__digit__container--yesterday--month').classList.remove("clockdate__digit__container--first");
      document.getElementById('clockdate__digit__container--yesterday--day').classList.add("clockdate__digit__container--first");
      document.getElementById('clockdate__digit__container--yesterday--day').classList.remove("clockdate__digit__container--third");

      document.getElementById('clockdate__digit__container--today--month').classList.add("clockdate__digit__container--third");
      document.getElementById('clockdate__digit__container--today--month').classList.remove("clockdate__digit__container--first");
      document.getElementById('clockdate__digit__container--today--day').classList.add("clockdate__digit__container--first");
      document.getElementById('clockdate__digit__container--today--day').classList.remove("clockdate__digit__container--third");

      document.getElementById('clockdate__digit__container--tomorrow--month').classList.add("clockdate__digit__container--third");
      document.getElementById('clockdate__digit__container--tomorrow--month').classList.remove("clockdate__digit__container--first");
      document.getElementById('clockdate__digit__container--tomorrow--day').classList.add("clockdate__digit__container--first");
      document.getElementById('clockdate__digit__container--tomorrow--day').classList.remove("clockdate__digit__container--third");

    } else if (order === 'mdy') {
      document.getElementById('clockdate__digit__container--yesterday--month').classList.add("clockdate__digit__container--first");
      document.getElementById('clockdate__digit__container--yesterday--month').classList.remove("clockdate__digit__container--third");
      document.getElementById('clockdate__digit__container--yesterday--day').classList.add("clockdate__digit__container--third");
      document.getElementById('clockdate__digit__container--yesterday--day').classList.remove("clockdate__digit__container--first");

      document.getElementById('clockdate__digit__container--today--month').classList.add("clockdate__digit__container--first");
      document.getElementById('clockdate__digit__container--today--month').classList.remove("clockdate__digit__container--third");
      document.getElementById('clockdate__digit__container--today--day').classList.add("clockdate__digit__container--third");
      document.getElementById('clockdate__digit__container--today--day').classList.remove("clockdate__digit__container--first");

      document.getElementById('clockdate__digit__container--tomorrow--month').classList.add("clockdate__digit__container--first");
      document.getElementById('clockdate__digit__container--tomorrow--month').classList.remove("clockdate__digit__container--third");
      document.getElementById('clockdate__digit__container--tomorrow--day').classList.add("clockdate__digit__container--third");
      document.getElementById('clockdate__digit__container--tomorrow--day').classList.remove("clockdate__digit__container--first");
    }
    dateOrder = order;
  }
}

function languageSwap(language) {
  document.getElementById("languageSelector").onchange = function() {
    var language = this.value;
    if (language != languageGlobal) {
      languageGlobal = language;
    }

    startTime();
    weekNames();
    startCal();
  }
}

function createLanguageOption(language) {
  var option = document.createElement("option");
  option.value = language;
  var optionText = document.createTextNode(language);
  option.appendChild(optionText);
  return option;
}

function reCreateLanguageSelector() {
  var parent = document.getElementById('languageSelectorContainer');
  var child = document.getElementById("languageSelector");
  parent.removeChild(child);

  createLanguageSelector();
}

function createLanguageSelector() {

  var select = document.createElement("select");
  select.id = "languageSelector";
  console.log(Object.getOwnPropertyNames(info));
  var properties = Object.getOwnPropertyNames(info);
  console.log(properties[1]);
  var languages = Object.keys(info).length;
  for (var i = 0; i < languages; i++) {
    var option = createLanguageOption(properties[i]);
    select.appendChild(option);
  }
  document.getElementById("languageSelectorContainer").appendChild(select);
}

function startWeekDaySwap(day) {
  if (day === "mon") {
    document.getElementById('cal__week__day--sun').classList.add("cal__week__day--last");
    document.getElementById('cal__week__day--sun').classList.remove("cal__week__day--first");
  } else {
    document.getElementById('cal__week__day--sun').classList.add("cal__week__day--first");
    document.getElementById('cal__week__day--sun').classList.remove("cal__week__day--last");
  };
}

function startTime() {
  var overallDate = masterDate();
  var today = overallDate.today;
  var todayNum = today.getDate();
  var tomorrow = new Date();
  tomorrow.setDate(today.getDate() + 1);
  var tomorrowNum = tomorrow.getDate();
  var yesterday = new Date();
  yesterday.setDate(today.getDate() - 1);
  var yesterdayNum = yesterday.getDate();
  var h = today.getHours();
  var m = today.getMinutes();
  var s = today.getSeconds();
  var m1 = today.getMinutes();
  var s1 = today.getSeconds();
  m = checkTime(m);
  s = checkTime(s);
  var year = today.getYear();
  if (year < 1000)
    year += 1900;
  var day = today.getDay() + 2;
  // console.log(day);
  var month = today.getMonth() + 1;
  // if (month < 10)
  //   month = "0" + month;
  var year_word = year - 2016;

  var year_y = yesterday.getYear();
  if (year_y < 1000)
    year_y += 1900;
  var month_y = yesterday.getMonth() + 1;
  // if (month < 10)
  //   month = "0" + month;
  var year_y_word = year_y - 2016;

  var year_t = tomorrow.getYear();
  if (year_t < 1000)
    year_t += 1900;
  var month_t = tomorrow.getMonth() + 1;
  var year_t_word = year_t - 2016;

  // if (month < 10)
  //   month = "0" + month;
  var daym = tomorrow.getDate();
  if (daym < 10)
    daym = "0" + daym;
  document.getElementById('clock__time__label').innerHTML = info[languageGlobal].currenttime;
  document.getElementById('clock__num__hour').innerHTML = h;
  document.getElementById('clock__num__min').innerHTML = m;
  document.getElementById('clock__num__sec').innerHTML = s;

  document.getElementById('clock__word__hour').innerHTML = info[languageGlobal].numbers[h];
  document.getElementById('clock__word__min').innerHTML = info[languageGlobal].numbers[m1];
  document.getElementById('clock__word__sec').innerHTML = info[languageGlobal].numbers[s1];

  document.getElementById('date__today__label').innerHTML = info[languageGlobal].today;
  document.getElementById('date__num__day--today').innerHTML = todayNum;
  document.getElementById('date__num__month--today').innerHTML = month;
  document.getElementById('date__num__year--today').innerHTML = year;

  document.getElementById('date__word__day--today').innerHTML = info[languageGlobal].numbers[todayNum];
  document.getElementById('date__word__month--today').innerHTML = info[languageGlobal].months[month - 1];
  document.getElementById('date__word__year--today').innerHTML = info[languageGlobal].years[year_word];

  document.getElementById('date__yesterday__label').innerHTML = info[languageGlobal].yesterday;
  document.getElementById('date__num__day--yesterday').innerHTML = yesterdayNum;
  document.getElementById('date__num__month--yesterday').innerHTML = month_y;
  document.getElementById('date__num__year--yesterday').innerHTML = year_y;

  document.getElementById('date__word__day--yesterday').innerHTML = info[languageGlobal].numbers[yesterdayNum];
  document.getElementById('date__word__month--yesterday').innerHTML = info[languageGlobal].months[month_y - 1];
  document.getElementById('date__word__year--yesterday').innerHTML = info[languageGlobal].years[year_y_word];

  document.getElementById('date__tomorrow__label').innerHTML = info[languageGlobal].tomorrow;
  document.getElementById('date__num__day--tomorrow').innerHTML = tomorrowNum;
  document.getElementById('date__num__month--tomorrow').innerHTML = month_t;
  document.getElementById('date__num__year--tomorrow').innerHTML = year_t;

  document.getElementById('date__word__day--tomorrow').innerHTML = info[languageGlobal].numbers[tomorrowNum];
  document.getElementById('date__word__month--tomorrow').innerHTML = info[languageGlobal].months[month_t - 1];
  document.getElementById('date__word__year--tomorrow').innerHTML = info[languageGlobal].years[year_t_word];

  // document.getElementById('cal__heading--month').innerHTML = info[languageGlobal].month;
  // document.getElementById('cal__heading--monthName').innerHTML = info[languageGlobal].months[month - 1];

  var t = setTimeout(startTime, 500);

}

function checkTime(i) {
  if (i < 10) {
    i = "0" + i
  }; // add zero in front of numbers < 10
  return i;
}

function weekNames(language) {
  for (var i = 0; i < 7; i++) {
    document.getElementById('cal__week__day--' + i).innerHTML = info[languageGlobal].days[i];
  };
  //add names to week in language
}

// create calendar day
function createDay(dayNumber, dayClass) {
  var h2 = document.createElement("h2");
  h2.className = "cal__days__day--num";
  h2.id = "h2__" + dayNumber;
  var h2Text = document.createTextNode(dayNumber);
  h2.appendChild(h2Text);

  var h3 = document.createElement("h3");
  h3.className = "cal__days__day--text";
  h3.id = "h3__" + dayNumber;
  var h3Text = document.createTextNode(info[languageGlobal].numbers[dayNumber]);
  h3.appendChild(h3Text);

  var h4 = document.createElement("h4");
  h4.className = "cal__days__day--ordinal";
  h4.id = "h4__" + dayNumber;
  var h4Text = document.createTextNode(info[languageGlobal].ordinals[dayNumber]);
  h4.appendChild(h4Text);

  var dayCard = document.createElement("div")
    // console.log(dayClass);
  if (dayClass) {
    dayCard.className = "cal__days__day " + dayClass;
  } else {
    dayCard.className = "cal__days__day ";
  }
  dayCard.appendChild(h2);
  dayCard.appendChild(h3);
  dayCard.appendChild(h4);

  // console.log(h3);
  // console.log(h4);
  // console.log(h5);

  document.getElementById("cal__days__grid").appendChild(dayCard)
}

function createSpacer(num) {
  var dayCard = document.createElement("div")
  dayCard.className = "cal__days__spacer";
  dayCard.id = "cal__days__spacer" + num;
  document.getElementById("cal__days__grid").appendChild(dayCard)
}

function createEndSpacer() {
  var dayCard = document.createElement("div")
  dayCard.className = "cal__days__spacer--end";

  document.getElementById("cal__days__grid").appendChild(dayCard)
}

function startCal() {
  var overallDate = masterDate();
  var today = overallDate.today;
  // var today = new Date();
  // var today = new Date("January 14, 2017");
  var year = today.getYear();
  if (year < 1000)
    year += 1900;
  var day = today.getDay() + 2;

  var month = today.getMonth() + 1;
  if (month < 10)
    month = "0" + month;
  var month1 = today.getMonth();
  var day1 = today.getDate();
  // console.log(day1);
  var firstDay = new Date(year, month1, 1);
  var firstDayNumber = firstDay.getDay();
  // console.log(mon + '3');
  if (mon === 'mon') {
    if (firstDayNumber === 0) {
      firstDayNumber = firstDayNumber + 6;
    } else {
      firstDayNumber = firstDayNumber - 1;
    }

  }

  var monthLength = monthDays(month1, year);
  // console.log(monthLength);

  var daysLeft = 42 - (monthLength + firstDayNumber);

  document.getElementById('cal__heading--month').innerHTML = info[languageGlobal].month;
  document.getElementById('cal__heading--monthName').innerHTML = info[languageGlobal].months[month - 1];

  //create calendar item for total number of days in month and add incrementing numbers in it
  if (runFirstTime) {
    for (var i = 1; i <= monthLength; i++) {
      if (i + firstDayNumber === 1) {
        if (i === day1) {
          createDay(i, 'cal__days__day--today');
        } else {
          createDay(i, 'cal__days__day--weekend');
        }
      } else if ((i + firstDayNumber) % 7 === 0) {
        if (i === day1) {
          createDay(i, 'cal__days__day--today');
        } else {
          createDay(i, 'cal__days__day--weekend');
        }
      } else if ((i + firstDayNumber) % 7 === 1) {
        if (i === day1) {
          createDay(i, 'cal__days__day--today');
        } else {
          createDay(i, 'cal__days__day--weekend');
        }
      } else {
        if (i === day1) {
          createDay(i, 'cal__days__day--today');
        } else {
          createDay(i);
        }
      }

    }
    for (var i = 0; i < firstDayNumber; i++) {
      createSpacer(i);
    }
    for (var i = 0; i < daysLeft; i++) {
      createEndSpacer();
    }
  }
  if (runFirstTime) {

  } else {
    for (var i = 1; i <= monthLength; i++) {
      document.getElementById("h3__" + i).innerHTML = info[languageGlobal].numbers[i];
      document.getElementById("h4__" + i).innerHTML = info[languageGlobal].ordinals[i];
    }
  }
  runFirstTime = false;
}
            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.
Loading ..................

Console