gl-w-frontend
Advanced tools
Comparing version 1.3.8 to 1.3.10
@@ -116,4 +116,4 @@ /// <reference types="moment-range" /> | ||
dateFromDatePicker: (date: import("moment").MomentInput, format?: string, outputFormat?: string) => string; | ||
localDateForDatePicker: (date: import("moment").MomentInput, outputFormat?: string) => any; | ||
currentDateForDatePicker: (dateFormat?: string, outputFormat?: string) => any; | ||
localDateForDatePicker: (date: import("moment").MomentInput, outputFormat?: string) => string; | ||
currentDateForDatePicker: (dateFormat?: string, outputFormat?: string) => string; | ||
dateForDatePicker: (month: number, day: number, year: number) => string; | ||
@@ -120,0 +120,0 @@ }; |
@@ -1,4 +0,3 @@ | ||
/// <reference types="moment-range" /> | ||
import 'node_modules/jquery-ui-dist/jquery-ui.min'; | ||
import 'moment/min/locale.min.js'; | ||
import * as moment from 'moment'; | ||
import { IDateLocal, IDayMonthYear, IDaysOfMonth, IWeeksOfMonth } from './core-services-date.interface'; | ||
@@ -8,14 +7,14 @@ /** | ||
*/ | ||
export declare const customDate: (date: import("moment").MomentInput, format: string) => string; | ||
export declare const customDate: (date: moment.MomentInput, format: string) => string; | ||
export declare const currentDate: (outputFormat?: string) => string; | ||
export declare const dayMonthYear: (date: import("moment").MomentInput, format?: string) => IDayMonthYear; | ||
export declare const dayMonthYear: (date: moment.MomentInput, format?: string) => IDayMonthYear; | ||
export declare const localDate: (year: number, month: number, day: number, local?: IDateLocal) => string; | ||
export declare const dateFromIso: (date: import("moment").MomentInput, format?: string) => string; | ||
export declare const ganttDate: (date: import("moment").MomentInput) => Date; | ||
export declare const isoDateCustom: (date: import("moment").MomentInput, dateFormat: string, outputFormat: string) => string; | ||
export declare const isoDate: (date: import("moment").MomentInput, format?: string) => string; | ||
export declare const isoDateWithoutTime: (date: import("moment").MomentInput) => string; | ||
export declare const dateMilliseconds: (date: import("moment").MomentInput, dateFormat: string, outputFormat: string) => number; | ||
export declare const dateToMillisecondsNoTime: (date: import("moment").MomentInput) => number; | ||
export declare const millisecondsToDate: (date: import("moment").MomentInput, outputFormat: string) => string; | ||
export declare const dateFromIso: (date: moment.MomentInput, format?: string) => string; | ||
export declare const ganttDate: (date: moment.MomentInput) => Date; | ||
export declare const isoDateCustom: (date: moment.MomentInput, dateFormat: string, outputFormat: string) => string; | ||
export declare const isoDate: (date: moment.MomentInput, format?: string) => string; | ||
export declare const isoDateWithoutTime: (date: moment.MomentInput) => string; | ||
export declare const dateMilliseconds: (date: moment.MomentInput, dateFormat: string, outputFormat: string) => number; | ||
export declare const dateToMillisecondsNoTime: (date: moment.MomentInput) => number; | ||
export declare const millisecondsToDate: (date: moment.MomentInput, outputFormat: string) => string; | ||
export declare const daysToMilliseconds: (days: number) => number; | ||
@@ -31,16 +30,20 @@ export declare const durationInDays: (start: number, end: number, countFirstDay: boolean) => number; | ||
*/ | ||
export declare const isDateBefore: (startDate: string, endDate: string, type?: import("moment").unitOfTime.StartOf) => boolean; | ||
export declare const isDateBefore: (startDate: string, endDate: string, type?: moment.unitOfTime.StartOf) => boolean; | ||
/** | ||
* Date validation | ||
*/ | ||
export declare const validateDate: (date: import("moment").MomentInput) => boolean; | ||
export declare const validateDate: (date: moment.MomentInput) => boolean; | ||
/** | ||
* Date picker utilities; | ||
* Jquery ui | ||
* This function is using Jquery and Jquery-ui and typescript is not available | ||
* To this function work is necessary the following imports, respectively: | ||
* import * as $ from 'jquery'; or import $ = require('jquery'); | ||
* import '../../../../../node_modules/jquery-ui-dist/jquery-ui.min'; | ||
*/ | ||
export declare const setDatePicker: (datePicker: HTMLInputElement, dateFormat: string) => void; | ||
export declare const monthYearDatePicker: (datePicker: HTMLInputElement, dateFormat: string, setValueCallback: any) => void; | ||
export declare const dateFromDatePicker: (date: import("moment").MomentInput, format?: string, outputFormat?: string) => string; | ||
export declare const localDateForDatePicker: (date: import("moment").MomentInput, outputFormat?: string) => any; | ||
export declare const currentDateForDatePicker: (dateFormat?: string, outputFormat?: string) => any; | ||
export declare const dateFromDatePicker: (date: moment.MomentInput, format?: string, outputFormat?: string) => string; | ||
export declare const localDateForDatePicker: (date: moment.MomentInput, outputFormat?: string) => string; | ||
export declare const currentDateForDatePicker: (dateFormat?: string, outputFormat?: string) => string; | ||
export declare const dateForDatePicker: (month: number, day: number, year: number) => string; |
@@ -30,5 +30,3 @@ var __values = (this && this.__values) || function(o) { | ||
import 'node_modules/jquery-ui-dist/jquery-ui.min'; | ||
// @ts-ignore | ||
import * as moment from 'moment/min/moment.min.js'; | ||
import 'moment/min/locale.min.js'; | ||
import * as moment from 'moment'; | ||
import { extendMoment } from 'moment-range'; | ||
@@ -80,6 +78,6 @@ import { numberToString } from '../string/core-services-string.service'; | ||
export var dateMilliseconds = function (date, dateFormat, outputFormat) { | ||
return moment(isoDateCustom(date, dateFormat, outputFormat), dateFormat).format('x'); | ||
return +moment(isoDateCustom(date, dateFormat, outputFormat), dateFormat).format('x'); | ||
}; | ||
export var dateToMillisecondsNoTime = function (date) { | ||
return moment(isoDateWithoutTime(date)).format('x'); | ||
return +moment(isoDateWithoutTime(date)).format('x'); | ||
}; | ||
@@ -270,2 +268,6 @@ export var millisecondsToDate = function (date, outputFormat) { | ||
* Jquery ui | ||
* This function is using Jquery and Jquery-ui and typescript is not available | ||
* To this function work is necessary the following imports, respectively: | ||
* import * as $ from 'jquery'; or import $ = require('jquery'); | ||
* import '../../../../../node_modules/jquery-ui-dist/jquery-ui.min'; | ||
*/ | ||
@@ -272,0 +274,0 @@ export var setDatePicker = function (datePicker, dateFormat) { |
@@ -116,4 +116,4 @@ /// <reference types="moment-range" /> | ||
dateFromDatePicker: (date: import("moment").MomentInput, format?: string, outputFormat?: string) => string; | ||
localDateForDatePicker: (date: import("moment").MomentInput, outputFormat?: string) => any; | ||
currentDateForDatePicker: (dateFormat?: string, outputFormat?: string) => any; | ||
localDateForDatePicker: (date: import("moment").MomentInput, outputFormat?: string) => string; | ||
currentDateForDatePicker: (dateFormat?: string, outputFormat?: string) => string; | ||
dateForDatePicker: (month: number, day: number, year: number) => string; | ||
@@ -120,0 +120,0 @@ }; |
@@ -1,4 +0,3 @@ | ||
/// <reference types="moment-range" /> | ||
import 'node_modules/jquery-ui-dist/jquery-ui.min'; | ||
import 'moment/min/locale.min.js'; | ||
import * as moment from 'moment'; | ||
import { IDateLocal, IDayMonthYear, IDaysOfMonth, IWeeksOfMonth } from './core-services-date.interface'; | ||
@@ -8,14 +7,14 @@ /** | ||
*/ | ||
export declare const customDate: (date: import("moment").MomentInput, format: string) => string; | ||
export declare const customDate: (date: moment.MomentInput, format: string) => string; | ||
export declare const currentDate: (outputFormat?: string) => string; | ||
export declare const dayMonthYear: (date: import("moment").MomentInput, format?: string) => IDayMonthYear; | ||
export declare const dayMonthYear: (date: moment.MomentInput, format?: string) => IDayMonthYear; | ||
export declare const localDate: (year: number, month: number, day: number, local?: IDateLocal) => string; | ||
export declare const dateFromIso: (date: import("moment").MomentInput, format?: string) => string; | ||
export declare const ganttDate: (date: import("moment").MomentInput) => Date; | ||
export declare const isoDateCustom: (date: import("moment").MomentInput, dateFormat: string, outputFormat: string) => string; | ||
export declare const isoDate: (date: import("moment").MomentInput, format?: string) => string; | ||
export declare const isoDateWithoutTime: (date: import("moment").MomentInput) => string; | ||
export declare const dateMilliseconds: (date: import("moment").MomentInput, dateFormat: string, outputFormat: string) => number; | ||
export declare const dateToMillisecondsNoTime: (date: import("moment").MomentInput) => number; | ||
export declare const millisecondsToDate: (date: import("moment").MomentInput, outputFormat: string) => string; | ||
export declare const dateFromIso: (date: moment.MomentInput, format?: string) => string; | ||
export declare const ganttDate: (date: moment.MomentInput) => Date; | ||
export declare const isoDateCustom: (date: moment.MomentInput, dateFormat: string, outputFormat: string) => string; | ||
export declare const isoDate: (date: moment.MomentInput, format?: string) => string; | ||
export declare const isoDateWithoutTime: (date: moment.MomentInput) => string; | ||
export declare const dateMilliseconds: (date: moment.MomentInput, dateFormat: string, outputFormat: string) => number; | ||
export declare const dateToMillisecondsNoTime: (date: moment.MomentInput) => number; | ||
export declare const millisecondsToDate: (date: moment.MomentInput, outputFormat: string) => string; | ||
export declare const daysToMilliseconds: (days: number) => number; | ||
@@ -31,16 +30,20 @@ export declare const durationInDays: (start: number, end: number, countFirstDay: boolean) => number; | ||
*/ | ||
export declare const isDateBefore: (startDate: string, endDate: string, type?: import("moment").unitOfTime.StartOf) => boolean; | ||
export declare const isDateBefore: (startDate: string, endDate: string, type?: moment.unitOfTime.StartOf) => boolean; | ||
/** | ||
* Date validation | ||
*/ | ||
export declare const validateDate: (date: import("moment").MomentInput) => boolean; | ||
export declare const validateDate: (date: moment.MomentInput) => boolean; | ||
/** | ||
* Date picker utilities; | ||
* Jquery ui | ||
* This function is using Jquery and Jquery-ui and typescript is not available | ||
* To this function work is necessary the following imports, respectively: | ||
* import * as $ from 'jquery'; or import $ = require('jquery'); | ||
* import '../../../../../node_modules/jquery-ui-dist/jquery-ui.min'; | ||
*/ | ||
export declare const setDatePicker: (datePicker: HTMLInputElement, dateFormat: string) => void; | ||
export declare const monthYearDatePicker: (datePicker: HTMLInputElement, dateFormat: string, setValueCallback: any) => void; | ||
export declare const dateFromDatePicker: (date: import("moment").MomentInput, format?: string, outputFormat?: string) => string; | ||
export declare const localDateForDatePicker: (date: import("moment").MomentInput, outputFormat?: string) => any; | ||
export declare const currentDateForDatePicker: (dateFormat?: string, outputFormat?: string) => any; | ||
export declare const dateFromDatePicker: (date: moment.MomentInput, format?: string, outputFormat?: string) => string; | ||
export declare const localDateForDatePicker: (date: moment.MomentInput, outputFormat?: string) => string; | ||
export declare const currentDateForDatePicker: (dateFormat?: string, outputFormat?: string) => string; | ||
export declare const dateForDatePicker: (month: number, day: number, year: number) => string; |
@@ -1,1 +0,1 @@ | ||
"use strict";var __values=this&&this.__values||function(o){var s=typeof Symbol==="function"&&Symbol.iterator,m=s&&o[s],i=0;if(m)return m.call(o);if(o&&typeof o.length==="number")return{next:function(){if(o&&i>=o.length)o=void 0;return{value:o&&o[i++],done:!o}}};throw new TypeError(s?"Object is not iterable.":"Symbol.iterator is not defined.")};var __read=this&&this.__read||function(o,n){var m=typeof Symbol==="function"&&o[Symbol.iterator];if(!m)return o;var i=m.call(o),r,ar=[],e;try{while((n===void 0||n-- >0)&&!(r=i.next()).done)ar.push(r.value)}catch(error){e={error:error}}finally{try{if(r&&!r.done&&(m=i["return"]))m.call(i)}finally{if(e)throw e.error}}return ar};Object.defineProperty(exports,"__esModule",{value:true});var $=require("jquery");require("node_modules/jquery-ui-dist/jquery-ui.min");var moment=require("moment/min/moment.min.js");require("moment/min/locale.min.js");var moment_range_1=require("moment-range");var core_services_string_service_1=require("../string/core-services-string.service");exports.customDate=function(date,format){return moment(date).format(format)};exports.currentDate=function(outputFormat){if(outputFormat===void 0){outputFormat="DD/MM/YYYY"}return moment.utc(new Date,outputFormat).local().format(outputFormat)};exports.dayMonthYear=function(date,format){if(format===void 0){format="DD/MM/YYYY"}var x=moment(date,format,true).format(format);var d=parseInt(x.split("/")[0],10);var m=parseInt(x.split("/")[1],10)-1;var y=parseInt(x.split("/")[2],10);return{day:d,month:m,year:y}};exports.localDate=function(year,month,day,local){if(local===void 0){local="pt-BR"}var options={year:"numeric",month:"numeric",day:"numeric"};return new Date(year,month,day).toLocaleDateString(local,options)};exports.dateFromIso=function(date,format){if(format===void 0){format="DD/MM/YYYY"}return moment.utc(date).format(format)};exports.ganttDate=function(date){var splitDate=exports.dayMonthYear(date);return new Date(splitDate.year,splitDate.month,splitDate.day)};exports.isoDateCustom=function(date,dateFormat,outputFormat){var splitDate=exports.dayMonthYear(date);return new Date(splitDate.year,splitDate.month,splitDate.day).toISOString()};exports.isoDate=function(date,format){if(format===void 0){format="DD/MM/YYYY"}return moment.utc(date,format).format(format)};exports.isoDateWithoutTime=function(date){var splitDate=exports.dayMonthYear(date);return moment.utc(new Date(splitDate.year,splitDate.month,splitDate.day)).toISOString()};exports.dateMilliseconds=function(date,dateFormat,outputFormat){return moment(exports.isoDateCustom(date,dateFormat,outputFormat),dateFormat).format("x")};exports.dateToMillisecondsNoTime=function(date){return moment(exports.isoDateWithoutTime(date)).format("x")};exports.millisecondsToDate=function(date,outputFormat){return moment.utc(date,"x").format(outputFormat)};exports.daysToMilliseconds=function(days){return days*24*60*60*1e3};exports.durationInDays=function(start,end,countFirstDay){var s=exports.dayMonthYear(start);var e=exports.dayMonthYear(end);var startDate=moment([s.year,s.month,s.day]);var endDate=moment([e.year,e.month,e.day]);var difference=endDate.diff(startDate,"days");var additional=countFirstDay?1:0;return difference+additional};exports.durationInMilliseconds=function(start,end){return exports.daysToMilliseconds(exports.durationInDays(start,end,false))};exports.monthName=function(month,language){if(language===void 0){language="pt-br"}if(language==="pt-br"||language==="pt-pt"||language==="pt"){switch(month){case 0:return"Janeiro";case 1:return"Fevereiro";case 2:return"Março";case 3:return"Abril";case 4:return"Maio";case 5:return"Junho";case 6:return"Julho";case 7:return"Agosto";case 8:return"Setembro";case 9:return"Outubro";case 10:return"Novembro";case 11:return"Dezembro";default:return""}}else{switch(month){case 0:return"January";case 1:return"February";case 2:return"March";case 3:return"April";case 4:return"May";case 5:return"June";case 6:return"July";case 7:return"August";case 8:return"September";case 9:return"October";case 10:return"November";case 11:return"December";default:return""}}};exports.weeksOfMonth=function(year,month){var e_1,_a,e_2,_b;var _moment=moment_range_1.extendMoment(moment);var startDate=moment([year,month]);var firstDay=moment(startDate).startOf("month");var endDay=moment(startDate).endOf("month");var monthRange=_moment.range(firstDay,endDay);var weeks=[];var _loop_1=function(range){var contain=weeks.filter(function(x){return x===range.week()}).length>0;if(!contain){weeks.push(range.week())}};try{for(var _c=__values(monthRange.by("days")),_d=_c.next();!_d.done;_d=_c.next()){var range=_d.value;_loop_1(range)}}catch(e_1_1){e_1={error:e_1_1}}finally{try{if(_d&&!_d.done&&(_a=_c.return))_a.call(_c)}finally{if(e_1)throw e_1.error}}var calendar=[];try{for(var weeks_1=__values(weeks),weeks_1_1=weeks_1.next();!weeks_1_1.done;weeks_1_1=weeks_1.next()){var week=weeks_1_1.value;var firstWeekDay=void 0;var lastWeekDay=void 0;var weekRange=void 0;if(month===11&&week===1){firstWeekDay=moment(year+1,"YYYY").week(week).day(0).isAfter(firstDay)?moment(year+1,"YYYY").week(week).day(0):firstDay;lastWeekDay=moment(year+1,"YYYY").week(week).day(6).isBefore(endDay)?moment(year+1,"YYYY").week(week).day(6):endDay;weekRange=_moment.range(firstWeekDay,lastWeekDay)}else{firstWeekDay=moment().week(week).day(0).isAfter(firstDay)?moment().week(week).day(0):firstDay;lastWeekDay=moment().week(week).day(6).isBefore(endDay)?moment().week(week).day(6):endDay;weekRange=_moment.range(firstWeekDay,lastWeekDay)}calendar.push({week:week,start:moment(weekRange.start.toISOString()).format("DD/MM/YYYY"),startDay:moment(weekRange.start.toISOString()).format("DD"),startMonth:moment(weekRange.start.toISOString()).format("MM"),startYear:moment(weekRange.start.toISOString()).format("YYYY"),end:moment(weekRange.end.toISOString()).format("DD/MM/YYYY"),endDay:moment(weekRange.end.toISOString()).format("DD"),endMonth:moment(weekRange.end.toISOString()).format("MM"),endYear:moment(weekRange.end.toISOString()).format("YYYY")})}}catch(e_2_1){e_2={error:e_2_1}}finally{try{if(weeks_1_1&&!weeks_1_1.done&&(_b=weeks_1.return))_b.call(weeks_1)}finally{if(e_2)throw e_2.error}}return calendar};exports.daysOfMonth=function(weeksRange){var e_3,_a;var range=[];try{for(var _b=__values(weeksRange.entries()),_c=_b.next();!_c.done;_c=_b.next()){var _d=__read(_c.value,2),i=_d[0],week=_d[1];var start=parseInt(weeksRange[i].startDay,10);var end=parseInt(weeksRange[i].endDay,10);var month=weeksRange[i].startMonth;var year=weeksRange[i].startYear;var weekDays=[];for(var j=start;j<=end;j++){var day=core_services_string_service_1.numberToString(j);weekDays.push({week:week.week,day:day,month:""+month,year:""+year,dayMonth:day+"/"+month,date:day+"/"+month+"/"+year,monthYear:month+"/"+year})}range.push(weekDays)}}catch(e_3_1){e_3={error:e_3_1}}finally{try{if(_c&&!_c.done&&(_a=_b.return))_a.call(_b)}finally{if(e_3)throw e_3.error}}return range};exports.weekOfYear=function(date,format){return moment(date,format).week()};exports.isDateBefore=function(startDate,endDate,type){if(type===void 0){type="day"}return moment(endDate).isBefore(startDate,type)};exports.validateDate=function(date){var aDate=moment(date,"DD/MM/YYYY",true);return aDate.isValid()};exports.setDatePicker=function(datePicker,dateFormat){$(datePicker).datepicker("option","dateFormat",dateFormat)};exports.monthYearDatePicker=function(datePicker,dateFormat,setValueCallback){$(datePicker).datepicker({changeMonth:true,changeYear:true,showButtonPanel:true,dateFormat:dateFormat,showAnim:"drop",showOn:"button",buttonImage:"src/assets/img/icons/calendar.svg",buttonImageOnly:true,buttonText:"Select period",onClose:function(){var _month=$("#ui-datepicker-div .ui-datepicker-month :selected").val();var _year=$("#ui-datepicker-div .ui-datepicker-year :selected").val();$(this).datepicker("setDate",new Date(_year,_month,1));setValueCallback(datePicker.value);setTimeout(function(){var parentCalendar=document.querySelector("#ui-datepicker-div");parentCalendar.classList.remove("only-month-year")},500)},beforeShow:function(){var parentCalendar=document.querySelector("#ui-datepicker-div");parentCalendar.classList.add("only-month-year");var selDate=$(this).val();if(selDate.length>0){var _year=parseInt(selDate.substring(selDate.length-4,selDate.length),10);var _month=parseInt(selDate.substring(0,selDate.length-5),10)-1;$(this).datepicker("option","defaultDate",new Date(_year,_month,1));$(this).datepicker("setDate",new Date(_year,_month,1));console.log(_year);console.log(_month)}}})};exports.dateFromDatePicker=function(date,format,outputFormat){if(format===void 0){format="DD/MM/YYYY"}if(outputFormat===void 0){outputFormat="DD/MM/YYYY"}return moment(date,format).format(outputFormat)};exports.localDateForDatePicker=function(date,outputFormat){if(outputFormat===void 0){outputFormat="DD/MM/YYYY"}return moment.utc(date,outputFormat).local().format(outputFormat)};exports.currentDateForDatePicker=function(dateFormat,outputFormat){if(dateFormat===void 0){dateFormat="DD/MM/YYYY"}if(outputFormat===void 0){outputFormat="DD/MM/YYYY"}return moment.utc(new Date,"DD/MM/YYYY").format(outputFormat)};exports.dateForDatePicker=function(month,day,year){var x=moment(new Date(year,month,day),"DD/MM/YYYY",true).toISOString().split("T")[0];x=x.split("-")[2]+"/"+x.split("-")[1]+"/"+x.split("-")[0];return x}; | ||
"use strict";var __values=this&&this.__values||function(o){var s=typeof Symbol==="function"&&Symbol.iterator,m=s&&o[s],i=0;if(m)return m.call(o);if(o&&typeof o.length==="number")return{next:function(){if(o&&i>=o.length)o=void 0;return{value:o&&o[i++],done:!o}}};throw new TypeError(s?"Object is not iterable.":"Symbol.iterator is not defined.")};var __read=this&&this.__read||function(o,n){var m=typeof Symbol==="function"&&o[Symbol.iterator];if(!m)return o;var i=m.call(o),r,ar=[],e;try{while((n===void 0||n-- >0)&&!(r=i.next()).done)ar.push(r.value)}catch(error){e={error:error}}finally{try{if(r&&!r.done&&(m=i["return"]))m.call(i)}finally{if(e)throw e.error}}return ar};Object.defineProperty(exports,"__esModule",{value:true});var $=require("jquery");require("node_modules/jquery-ui-dist/jquery-ui.min");var moment=require("moment");var moment_range_1=require("moment-range");var core_services_string_service_1=require("../string/core-services-string.service");exports.customDate=function(date,format){return moment(date).format(format)};exports.currentDate=function(outputFormat){if(outputFormat===void 0){outputFormat="DD/MM/YYYY"}return moment.utc(new Date,outputFormat).local().format(outputFormat)};exports.dayMonthYear=function(date,format){if(format===void 0){format="DD/MM/YYYY"}var x=moment(date,format,true).format(format);var d=parseInt(x.split("/")[0],10);var m=parseInt(x.split("/")[1],10)-1;var y=parseInt(x.split("/")[2],10);return{day:d,month:m,year:y}};exports.localDate=function(year,month,day,local){if(local===void 0){local="pt-BR"}var options={year:"numeric",month:"numeric",day:"numeric"};return new Date(year,month,day).toLocaleDateString(local,options)};exports.dateFromIso=function(date,format){if(format===void 0){format="DD/MM/YYYY"}return moment.utc(date).format(format)};exports.ganttDate=function(date){var splitDate=exports.dayMonthYear(date);return new Date(splitDate.year,splitDate.month,splitDate.day)};exports.isoDateCustom=function(date,dateFormat,outputFormat){var splitDate=exports.dayMonthYear(date);return new Date(splitDate.year,splitDate.month,splitDate.day).toISOString()};exports.isoDate=function(date,format){if(format===void 0){format="DD/MM/YYYY"}return moment.utc(date,format).format(format)};exports.isoDateWithoutTime=function(date){var splitDate=exports.dayMonthYear(date);return moment.utc(new Date(splitDate.year,splitDate.month,splitDate.day)).toISOString()};exports.dateMilliseconds=function(date,dateFormat,outputFormat){return+moment(exports.isoDateCustom(date,dateFormat,outputFormat),dateFormat).format("x")};exports.dateToMillisecondsNoTime=function(date){return+moment(exports.isoDateWithoutTime(date)).format("x")};exports.millisecondsToDate=function(date,outputFormat){return moment.utc(date,"x").format(outputFormat)};exports.daysToMilliseconds=function(days){return days*24*60*60*1e3};exports.durationInDays=function(start,end,countFirstDay){var s=exports.dayMonthYear(start);var e=exports.dayMonthYear(end);var startDate=moment([s.year,s.month,s.day]);var endDate=moment([e.year,e.month,e.day]);var difference=endDate.diff(startDate,"days");var additional=countFirstDay?1:0;return difference+additional};exports.durationInMilliseconds=function(start,end){return exports.daysToMilliseconds(exports.durationInDays(start,end,false))};exports.monthName=function(month,language){if(language===void 0){language="pt-br"}if(language==="pt-br"||language==="pt-pt"||language==="pt"){switch(month){case 0:return"Janeiro";case 1:return"Fevereiro";case 2:return"Março";case 3:return"Abril";case 4:return"Maio";case 5:return"Junho";case 6:return"Julho";case 7:return"Agosto";case 8:return"Setembro";case 9:return"Outubro";case 10:return"Novembro";case 11:return"Dezembro";default:return""}}else{switch(month){case 0:return"January";case 1:return"February";case 2:return"March";case 3:return"April";case 4:return"May";case 5:return"June";case 6:return"July";case 7:return"August";case 8:return"September";case 9:return"October";case 10:return"November";case 11:return"December";default:return""}}};exports.weeksOfMonth=function(year,month){var e_1,_a,e_2,_b;var _moment=moment_range_1.extendMoment(moment);var startDate=moment([year,month]);var firstDay=moment(startDate).startOf("month");var endDay=moment(startDate).endOf("month");var monthRange=_moment.range(firstDay,endDay);var weeks=[];var _loop_1=function(range){var contain=weeks.filter(function(x){return x===range.week()}).length>0;if(!contain){weeks.push(range.week())}};try{for(var _c=__values(monthRange.by("days")),_d=_c.next();!_d.done;_d=_c.next()){var range=_d.value;_loop_1(range)}}catch(e_1_1){e_1={error:e_1_1}}finally{try{if(_d&&!_d.done&&(_a=_c.return))_a.call(_c)}finally{if(e_1)throw e_1.error}}var calendar=[];try{for(var weeks_1=__values(weeks),weeks_1_1=weeks_1.next();!weeks_1_1.done;weeks_1_1=weeks_1.next()){var week=weeks_1_1.value;var firstWeekDay=void 0;var lastWeekDay=void 0;var weekRange=void 0;if(month===11&&week===1){firstWeekDay=moment(year+1,"YYYY").week(week).day(0).isAfter(firstDay)?moment(year+1,"YYYY").week(week).day(0):firstDay;lastWeekDay=moment(year+1,"YYYY").week(week).day(6).isBefore(endDay)?moment(year+1,"YYYY").week(week).day(6):endDay;weekRange=_moment.range(firstWeekDay,lastWeekDay)}else{firstWeekDay=moment().week(week).day(0).isAfter(firstDay)?moment().week(week).day(0):firstDay;lastWeekDay=moment().week(week).day(6).isBefore(endDay)?moment().week(week).day(6):endDay;weekRange=_moment.range(firstWeekDay,lastWeekDay)}calendar.push({week:week,start:moment(weekRange.start.toISOString()).format("DD/MM/YYYY"),startDay:moment(weekRange.start.toISOString()).format("DD"),startMonth:moment(weekRange.start.toISOString()).format("MM"),startYear:moment(weekRange.start.toISOString()).format("YYYY"),end:moment(weekRange.end.toISOString()).format("DD/MM/YYYY"),endDay:moment(weekRange.end.toISOString()).format("DD"),endMonth:moment(weekRange.end.toISOString()).format("MM"),endYear:moment(weekRange.end.toISOString()).format("YYYY")})}}catch(e_2_1){e_2={error:e_2_1}}finally{try{if(weeks_1_1&&!weeks_1_1.done&&(_b=weeks_1.return))_b.call(weeks_1)}finally{if(e_2)throw e_2.error}}return calendar};exports.daysOfMonth=function(weeksRange){var e_3,_a;var range=[];try{for(var _b=__values(weeksRange.entries()),_c=_b.next();!_c.done;_c=_b.next()){var _d=__read(_c.value,2),i=_d[0],week=_d[1];var start=parseInt(weeksRange[i].startDay,10);var end=parseInt(weeksRange[i].endDay,10);var month=weeksRange[i].startMonth;var year=weeksRange[i].startYear;var weekDays=[];for(var j=start;j<=end;j++){var day=core_services_string_service_1.numberToString(j);weekDays.push({week:week.week,day:day,month:""+month,year:""+year,dayMonth:day+"/"+month,date:day+"/"+month+"/"+year,monthYear:month+"/"+year})}range.push(weekDays)}}catch(e_3_1){e_3={error:e_3_1}}finally{try{if(_c&&!_c.done&&(_a=_b.return))_a.call(_b)}finally{if(e_3)throw e_3.error}}return range};exports.weekOfYear=function(date,format){return moment(date,format).week()};exports.isDateBefore=function(startDate,endDate,type){if(type===void 0){type="day"}return moment(endDate).isBefore(startDate,type)};exports.validateDate=function(date){var aDate=moment(date,"DD/MM/YYYY",true);return aDate.isValid()};exports.setDatePicker=function(datePicker,dateFormat){$(datePicker).datepicker("option","dateFormat",dateFormat)};exports.monthYearDatePicker=function(datePicker,dateFormat,setValueCallback){$(datePicker).datepicker({changeMonth:true,changeYear:true,showButtonPanel:true,dateFormat:dateFormat,showAnim:"drop",showOn:"button",buttonImage:"src/assets/img/icons/calendar.svg",buttonImageOnly:true,buttonText:"Select period",onClose:function(){var _month=$("#ui-datepicker-div .ui-datepicker-month :selected").val();var _year=$("#ui-datepicker-div .ui-datepicker-year :selected").val();$(this).datepicker("setDate",new Date(_year,_month,1));setValueCallback(datePicker.value);setTimeout(function(){var parentCalendar=document.querySelector("#ui-datepicker-div");parentCalendar.classList.remove("only-month-year")},500)},beforeShow:function(){var parentCalendar=document.querySelector("#ui-datepicker-div");parentCalendar.classList.add("only-month-year");var selDate=$(this).val();if(selDate.length>0){var _year=parseInt(selDate.substring(selDate.length-4,selDate.length),10);var _month=parseInt(selDate.substring(0,selDate.length-5),10)-1;$(this).datepicker("option","defaultDate",new Date(_year,_month,1));$(this).datepicker("setDate",new Date(_year,_month,1));console.log(_year);console.log(_month)}}})};exports.dateFromDatePicker=function(date,format,outputFormat){if(format===void 0){format="DD/MM/YYYY"}if(outputFormat===void 0){outputFormat="DD/MM/YYYY"}return moment(date,format).format(outputFormat)};exports.localDateForDatePicker=function(date,outputFormat){if(outputFormat===void 0){outputFormat="DD/MM/YYYY"}return moment.utc(date,outputFormat).local().format(outputFormat)};exports.currentDateForDatePicker=function(dateFormat,outputFormat){if(dateFormat===void 0){dateFormat="DD/MM/YYYY"}if(outputFormat===void 0){outputFormat="DD/MM/YYYY"}return moment.utc(new Date,"DD/MM/YYYY").format(outputFormat)};exports.dateForDatePicker=function(month,day,year){var x=moment(new Date(year,month,day),"DD/MM/YYYY",true).toISOString().split("T")[0];x=x.split("-")[2]+"/"+x.split("-")[1]+"/"+x.split("-")[0];return x}; |
{ | ||
"name": "gl-w-frontend", | ||
"version": "1.3.8", | ||
"version": "1.3.10", | ||
"description": "Common code for using among web front-end development such as pure JavaScript, ES6+ and TypeScript", | ||
@@ -5,0 +5,0 @@ "main": "lib/", |
# gl-w-frontend # | ||
[![version](https://img.shields.io/badge/version-1.3.8-green.svg)](https://www.npmjs.com/package/gl-w-frontend) | ||
[![version](https://img.shields.io/badge/version-1.3.10-green.svg)](https://www.npmjs.com/package/gl-w-frontend) | ||
@@ -4,0 +4,0 @@ ### What is this repository for? ### |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
160997
1555