How to use endDate method in argos

Best JavaScript code snippet using argos

DateUtil.js

Source:DateUtil.js Github

copy

Full Screen

1/**2 * used in Core to convert the options into a volatile variable3 * 4 * @param {function} moment5 * @param {Object} body6 * @param {Array | Object} hiddenDates7 * @returns {number}8 */9exports.convertHiddenOptions = function(moment, body, hiddenDates) {10 if (hiddenDates && !Array.isArray(hiddenDates)) {11 return exports.convertHiddenOptions(moment, body, [hiddenDates])12 }13 body.hiddenDates = [];14 if (hiddenDates) {15 if (Array.isArray(hiddenDates) == true) {16 for (var i = 0; i < hiddenDates.length; i++) {17 if (hiddenDates[i].repeat === undefined) {18 var dateItem = {};19 dateItem.start = moment(hiddenDates[i].start).toDate().valueOf();20 dateItem.end = moment(hiddenDates[i].end).toDate().valueOf();21 body.hiddenDates.push(dateItem);22 }23 }24 body.hiddenDates.sort(function (a, b) {25 return a.start - b.start;26 }); // sort by start time27 }28 }29};30/**31 * create new entrees for the repeating hidden dates32 *33 * @param {function} moment34 * @param {Object} body35 * @param {Array | Object} hiddenDates36 * @returns {null}37 */38exports.updateHiddenDates = function (moment, body, hiddenDates) {39 if (hiddenDates && !Array.isArray(hiddenDates)) {40 return exports.updateHiddenDates(moment, body, [hiddenDates])41 }42 if (hiddenDates && body.domProps.centerContainer.width !== undefined) {43 exports.convertHiddenOptions(moment, body, hiddenDates);44 var start = moment(body.range.start);45 var end = moment(body.range.end);46 var totalRange = (body.range.end - body.range.start);47 var pixelTime = totalRange / body.domProps.centerContainer.width;48 for (var i = 0; i < hiddenDates.length; i++) {49 if (hiddenDates[i].repeat !== undefined) {50 var startDate = moment(hiddenDates[i].start);51 var endDate = moment(hiddenDates[i].end);52 if (startDate._d == "Invalid Date") {53 throw new Error("Supplied start date is not valid: " + hiddenDates[i].start);54 }55 if (endDate._d == "Invalid Date") {56 throw new Error("Supplied end date is not valid: " + hiddenDates[i].end);57 }58 var duration = endDate - startDate;59 if (duration >= 4 * pixelTime) {60 var offset = 0;61 var runUntil = end.clone();62 switch (hiddenDates[i].repeat) {63 case "daily": // case of time64 if (startDate.day() != endDate.day()) {65 offset = 1;66 }67 startDate.dayOfYear(start.dayOfYear());68 startDate.year(start.year());69 startDate.subtract(7,'days');70 endDate.dayOfYear(start.dayOfYear());71 endDate.year(start.year());72 endDate.subtract(7 - offset,'days');73 runUntil.add(1, 'weeks');74 break;75 case "weekly":76 var dayOffset = endDate.diff(startDate,'days');77 var day = startDate.day();78 // set the start date to the range.start79 startDate.date(start.date());80 startDate.month(start.month());81 startDate.year(start.year());82 endDate = startDate.clone();83 // force84 startDate.day(day);85 endDate.day(day);86 endDate.add(dayOffset,'days');87 startDate.subtract(1,'weeks');88 endDate.subtract(1,'weeks');89 runUntil.add(1, 'weeks');90 break;91 case "monthly":92 if (startDate.month() != endDate.month()) {93 offset = 1;94 }95 startDate.month(start.month());96 startDate.year(start.year());97 startDate.subtract(1,'months');98 endDate.month(start.month());99 endDate.year(start.year());100 endDate.subtract(1,'months');101 endDate.add(offset,'months');102 runUntil.add(1, 'months');103 break;104 case "yearly":105 if (startDate.year() != endDate.year()) {106 offset = 1;107 }108 startDate.year(start.year());109 startDate.subtract(1,'years');110 endDate.year(start.year());111 endDate.subtract(1,'years');112 endDate.add(offset,'years');113 runUntil.add(1, 'years');114 break;115 default:116 console.log("Wrong repeat format, allowed are: daily, weekly, monthly, yearly. Given:", hiddenDates[i].repeat);117 return;118 }119 while (startDate < runUntil) {120 body.hiddenDates.push({start: startDate.valueOf(), end: endDate.valueOf()});121 switch (hiddenDates[i].repeat) {122 case "daily":123 startDate.add(1, 'days');124 endDate.add(1, 'days');125 break;126 case "weekly":127 startDate.add(1, 'weeks');128 endDate.add(1, 'weeks');129 break;130 case "monthly":131 startDate.add(1, 'months');132 endDate.add(1, 'months');133 break;134 case "yearly":135 startDate.add(1, 'y');136 endDate.add(1, 'y');137 break;138 default:139 console.log("Wrong repeat format, allowed are: daily, weekly, monthly, yearly. Given:", hiddenDates[i].repeat);140 return;141 }142 }143 body.hiddenDates.push({start: startDate.valueOf(), end: endDate.valueOf()});144 }145 }146 }147 // remove duplicates, merge where possible148 exports.removeDuplicates(body);149 // ensure the new positions are not on hidden dates150 var startHidden = exports.isHidden(body.range.start, body.hiddenDates);151 var endHidden = exports.isHidden(body.range.end,body.hiddenDates);152 var rangeStart = body.range.start;153 var rangeEnd = body.range.end;154 if (startHidden.hidden == true) {rangeStart = body.range.startToFront == true ? startHidden.startDate - 1 : startHidden.endDate + 1;}155 if (endHidden.hidden == true) {rangeEnd = body.range.endToFront == true ? endHidden.startDate - 1 : endHidden.endDate + 1;}156 if (startHidden.hidden == true || endHidden.hidden == true) {157 body.range._applyRange(rangeStart, rangeEnd);158 }159 }160};161/**162 * remove duplicates from the hidden dates list. Duplicates are evil. They mess everything up.163 * Scales with N^2164 *165 * @param {Object} body166 */167exports.removeDuplicates = function(body) {168 var hiddenDates = body.hiddenDates;169 var safeDates = [];170 for (var i = 0; i < hiddenDates.length; i++) {171 for (var j = 0; j < hiddenDates.length; j++) {172 if (i != j && hiddenDates[j].remove != true && hiddenDates[i].remove != true) {173 // j inside i174 if (hiddenDates[j].start >= hiddenDates[i].start && hiddenDates[j].end <= hiddenDates[i].end) {175 hiddenDates[j].remove = true;176 }177 // j start inside i178 else if (hiddenDates[j].start >= hiddenDates[i].start && hiddenDates[j].start <= hiddenDates[i].end) {179 hiddenDates[i].end = hiddenDates[j].end;180 hiddenDates[j].remove = true;181 }182 // j end inside i183 else if (hiddenDates[j].end >= hiddenDates[i].start && hiddenDates[j].end <= hiddenDates[i].end) {184 hiddenDates[i].start = hiddenDates[j].start;185 hiddenDates[j].remove = true;186 }187 }188 }189 }190 for (i = 0; i < hiddenDates.length; i++) {191 if (hiddenDates[i].remove !== true) {192 safeDates.push(hiddenDates[i]);193 }194 }195 body.hiddenDates = safeDates;196 body.hiddenDates.sort(function (a, b) {197 return a.start - b.start;198 }); // sort by start time199};200exports.printDates = function(dates) {201 for (var i =0; i < dates.length; i++) {202 console.log(i, new Date(dates[i].start),new Date(dates[i].end), dates[i].start, dates[i].end, dates[i].remove);203 }204};205/**206 * Used in TimeStep to avoid the hidden times.207 * @param {function} moment208 * @param {TimeStep} timeStep209 * @param {Date} previousTime210 */211exports.stepOverHiddenDates = function(moment, timeStep, previousTime) {212 var stepInHidden = false;213 var currentValue = timeStep.current.valueOf();214 for (var i = 0; i < timeStep.hiddenDates.length; i++) {215 var startDate = timeStep.hiddenDates[i].start;216 var endDate = timeStep.hiddenDates[i].end;217 if (currentValue >= startDate && currentValue < endDate) {218 stepInHidden = true;219 break;220 }221 }222 if (stepInHidden == true && currentValue < timeStep._end.valueOf() && currentValue != previousTime) {223 var prevValue = moment(previousTime);224 var newValue = moment(endDate);225 //check if the next step should be major226 if (prevValue.year() != newValue.year()) {timeStep.switchedYear = true;}227 else if (prevValue.month() != newValue.month()) {timeStep.switchedMonth = true;}228 else if (prevValue.dayOfYear() != newValue.dayOfYear()) {timeStep.switchedDay = true;}229 timeStep.current = newValue;230 }231};232///**233// * Used in TimeStep to avoid the hidden times.234// * @param timeStep235// * @param previousTime236// */237//exports.checkFirstStep = function(timeStep) {238// var stepInHidden = false;239// var currentValue = timeStep.current.valueOf();240// for (var i = 0; i < timeStep.hiddenDates.length; i++) {241// var startDate = timeStep.hiddenDates[i].start;242// var endDate = timeStep.hiddenDates[i].end;243// if (currentValue >= startDate && currentValue < endDate) {244// stepInHidden = true;245// break;246// }247// }248//249// if (stepInHidden == true && currentValue <= timeStep._end.valueOf()) {250// var newValue = moment(endDate);251// timeStep.current = newValue.toDate();252// }253//};254/**255 * replaces the Core toScreen methods256 *257 * @param {vis.Core} Core258 * @param {Date} time259 * @param {number} width260 * @returns {number}261 */262exports.toScreen = function (Core, time, width) {263 var conversion;264 if (Core.body.hiddenDates.length == 0) {265 conversion = Core.range.conversion(width);266 return (time.valueOf() - conversion.offset) * conversion.scale;267 } else {268 var hidden = exports.isHidden(time, Core.body.hiddenDates);269 if (hidden.hidden == true) {270 time = hidden.startDate;271 }272 var duration = exports.getHiddenDurationBetween(Core.body.hiddenDates, Core.range.start, Core.range.end);273 if (time < Core.range.start) {274 conversion = Core.range.conversion(width, duration);275 var hiddenBeforeStart = exports.getHiddenDurationBeforeStart(Core.body.hiddenDates, time, conversion.offset);276 time = Core.options.moment(time).toDate().valueOf();277 time = time + hiddenBeforeStart;278 return -(conversion.offset - time.valueOf()) * conversion.scale;279 280 } else if (time > Core.range.end) {281 var rangeAfterEnd = {start: Core.range.start, end: time};282 time = exports.correctTimeForHidden(Core.options.moment, Core.body.hiddenDates, rangeAfterEnd, time);283 conversion = Core.range.conversion(width, duration);284 return (time.valueOf() - conversion.offset) * conversion.scale;285 } else {286 time = exports.correctTimeForHidden(Core.options.moment, Core.body.hiddenDates, Core.range, time);287 conversion = Core.range.conversion(width, duration);288 return (time.valueOf() - conversion.offset) * conversion.scale;289 }290 }291 };292/**293 * Replaces the core toTime methods294 *295 * @param {vis.Core} Core296 * @param {number} x297 * @param {number} width298 * @returns {Date}299 */300exports.toTime = function(Core, x, width) {301 if (Core.body.hiddenDates.length == 0) {302 var conversion = Core.range.conversion(width);303 return new Date(x / conversion.scale + conversion.offset);304 }305 else {306 var hiddenDuration = exports.getHiddenDurationBetween(Core.body.hiddenDates, Core.range.start, Core.range.end);307 var totalDuration = Core.range.end - Core.range.start - hiddenDuration;308 var partialDuration = totalDuration * x / width;309 var accumulatedHiddenDuration = exports.getAccumulatedHiddenDuration(Core.body.hiddenDates, Core.range, partialDuration);310 return new Date(accumulatedHiddenDuration + partialDuration + Core.range.start);311 }312};313/**314 * Support function315 *316 * @param {Array.<{start: Window.start, end: *}>} hiddenDates317 * @param {number} start318 * @param {number} end319 * @returns {number}320 */321exports.getHiddenDurationBetween = function(hiddenDates, start, end) {322 var duration = 0;323 for (var i = 0; i < hiddenDates.length; i++) {324 var startDate = hiddenDates[i].start;325 var endDate = hiddenDates[i].end;326 // if time after the cutout, and the327 if (startDate >= start && endDate < end) {328 duration += endDate - startDate;329 }330 }331 return duration;332};333/**334 * Support function335 *336 * @param {Array.<{start: Window.start, end: *}>} hiddenDates337 * @param {number} start338 * @param {number} end339 * @returns {number}340 */341exports.getHiddenDurationBeforeStart = function (hiddenDates, start, end) {342 var duration = 0;343 for (var i = 0; i < hiddenDates.length; i++) {344 var startDate = hiddenDates[i].start;345 var endDate = hiddenDates[i].end;346 if (startDate >= start && endDate <= end) {347 duration += endDate - startDate;348 }349 }350 return duration;351};352/**353 * Support function354 * @param {function} moment355 * @param {Array.<{start: Window.start, end: *}>} hiddenDates356 * @param {{start: number, end: number}} range357 * @param {Date} time358 * @returns {number}359 */360exports.correctTimeForHidden = function(moment, hiddenDates, range, time) {361 time = moment(time).toDate().valueOf();362 time -= exports.getHiddenDurationBefore(moment, hiddenDates,range,time);363 return time;364};365exports.getHiddenDurationBefore = function(moment, hiddenDates, range, time) {366 var timeOffset = 0;367 time = moment(time).toDate().valueOf();368 for (var i = 0; i < hiddenDates.length; i++) {369 var startDate = hiddenDates[i].start;370 var endDate = hiddenDates[i].end;371 // if time after the cutout, and the372 if (startDate >= range.start && endDate < range.end) {373 if (time >= endDate) {374 timeOffset += (endDate - startDate);375 }376 }377 }378 return timeOffset;379};380/**381 * sum the duration from start to finish, including the hidden duration,382 * until the required amount has been reached, return the accumulated hidden duration383 * @param {Array.<{start: Window.start, end: *}>} hiddenDates384 * @param {{start: number, end: number}} range385 * @param {number} [requiredDuration=0]386 * @returns {number}387 */388exports.getAccumulatedHiddenDuration = function(hiddenDates, range, requiredDuration) {389 var hiddenDuration = 0;390 var duration = 0;391 var previousPoint = range.start;392 //exports.printDates(hiddenDates)393 for (var i = 0; i < hiddenDates.length; i++) {394 var startDate = hiddenDates[i].start;395 var endDate = hiddenDates[i].end;396 // if time after the cutout, and the397 if (startDate >= range.start && endDate < range.end) {398 duration += startDate - previousPoint;399 previousPoint = endDate;400 if (duration >= requiredDuration) {401 break;402 }403 else {404 hiddenDuration += endDate - startDate;405 }406 }407 }408 return hiddenDuration;409};410/**411 * used to step over to either side of a hidden block. Correction is disabled on tablets, might be set to true412 * @param {Array.<{start: Window.start, end: *}>} hiddenDates413 * @param {Date} time414 * @param {number} direction415 * @param {boolean} correctionEnabled416 * @returns {Date|number}417 */418exports.snapAwayFromHidden = function(hiddenDates, time, direction, correctionEnabled) {419 var isHidden = exports.isHidden(time, hiddenDates);420 if (isHidden.hidden == true) {421 if (direction < 0) {422 if (correctionEnabled == true) {423 return isHidden.startDate - (isHidden.endDate - time) - 1;424 }425 else {426 return isHidden.startDate - 1;427 }428 }429 else {430 if (correctionEnabled == true) {431 return isHidden.endDate + (time - isHidden.startDate) + 1;432 }433 else {434 return isHidden.endDate + 1;435 }436 }437 }438 else {439 return time;440 }441};442/**443 * Check if a time is hidden444 *445 * @param {Date} time446 * @param {Array.<{start: Window.start, end: *}>} hiddenDates447 * @returns {{hidden: boolean, startDate: Window.start, endDate: *}}448 */449exports.isHidden = function(time, hiddenDates) {450 for (var i = 0; i < hiddenDates.length; i++) {451 var startDate = hiddenDates[i].start;452 var endDate = hiddenDates[i].end;453 if (time >= startDate && time < endDate) { // if the start is entering a hidden zone454 return {hidden: true, startDate: startDate, endDate: endDate};455 }456 }457 return {hidden: false, startDate: startDate, endDate: endDate};...

Full Screen

Full Screen

eventsDate.pipe.ts

Source:eventsDate.pipe.ts Github

copy

Full Screen

1import { Pipe, PipeTransform } from '@angular/core';2import * as moment from 'moment';3@Pipe({ name: 'eventsDate' })4export class EventsDatePipe implements PipeTransform { 5 transform(value: string, eventEndDate: string, localeAndDateFormat: any) { 6 let date = '';7 if (value !== undefined && eventEndDate !== undefined && localeAndDateFormat !== undefined) { 8 let startDate = moment.utc(value).locale(localeAndDateFormat.locale); 9 let endDate = moment.utc(eventEndDate).locale(localeAndDateFormat.locale);10 11 12 if (startDate.get('year') == endDate.get('year')) {13 if (startDate.get('month') == endDate.get('month')) {14 if (startDate.get('date') == endDate.get('date')) {15 date = startDate.format(localeAndDateFormat.format);16 17 18 } else {19 date = startDate.format('MMMM DD') + '-' + endDate.format('DD') + ', ' + startDate.get('year'); 20 } 21 } else {22 date = startDate.format('MMMM DD') + '-' + endDate.format('MMMM DD') + ', ' + startDate.get('year');23 } 24 } else { 25 date = startDate.format(localeAndDateFormat.format) + '-' + endDate.format(localeAndDateFormat.format);26 }27 if (localeAndDateFormat.locale == 'es') {28 date = date.charAt(0).toUpperCase() + date.slice(1);29 }30 31 if (localeAndDateFormat.locale == 'ja' || localeAndDateFormat.locale == 'zh') {32 if (startDate.get('year') == endDate.get('year')) {33 if (startDate.get('month') == endDate.get('month')) {34 if (startDate.get('date') == endDate.get('date')) {35 date = startDate.format(localeAndDateFormat.format);36 } else {37 date = startDate.get('year')+"年"+startDate.format('M')+'月'+startDate.format('D') + '-' + endDate.format('D') + '日'; 38 39 } 40 } else {41 date = startDate.get('year')+"年"+startDate.format('M')+'月'+startDate.format('D') + '日'+ '-' +endDate.format('M')+'月'+endDate.format('D') + '日';42 43 } 44 } else { 45 date = startDate.get('year')+"年"+startDate.format('M')+'月'+startDate.format('D') + '日'+ '-'+endDate.get('year')+"年" +endDate.format('M')+'月'+endDate.format('D') + '日';46 }47 }48 if (localeAndDateFormat.locale == 'fr') {49 if (startDate.get('year') == endDate.get('year')) {50 if (startDate.get('month') == endDate.get('month')) {51 if (startDate.get('date') == endDate.get('date')) {52 date = startDate.format(localeAndDateFormat.format);53 54 } else {55 date = startDate.format('DD') + ' - ' + endDate.format('DD') + ' '+startDate.format('MMMM') +' ' + startDate.get('year'); 56 } 57 } else {58 date = startDate.format('DD') + ' '+startDate.format('MMMM') + ' - ' + endDate.format('DD') +' ' +endDate.format('MMMM')+' ' +startDate.get('year'); 59 60 } 61 } else { 62 date = startDate.format('DD') + ' '+startDate.format('MMMM') +' ' +startDate.get('year')+ ' - ' + endDate.format('DD') +' ' +endDate.format('MMMM')+' ' +endDate.get('year'); 63 }64 }65 if (localeAndDateFormat.locale == 'ru') {66 if (startDate.get('year') == endDate.get('year')) {67 if (startDate.get('month') == endDate.get('month')) {68 if (startDate.get('date') == endDate.get('date')) {69 date = startDate.format(localeAndDateFormat.format);70 71 } else {72 date = startDate.format('D') + '-' + endDate.format('D') + ' '+startDate.format('MMMM') +' ' + startDate.get('year'); 73 } 74 } else {75 date = startDate.format('D') + ' '+startDate.format('MMMM') + '-' + endDate.format('D') +' ' +endDate.format('MMMM')+' ' +startDate.get('year'); 76 77 } 78 } else { 79 date = startDate.format('D') + ' '+startDate.format('MMMM') +' ' +startDate.get('year')+ '-' + endDate.format('D') +' ' +endDate.format('MMMM')+' ' +endDate.get('year'); 80 }81 }82 if (localeAndDateFormat.locale == 'ar') {83 startDate = moment.utc(value).locale('ar-tn'); 84 endDate = moment.utc(eventEndDate).locale('ar-tn');85 if (startDate.get('year') == endDate.get('year')) {86 if (startDate.get('month') == endDate.get('month')) {87 if (startDate.get('date') == endDate.get('date')) {88 89 date =startDate.get('year') +"/"+(startDate.get('month') + 1) +"/"+ ('0' + startDate.get('date')).slice(-2);90 91 } else {92 date = ('0' + endDate.get('date')).slice(-2) + ' - ' + ('0' + startDate.get('date')).slice(-2) + ' '+startDate.format('MMMM') +' ' + startDate.get('year'); 93 } 94 } else {95 date = ('0' + startDate.get('date')).slice(-2) + ' '+startDate.format('MMMM') +' إلى '+ ('0' + endDate.get('date')).slice(-2) +' ' +endDate.format('MMMM')+' ' +startDate.get('year'); 96 97 } 98 } else { 99 date = ('0' + startDate.get('date')).slice(-2) + ' '+startDate.format('MMMM') +' ' +startDate.get('year')+' إلى '+ ('0' + endDate.get('date')).slice(-2) +' ' +endDate.format('MMMM')+' ' +endDate.get('year'); 100 } 101}102if (localeAndDateFormat.locale == 'pt') {103 if (startDate.get('year') == endDate.get('year')) {104 if (startDate.get('month') == endDate.get('month')) {105 if (startDate.get('date') == endDate.get('date')) {106 date = startDate.format('DD') + ' de '+startDate.format('MMMM') +' de ' + startDate.get('year'); 107 108 } else {109 date = startDate.format('DD') + ' - ' + endDate.format('DD') + ' de '+startDate.format('MMMM') +' de ' + startDate.get('year'); 110 } 111 } else {112 date = startDate.format('DD') + ' de '+startDate.format('MMMM') + ' - ' + endDate.format('DD') +' de ' +endDate.format('MMMM')+' de ' +startDate.get('year'); 113 114 } 115 } else { 116 date = startDate.format('DD') + ' de '+startDate.format('MMMM') +' de ' +startDate.get('year')+ ' - ' + endDate.format('DD') +' de ' +endDate.format('MMMM')+' de ' +endDate.get('year'); 117 }118}119if (localeAndDateFormat.locale == 'vi') {120 let startMonth = startDate.format('MMMM');121 let endMonth = endDate.format('MMMM');122 startMonth = startMonth.charAt(0).toUpperCase() + startMonth.slice(1);123 endMonth = endMonth.charAt(0).toUpperCase() + endMonth.slice(1);124 if (startDate.get('year') == endDate.get('year')) {125 if (startDate.get('month') == endDate.get('month')) {126 if (startDate.get('date') == endDate.get('date')) {127 date = startDate.format('D ') + startMonth+' Năm ' + startDate.get('year'); 128 } else {129 date = 'Ngày '+ startDate.format('D') +'-' + endDate.format('D ')+startMonth +' Năm ' + startDate.get('year'); 130 131 } 132 } else {133 date = 'Ngày '+ startDate.format('D ') +startMonth + ' - ' +'Ngày '+ endDate.format('D ') +endMonth+' Năm ' +startDate.get('year'); 134 135 } 136} else { 137 date = 'Ngày '+ startDate.format('D ') +startMonth +' Năm ' +startDate.get('year')+ ' - ' +'Ngày '+ endDate.format('D ') +endMonth+' Năm ' +endDate.get('year'); 138}139}140if (localeAndDateFormat.locale == 'sq' || localeAndDateFormat.locale == 'ro' || localeAndDateFormat.locale == 'bg' || localeAndDateFormat.locale == 'pl' || localeAndDateFormat.locale == 'tr' || localeAndDateFormat.locale == 'th' || localeAndDateFormat.locale == 'id' || localeAndDateFormat.locale == 'mk') {141 142 let startYear = startDate.get('year');143 let endYear = endDate.get('year');144 if(localeAndDateFormat.locale == 'th')145 {146 startYear = startYear + 543;147 endYear = endYear + 543;148 }149 let startMonth = startDate.format('MMMM');150 let endMonth = endDate.format('MMMM');151 if(localeAndDateFormat.locale != 'tr')152 {153 startMonth = startDate.format('MMMM').toLowerCase();154 endMonth = endDate.format('MMMM').toLowerCase();155 }156 if (startDate.get('year') == endDate.get('year')) {157 if (startDate.get('month') == endDate.get('month')) {158 if (startDate.get('date') == endDate.get('date')) {159 if(localeAndDateFormat.locale != 'tr')160 date = startDate.format(localeAndDateFormat.format).toLowerCase();161 if(localeAndDateFormat.locale == 'th')162 date = 'วันที่ ' + startDate.format('DD')+ startMonth + ' ' + startYear; 163 } else {164 date = startDate.format('DD') + '-' +endDate.format('DD')+ ' '+startMonth+ ' ' + startYear; 165 } 166 } else {167 date = startDate.format('DD')+ ' ' + startMonth + '-' + endDate.format('DD')+ ' '+ endMonth+ ' ' + startYear;168 } 169} else { 170 date = startDate.format('DD')+ ' '+ startMonth+ ' ' + startYear + '-' + endDate.format('DD')+ ' '+ endMonth+ ' ' + startYear; 171 172 if(localeAndDateFormat.locale == 'th')173 date = startDate.format('DD MMMM').toLowerCase()+ ' ' + startYear+'-' + endDate.format('DD MMMM').toLowerCase() + ' ' + endYear;174}175}176 177 } 178 return date;179 }...

Full Screen

Full Screen

daterangecustom.js

Source:daterangecustom.js Github

copy

Full Screen

1'use strict';23function customDaterangeFormat () {4 var sessionDateFinal = sessionDate.toUpperCase(); 5 var sepSign = "-";67 var dateFormat = 'YYYY M D';8 var showDateFormat = 'YYYY M D';910 if (sessionDateFinal.includes("/")){11 sepSign = '/';12 } else if (sessionDateFinal.includes(".")) {13 sepSign = '.';14 } else {15 sepSign = '-';16 }1718 var dateSep = dateFormat.replace(/ /g,sepSign);1920 switch(sessionDateFinal) {21 case 'YYYY' + sepSign + 'MM' + sepSign + 'DD':22 showDateFormat = 'YYYY M D';23 dateSep = showDateFormat.replace(/ /g,sepSign);24 break;25 case 'DD' + sepSign + 'MM' + sepSign + 'YYYY':26 showDateFormat = 'D M YYYY';27 dateSep = showDateFormat.replace(/ /g,sepSign);28 break;2930 case 'MM' + sepSign + 'DD' + sepSign+ 'YYYY':31 showDateFormat = 'M D YYYY';32 dateSep = showDateFormat.replace(/ /g,sepSign);33 break;34 case 'DD' + sepSign + 'M' + sepSign + 'YYYY':35 showDateFormat = 'D MMM YYYY';36 dateSep = showDateFormat.replace(/ /g,sepSign);37 break;3839 case 'YYYY' + sepSign + 'M' + sepSign + 'DD':40 showDateFormat = 'YYYY MMM D';41 dateSep = showDateFormat.replace(/ /g,sepSign);42 break;43 default:44 45 }4647 return {48 dateFormat: dateFormat, 49 showDateFormat: showDateFormat,50 sepSign:sepSign,51 dateSep:dateSep,52 }; 53}5455function dateRangeBtn (startDate, endDate,dt=null) {56 var df = dt;57 var customFormat = customDaterangeFormat();58 if(startDate == undefined || !startDate){59 var startDate = moment();60 startDate = moment(startDate, customFormat.showDateFormat);61 var endDate = moment();62 endDate = moment(endDate, customFormat.showDateFormat);63 } else {64 startDate = moment(startDate, customFormat.showDateFormat);65 endDate = moment(endDate, customFormat.showDateFormat);66 }6768 var init = moment();69 var initdate;70 if(dt == 1) {71 init = moment(0);72 initdate = moment(init, customFormat.dateFormat);73 var today = moment();74 today = moment(today, customFormat.dateFormat);7576 $('#daterange-btn').daterangepicker({77 ranges : {78 'Anytime' : [moment(0),moment()],79 'Today' : [moment(), moment()],80 'Yesterday' : [moment().subtract(1, 'days'), moment().subtract(1, 'days')],81 'Last 7 Days' : [moment().subtract(6, 'days'), moment()],82 'Last 30 Days': [moment().subtract(29, 'days'), moment()],83 'This Month' : [moment().startOf('month'), moment().endOf('month')],84 'Last Month' : [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month').endOf('month')]85 },86 "autoApply": true,87 "startDate": startDate,88 "endDate": endDate,89 "minDate": initdate,90 "drops": "auto",91 }, function(start, end) {92 93 var startDate = moment(start, customFormat.showDateFormat).format(customFormat.dateSep);94 $("#startDate").val(startDate);95 var endDate = moment(end, customFormat.showDateFormat).format(customFormat.dateSep);96 $("#endDate").val(endDate);97 initdate = moment(initdate, customFormat.showDateFormat).format(customFormat.dateSep);98 today = moment(today, customFormat.showDateFormat).format(customFormat.dateSep);99 if (startDate == 'undefined' || endDate == 'undefined') {100 $('#daterange-btn span').html('Pick a date range');101 } else if (startDate == '' || endDate == '' || (startDate === initdate && endDate === today )) {102 $('#daterange-btn span').html('Anytime');103 104 } else {105 startDate = moment(startDate, customFormat.showDateFormat).format(customFormat.dateSep);106 endDate = moment(endDate, customFormat.showDateFormat).format(customFormat.dateSep);107 $("#startDate").val(startDate);108 $("#endDate").val(endDate);109 $('#daterange-btn span').text(startDate + '-' + endDate );110 }111 });112 } else {113 initdate = moment(init, customFormat.dateFormat);114 $('#daterange-btn').daterangepicker({115 "autoApply": true,116 "alwaysShowCalendars": true,117 "startDate": startDate,118 "endDate": endDate,119 "minDate": initdate,120 "drops": "auto",121 }, function(start, end) {122 123 var startDate = moment(start, customFormat.showDateFormat).format(customFormat.dateSep);124 $("#startDate").val(startDate);125 var endDate = moment(end, customFormat.showDateFormat).format(customFormat.dateSep);126 $("#endDate").val(endDate);127 if(startDate=='' && endDate==''){128 $('#daterange-btn span').html('<i class="fa fa-calendar"></i> &nbsp;&nbsp; Pick a date range');129 } else {130 131 startDate = moment(startDate, customFormat.showDateFormat).format(customFormat.dateSep);132 endDate = moment(endDate, customFormat.showDateFormat).format(customFormat.dateSep);133 $("#startDate").val(startDate);134 $("#endDate").val(endDate);135 // $('#daterange-btn span').text(startDate + '-' + endDate );136 if(df == 'single') {137 price_calculation('', '', '');138 }139 }140 });141 }142}143144145function formDate (startDate, endDate) {146 var customFormat = customDaterangeFormat();147 var init = moment(0);148 var initdate;149 initdate = moment(init, customFormat.showDateFormat).format(customFormat.dateSep);150 var today = moment();151 today = moment(today, customFormat.showDateFormat).format(customFormat.dateSep);152153154155 if(startDate == undefined || !startDate){156 var startDate = moment();157 startDate = moment(startDate, customFormat.showDateFormat).format(customFormat.dateSep);158 var endDate = moment();159 endDate = moment(endDate, customFormat.showDateFormat).format(customFormat.dateSep);160 } else {161 startDate = moment(startDate, customFormat.showDateFormat).format(customFormat.dateSep);162 endDate = moment(endDate, customFormat.showDateFormat).format(customFormat.dateSep);163 }164 165 if (startDate == 'undefined' || endDate == 'undefined') {166 $('#daterange-btn span').html('Pick a date range');167 } else if (startDate == '' || endDate == '' || (startDate === initdate && endDate === today )) {168 $('#daterange-btn span').html('Anytime');169 170 } else {171 startDate = moment(startDate, customFormat.showDateFormat).format(customFormat.dateSep);172 endDate = moment(endDate, customFormat.showDateFormat).format(customFormat.dateSep);173 $("#startDate").val(startDate);174 $("#endDate").val(endDate);175 $('#daterange-btn span').text(startDate + '-' + endDate );176 } ...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1define('Mobile/SalesLogix/Views/Activity/List', [2], function(3) {4 return declare('Mobile.SalesLogix.Views.Activity.List', [List, _RightDrawerListMixin], {5 itemTemplate: new Simplate([6 '<h3>{%: $.Description %}</h3>',7 '{% if ($.Type === "atToDo") { %}',8 '{%: $.Timeless ? $$.timelessText : $$.startingText %}',9 '{% } else { %}',10 '{%: $.Timeless ? $$.timelessText : $$.startingText %}',11 '{% } %}',12 '{% if ($.Type === "atToDo") { %}',13 '{%: $.Timeless ? $$.timelessText : $$.endingText %}',14 '{% } else { %}',15 '{%: $.Timeless ? $$.timelessText : $$.endingText %}',16 '{% } %}',17 hashTagQueriesText: {

Full Screen

Using AI Code Generation

copy

Full Screen

1define([2], function(3) {4 var widget = new DateRangeWidget();5});6define([7], function(8) {9 var widget = declare('test', [DateRangeWidget])();10});

Full Screen

Using AI Code Generation

copy

Full Screen

1var argosy = require('argosy')2var argosyPattern = require('argosy-pattern')3var argosyEndDate = require('argosy-end-date')4var pattern = argosyPattern({5 foo: { bar: 'string' }6})7var service = argosy()8service.pipe(argosyEndDate()).pipe(service)9service.accept(pattern, function (msg, cb) {10 cb(null, { bar: msg.foo.bar })11})12service.on('error', function (err) {13 console.error(err.stack)14})15service.on('ready', function () {16 service.endDate(new Date(2017, 2, 3), function (err) {17 if (err) {18 console.error(err.stack)19 }20 else {21 console.log('end date set')22 }23 })24})

Full Screen

Using AI Code Generation

copy

Full Screen

1var argosy = require('argosy')2var pattern = require('argosy-pattern')3var argosyRpc = require('argosy-rpc')4var argosyPipeline = require('argosy-pipeline')5var argosyReceiver = require('argosy-receiver')6var argosySender = require('argosy-sender')7var argosyKv = require('argosy-kv')8var argosyEnd = require('argosy-end')9var pipeline = argosyPipeline()10var receiver = argosyReceiver()11var sender = argosySender()12var kv = argosyKv()13var end = argosyEnd()14var service = argosy()15 .use(argosyRpc({ timeout: 1000 }))16 .use(pipeline)17 .use(kv)18 .use(end)19 .use('echo', function (msg, cb) {20 cb(null, msg)21 })22 .use('echo', pattern({23 }), function (msg, cb) {24 cb(null, msg)25 })26 .use('echo', pattern({27 }), function (msg, cb) {28 cb(new Error('error'))29 })30 .use('echo', pattern({31 }), function (msg, cb) {32 setTimeout(function () {33 cb(null, msg)34 }, 2000)35 })36 .use('echo', pattern({37 }), function (msg, cb) {38 cb(null, msg)39 })40service.listen(8000)41var client = argosy()42 .use(argosyRpc({ timeout: 1000 }))43 .use(pipeline)44 .use(kv)45 .use(end)46 .use('echo', function (msg, cb) {47 cb(null, msg)48 })49 .use('echo', pattern({50 }), function (msg, cb) {51 cb(null, msg)52 })53 .use('echo', pattern({54 }), function (msg, cb) {55 cb(new Error('error'))56 })57 .use('echo', pattern({

Full Screen

Using AI Code Generation

copy

Full Screen

1define('test', ['argos-sdk'], function (sdk) {2 var _endDate = sdk.Utility.endDate;3 var _startDate = sdk.Utility.startDate;4 var _formatDate = sdk.Utility.formatDate;5 describe('Utility', function () {6 it('should be able to get the end date of the current month', function () {7 var endDate = _endDate();8 var date = new Date();9 expect(endDate.getMonth()).toEqual(date.getMonth());10 expect(endDate.getFullYear()).toEqual(date.getFullYear());11 expect(endDate.getDate()).toEqual(1);12 });13 it('should be able to get the start date of the current month', function () {14 var startDate = _startDate();15 var date = new Date();16 expect(startDate.getMonth()).toEqual(date.getMonth());17 expect(startDate.getFullYear()).toEqual(date.getFullYear());18 expect(startDate.getDate()).toEqual(1);19 });20 it('should be able to get the end date of the current month', function () {21 var endDate = _endDate(new Date(2015, 0, 1));22 expect(endDate.getMonth()).toEqual(0);23 expect(endDate.getFullYear()).toEqual(2015);24 expect(endDate.getDate()).toEqual(1);25 });26 it('should be able to get the start date of the current month', function () {27 var startDate = _startDate(new Date(2015, 0, 1));28 expect(startDate.getMonth()).toEqual(0);29 expect(startDate.getFullYear()).toEqual(2015);30 expect(startDate.getDate()).toEqual(1);31 });32 it('should be able to format the date', function () {33 var date = new Date(2015, 0, 1);34 var formattedDate = _formatDate(date, true);35 expect(formattedDate).toEqual('01/01/2015');36 });37 it('should be able to format the date', function () {38 var date = new Date(2015, 0, 1);39 var formattedDate = _formatDate(date, false);40 expect(formattedDate).toEqual('01/01/2015');41 });42 });43});

Full Screen

Using AI Code Generation

copy

Full Screen

1define('test', [2], function(3) {4 return declare('test', null, {5 constructor: function() {6 var date = sdk.Utility.endDate();7 console.log(date);8 }9 });10});

Full Screen

Using AI Code Generation

copy

Full Screen

1import Activity from 'argos-sdk/Models/Activity';2var activity = new Activity();3activity.endDate();4### Activity#endDate()5### Activity#isEnded()6### Activity#isStarted()7### Activity#reset()8### Activity#setDuration()9### Activity#setNotes()10### Activity#setOptions()11### Activity#setResourceKind()12### Activity#setResourceName()13### Activity#setResourceProperty()14### Activity#setResult()15### Activity#setStartDate()16### Activity#setUser()17### Activity#start()18### Activity#setResourceProperty()19### Activity#setResult()20### Activity#setStartDate()21### Activity#setUser()22### Activity#start()

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run argos automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful