Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- module.exports = function () {
- var dateTime = {
- days: [],
- months: [],
- years: [],
- hours: [],
- minutes: [],
- start: new DateTime('1', '1', '2017', '1', '0'),
- end: new DateTime('2', '1', '2017', '1', '0')
- }
- // setup values for dates and time
- for (var i = 1; i < 32; i++) {
- dateTime.days.push(i.toString())
- }
- for (var i = 1; i < 13; i++) {
- dateTime.months.push(i.toString())
- }
- for (var i = 2010; i < 2026; i++) {
- dateTime.years.push(i.toString())
- }
- for (var i = 0; i < 24; i++) {
- dateTime.hours.push(i.toString())
- }
- for (var i = 0; i < 60; i++) {
- dateTime.minutes.push(i.toString())
- }
- return dateTime
- }
- var DateTime = module.exports.DateTime = function (day, month, year, hour, minute) {
- this.day = day ? day : 1
- this.month = month ? month : 1
- this.year = year ? year : 2017
- this.hour = hour ? hour : 12
- this.minute = minute ? minute : 0
- this.months = [
- 'NotAMonth',
- 'JAN',
- 'FEB',
- 'MAR',
- 'APR',
- 'MAY',
- 'JUN',
- 'JUL',
- 'AUG',
- 'SEP',
- 'OCT',
- 'NOV',
- 'DEC'
- ]
- this.timeFormat = function(z) {
- return ('0' + z).slice(-2)
- }
- this.toString = function() {
- var str =
- this.timeFormat(this.day) +
- '-' +
- this.months[this.month] +
- '-' +
- this.year +
- ' ' +
- this.timeFormat(this.hour) +
- ':' +
- this.timeFormat(this.minute) +
- ':00.00 ' +
- (this.hour < 12 ? 'AM' : 'PM')
- return str
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement