Last active
October 15, 2019 17:33
-
-
Save netstart/c92e09730f3675ba8fb33be48520a86d to your computer and use it in GitHub Desktop.
Revisions
-
netstart revised this gist
Oct 15, 2019 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,7 +1,7 @@ /** * Import on top of app.module.ts to use across the application * * import './shared/utils/date.prototype.extendions'; */ declare global { interface Date { -
netstart revised this gist
Oct 15, 2019 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,7 +1,7 @@ /** * just import, like * * import './../shared/utils/date.prototype.extendions'; */ declare global { interface Date { -
netstart revised this gist
Oct 15, 2019 . 1 changed file with 13 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -3,20 +3,28 @@ * * import './../shared/utils/date.prototype.extendions.ts'; */ declare global { interface Date { addDays(days: number, useThis?: boolean): Date; addSeconds(seconds: number): Date; addMinutes(minutes: number): Date; addHours(hours: number): Date; addMonths(months: number): Date; isToday(): boolean; clone(): Date; isAnotherMonth(date: Date): boolean; isWeekend(): boolean; isSameDate(date: Date): boolean; getStringDate(): string; } } @@ -107,3 +115,6 @@ Date.prototype.getStringDate = function(): string { // return this.monthNames[this.getMonth()] + ' ' + this.getDay() + ', ' + this.getFullYear(); } }; export {}; -
netstart revised this gist
Oct 15, 2019 . 1 changed file with 5 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,8 @@ /** * just import, like * * import './../shared/utils/date.prototype.extendions.ts'; */ export {}; declare global { -
netstart revised this gist
Oct 15, 2019 . 1 changed file with 13 additions and 18 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -8,15 +8,10 @@ declare global { addHours(hours: number): Date; addMonths(months: number): Date; isToday(): boolean; clone(): Date; isAnotherMonth(date: Date): boolean; isWeekend(): boolean; isSameDate(date: Date): boolean; getStringDate(): string; } } @@ -87,23 +82,23 @@ Date.prototype.isSameDate = function(date: Date): boolean { return date && this.getFullYear() === date.getFullYear() && this.getMonth() === date.getMonth() && this.getDate() === date.getDate(); }; Date.prototype.getStringDate = function(): string { // Month names in Brazilian Portuguese const monthNames = ['Janeiro', 'Fevereiro', 'Março', 'Abril', 'Maio', 'Junho', 'Julho', 'Agosto', 'Setembro', 'Outubro', 'Novembro', 'Dezembro']; // Month names in English // let monthNames = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']; const today = new Date(); if (this.getMonth() === today.getMonth() && this.getDay() === today.getDay()) { return 'Hoje'; // return "Today"; } else if (this.getMonth() === today.getMonth() && this.getDay() === today.getDay() + 1) { return 'Amanhã'; // return "Tomorrow"; } else if (this.getMonth() === today.getMonth() && this.getDay() === today.getDay() - 1) { return 'Ontem'; // return "Yesterday"; } else { return this.getDay() + ' de ' + this.monthNames[this.getMonth()] + ' de ' + this.getFullYear(); // return this.monthNames[this.getMonth()] + ' ' + this.getDay() + ', ' + this.getFullYear(); } }; -
netstart revised this gist
Oct 15, 2019 . 1 changed file with 86 additions and 77 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,100 +1,109 @@ export {}; declare global { interface Date { addDays(days: number, useThis?: boolean): Date; addSeconds(seconds: number): Date; addMinutes(minutes: number): Date; addHours(hours: number): Date; addMonths(months: number): Date; isToday(): boolean; clone(): Date; isAnotherMonth(date: Date): boolean; isWeekend(): boolean; isSameDate(date: Date): boolean; getStringDate(): string; } } Date.prototype.addDays = function(days: number): Date { if (!days) { return this; } this.setDate(this.getDate() + days); return this; }; Date.prototype.addSeconds = function(seconds: number) { let value = this.valueOf(); value += 1000 * seconds; return new Date(value); }; Date.prototype.addMinutes = function(minutes: number) { let value = this.valueOf(); value += 60000 * minutes; return new Date(value); }; Date.prototype.addHours = function(hours: number) { let value = this.valueOf(); value += 3600000 * hours; return new Date(value); }; Date.prototype.addMonths = function(months: number) { const value = new Date(this.valueOf()); let mo = this.getMonth(); let yr = this.getYear(); mo = (mo + months) % 12; if (0 > mo) { yr += (this.getMonth() + months - mo - 12) / 12; mo += 12; } else { yr += ((this.getMonth() + months - mo) / 12); } value.setMonth(mo); value.setFullYear(yr); return value; }; Date.prototype.isToday = function(): boolean { const today = new Date(); return this.isSameDate(today); }; Date.prototype.clone = function(): Date { return new Date(+this); }; Date.prototype.isAnotherMonth = function(date: Date): boolean { return date && this.getMonth() !== date.getMonth(); }; Date.prototype.isWeekend = function(): boolean { return this.getDay() === 0 || this.getDay() === 6; }; Date.prototype.isSameDate = function(date: Date): boolean { return date && this.getFullYear() === date.getFullYear() && this.getMonth() === date.getMonth() && this.getDate() === date.getDate(); }; Date.prototype.getStringDate = function(): String { //Month names in Brazilian Portuguese let monthNames = ['Janeiro', 'Fevereiro', 'Março', 'Abril', 'Maio', 'Junho', 'Julho', 'Agosto', 'Setembro', 'Outubro', 'Novembro', 'Dezembro']; //Month names in English //let monthNames = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']; let today = new Date(); if (this.getMonth() == today.getMonth() && this.getDay() == today.getDay()) { return 'Hoje'; //return "Today"; } else if (this.getMonth() == today.getMonth() && this.getDay() == today.getDay() + 1) { return 'Amanhã'; //return "Tomorrow"; } else if (this.getMonth() == today.getMonth() && this.getDay() == today.getDay() - 1) { return 'Ontem'; //return "Yesterday"; } else { return this.getDay() + ' de ' + this.monthNames[this.getMonth()] + ' de ' + this.getFullYear(); //return this.monthNames[this.getMonth()] + ' ' + this.getDay() + ', ' + this.getFullYear(); } }; -
netstart revised this gist
Oct 15, 2019 . 1 changed file with 38 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -19,6 +19,42 @@ Date.prototype.addDays = function (days: number): Date { return date; }; Date.prototype.addSeconds = function (num) { var value = this.valueOf(); value += 1000 * num; return new Date(value); } Date.prototype.addMinutes = function (num) { var value = this.valueOf(); value += 60000 * num; return new Date(value); } Date.prototype.addHours = function (num) { var value = this.valueOf(); value += 3600000 * num; return new Date(value); } Date.prototype.addMonths = function (num) { var value = new Date(this.valueOf()); var mo = this.getMonth(); var yr = this.getYear(); mo = (mo + num) % 12; if (0 > mo) { yr += (this.getMonth() + num - mo - 12) / 12; mo += 12; } else yr += ((this.getMonth() + num - mo) / 12); value.setMonth(mo); value.setYear(yr); return value; } Date.prototype.isToday = function (): boolean{ let today = new Date(); @@ -60,4 +96,5 @@ Date.prototype.getStringDate = function (): String { return this.getDay() + ' de ' + this.monthNames[this.getMonth()] + ' de ' + this.getFullYear(); //return this.monthNames[this.getMonth()] + ' ' + this.getDay() + ', ' + this.getFullYear(); } } -
netstart created this gist
Oct 15, 2019 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,63 @@ export {} declare global { interface Date { addDays(days: number, useThis?: boolean): Date; isToday(): boolean; clone(): Date; isAnotherMonth(date: Date): boolean; isWeekend(): boolean; isSameDate(date: Date): boolean; getStringDate(): String; } } Date.prototype.addDays = function (days: number): Date { if (!days) return this; let date = this; date.setDate(date.getDate() + days); return date; }; Date.prototype.isToday = function (): boolean{ let today = new Date(); return this.isSameDate(today); }; Date.prototype.clone = function (): Date{ return new Date(+this); }; Date.prototype.isAnotherMonth = function (date: Date): boolean { return date && this.getMonth() !== date.getMonth(); }; Date.prototype.isWeekend = function (): boolean { return this.getDay() === 0 || this.getDay() === 6; }; Date.prototype.isSameDate = function (date: Date): boolean { return date && this.getFullYear() === date.getFullYear() && this.getMonth() === date.getMonth() && this.getDate() === date.getDate(); }; Date.prototype.getStringDate = function (): String { //Month names in Brazilian Portuguese let monthNames = ['Janeiro', 'Fevereiro', 'Março', 'Abril', 'Maio', 'Junho', 'Julho', 'Agosto', 'Setembro', 'Outubro', 'Novembro', 'Dezembro']; //Month names in English //let monthNames = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']; let today = new Date(); if (this.getMonth() == today.getMonth() && this.getDay() == today.getDay()) { return "Hoje"; //return "Today"; } else if (this.getMonth() == today.getMonth() && this.getDay() == today.getDay() + 1) { return "Amanhã"; //return "Tomorrow"; } else if (this.getMonth() == today.getMonth() && this.getDay() == today.getDay() - 1) { return "Ontem"; //return "Yesterday"; } else { return this.getDay() + ' de ' + this.monthNames[this.getMonth()] + ' de ' + this.getFullYear(); //return this.monthNames[this.getMonth()] + ' ' + this.getDay() + ', ' + this.getFullYear(); } }