diff --git a/server/controllers/BlockchainBlock.ts b/server/controllers/BlockchainBlock.ts index 46ff1d7..b801a4a 100644 --- a/server/controllers/BlockchainBlock.ts +++ b/server/controllers/BlockchainBlock.ts @@ -82,7 +82,7 @@ export class BlockchainBlockController { return fee; } - dateDiff(date2) { + dateDiff(date2, insec = false) { var current_date = new Date(); // var current_date = new Date("Sat Apr 2 2018 15:04:00 GMT+0530 (IST)"); @@ -92,7 +92,7 @@ export class BlockchainBlockController { var enddayrnd = Math.round(enddaydif); // if(enddayrnd < 1) { var time = this.convertMinsToHrmin( - Math.abs(date2.getTime() - current_date.getTime()), + Math.abs(date2.getTime() - current_date.getTime()),insec ); return time; // } else if(enddayrnd == 1) { @@ -118,8 +118,13 @@ export class BlockchainBlockController { // return dateTimeDurationString; // } - convertMinsToHrmin(millseconds) { + convertMinsToHrmin(millseconds,insec) { var seconds = Math.floor(millseconds / 1000); + if(insec){ + let sec = Math.floor(millseconds / 1000); + return sec; + } + console.log('secnds djfhksjdfdsf',seconds); var days = Math.floor(seconds / 86400); var hours = Math.floor((seconds % 86400) / 3600); var minutes = Math.floor(((seconds % 86400) % 3600) / 60); @@ -1068,7 +1073,7 @@ export class BlockchainBlockController { var timeIntervalQry = "timestamp at time zone '" + process.env.TIME_ZONE + - "' > current_date - interval '30 days'"; + "' > current_date - interval '1 day'"; } const BlockQuery = await getConnection() .query( @@ -1523,7 +1528,7 @@ export class BlockchainBlockController { ) => { try { let block_height = '', - letest_block = '', + letest_block, letest_block_num = '', letest_block_duration = ''; @@ -1624,11 +1629,10 @@ export class BlockchainBlockController { var coin_existence = height * 200; } - letest_block = moment(BlockchainLatestBlockQuery[0].timestamp).fromNow(); - letest_block_num = letest_block.substr(0, letest_block.indexOf(' ')); // "72" - letest_block_duration = letest_block.substr( - letest_block.indexOf(' ') + 1, - ); // "tocirah sneab" + letest_block = this.dateDiff(BlockchainLatestBlockQuery[0].timestamp,true); + console.log('letest_block letest_block letest_block !!!!!!!!!!!!!1',letest_block); + letest_block_num = letest_block; // "72" + letest_block_duration = letest_block == 1 ? 'second ago' : 'seconds ago'; const SECOND_POW_EDGE_BITS = 29; const BASE_EDGE_BITS = 24; diff --git a/server/i18n/de.json b/server/i18n/de.json index cba9651..87c1b1f 100644 --- a/server/i18n/de.json +++ b/server/i18n/de.json @@ -19,7 +19,7 @@ "BLOCKCHAIN_HEIGHT": "Blockchain Höhe", "LATEST_BLOCK": "Letzter Block", "LATEST_BLOCK1": "Aktuelle Schwierigkeit", - "COIN_IN": "Münzen in Existenz", + "COIN_IN": "Zirkulierende Versorgung", "HEIGHT": "Höhe", "HASH": "Hash", "AGE": "Alter", @@ -51,7 +51,7 @@ "DAYS" : "Tage", "MONTHS" : "Monate", "WEEK" : "Woche", - "SEARCH_TEXT" : "Suche nach Hash oder Höhe", + "SEARCH_TEXT" : "Suche nach Adresse, Hash oder Blockhöhe", "BLOCK_REWARD" : "Block Belohnung", "NOT_FOUND" : "Seite nicht gefunden", "NOT_FOUND1" : "Die von Ihnen gesuchte Seite wurde nicht gefunden", diff --git a/server/i18n/en.json b/server/i18n/en.json index 05fadd8..1fb1874 100644 --- a/server/i18n/en.json +++ b/server/i18n/en.json @@ -19,7 +19,7 @@ "BLOCKCHAIN_HEIGHT": "Blockchain Height", "LATEST_BLOCK": "Latest Block", "LATEST_BLOCK1": "Current Difficulty", - "COIN_IN": "Coins in Existence", + "COIN_IN": "Circulating Supply", "HEIGHT": "Height", "HASH": "Hash", "AGE": "Age", @@ -51,7 +51,7 @@ "DAYS" : "days", "MONTHS" : "months", "WEEK" : "week", - "SEARCH_TEXT" : "Search by hash or height", + "SEARCH_TEXT" : "Search by address, hash, or block height", "BLOCK_REWARD" : "Block Reward", "NOT_FOUND" : "Page Not Found", "NOT_FOUND1" : "Page you are looking for is not found", diff --git a/server/socket/block.ts b/server/socket/block.ts index bd654bc..6f28575 100644 --- a/server/socket/block.ts +++ b/server/socket/block.ts @@ -1,4 +1,5 @@ import { getConnection } from "typeorm"; + var moment = require("moment"); moment.updateLocale('en', { relativeTime: { @@ -18,10 +19,76 @@ moment.updateLocale('en', { } }); +function dateDiff(date2, insec = false) { + var current_date = new Date(); + // var current_date = new Date("Sat Apr 2 2018 15:04:00 GMT+0530 (IST)"); + + var enddaydif = + Math.abs(date2.getTime() - current_date.getTime()) / + (1000 * 60 * 60 * 24); + var enddayrnd = Math.round(enddaydif); + // if(enddayrnd < 1) { + var time = convertMinsToHrmin( + Math.abs(date2.getTime() - current_date.getTime()),insec + ); + return time; + // } else if(enddayrnd == 1) { + // return 'Ends in ' + enddayrnd + ' day'; + // }else { + // return 'Ends in ' + enddayrnd + ' days'; + // } +} + +// convertMinsToHrmin(millseconds) { +// var seconds = Math.floor(millseconds / 1000); +// var days = Math.floor(seconds / 86400); +// var hours = Math.floor((seconds % 86400) / 3600); +// var minutes = Math.floor(((seconds % 86400) % 3600) / 60); + +// var dateTimeDurationString = ''; +// if ((days > 0) && (hours === 0 && minutes === 0)) dateTimeDurationString += (days > 1) ? (days + ' days ') : (days + ' day '); +// if ((days > 0) && (hours > 0 || minutes > 0)) dateTimeDurationString += (days > 1) ? (days + ' days, ') : (days + ' day, '); +// if ((hours > 0) && (minutes > 0)) dateTimeDurationString += (hours > 1) ? (hours + ' hours, ') : (hours + ' hour, '); +// if ((hours > 0) && (minutes === 0)) dateTimeDurationString += (hours > 1) ? (hours + ' hours ') : (hours + ' hour '); +// if (minutes > 0) dateTimeDurationString += (minutes > 1) ? (minutes + ' minutes ') : (minutes + ' minute '); +// if (seconds > 0) dateTimeDurationString += (seconds > 1) ? (minutes + ' seconds ') : (minutes + ' second '); +// return dateTimeDurationString; +// } + +function convertMinsToHrmin(millseconds,insec) { + var seconds = Math.floor(millseconds / 1000); + if(insec){ + let sec = Math.floor(millseconds / 1000); + return sec; + } + console.log('secnds djfhksjdfdsf',seconds); + var days = Math.floor(seconds / 86400); + var hours = Math.floor((seconds % 86400) / 3600); + var minutes = Math.floor(((seconds % 86400) % 3600) / 60); + seconds = seconds % 60; + var dateTimeDurationString = ''; + + if (days > 0 && (hours === 0 && minutes === 0)) + dateTimeDurationString += days > 1 ? days + 'd ' : days + 'd '; + if (days > 0 && (hours > 0 || minutes > 0)) + dateTimeDurationString += days > 1 ? days + 'd ' : days + 'd '; + if (hours > 0 && minutes > 0) + dateTimeDurationString += hours > 1 ? hours + 'h ' : hours + 'h '; + if (hours > 0 && minutes === 0) + dateTimeDurationString += hours > 1 ? hours + 'h ' : hours + 'h '; + if (minutes > 0) + dateTimeDurationString += minutes > 1 ? minutes + 'm ' : minutes + 'm '; + if (seconds > 0) + dateTimeDurationString += seconds > 1 ? seconds + 's ' : seconds + 's '; + return dateTimeDurationString; +} + + export async function universalGetLatestBlockDetails(socket) { + let block_height = "", - letest_block = "", + letest_block, letest_block_num = "", letest_block_duration = ""; @@ -108,9 +175,9 @@ export async function universalGetLatestBlockDetails(socket) { var coin_existence = height * 200; } - letest_block = moment(BlockchainLatestBlockQuery[0].timestamp).fromNow(); - letest_block_num = letest_block.substr(0, letest_block.indexOf(" ")); // "72" - letest_block_duration = letest_block.substr(letest_block.indexOf(" ") + 1); // "tocirah sneab" + letest_block = dateDiff(BlockchainLatestBlockQuery[0].timestamp, true); + letest_block_num = letest_block // "72" + letest_block_duration = letest_block == 1 ? 'second ago' : 'seconds ago'; // "tocirah sneab" const SECOND_POW_EDGE_BITS = 29; const BASE_EDGE_BITS = 24; diff --git a/src/app/shared/services/trans-service.service.ts b/src/app/shared/services/trans-service.service.ts index 28de00c..668a957 100644 --- a/src/app/shared/services/trans-service.service.ts +++ b/src/app/shared/services/trans-service.service.ts @@ -17,7 +17,7 @@ export class TransServiceService { if (isPlatformBrowser(this.platformId)) { translate.addLangs(["en", "de"]); translate.setDefaultLang("en"); - this.langLabel = { en: "EN", de: "DE" }; + this.langLabel = { en: "English", de: "German" }; // console.log('this.getCookie() ifconf',this.getCookie() != 'undefined' ? 1: 2); // console.log("(this.getCookie() && this.getCookie() != null) ? this.getCookie() : (this.getCurrentLang() && this.getCurrentLang() != null) ? this.getCurrentLang() : 'en'",(this.getCookie() && this.getCookie() != 'undefined') ? this.getCookie() : (this.getCurrentLang() && this.getCurrentLang() != 'undefined') ? this.getCurrentLang() : 'en'); translate.use( diff --git a/src/app/view/home/graph-list/graph-list.component.html b/src/app/view/home/graph-list/graph-list.component.html index 6dbaa44..6616ecf 100644 --- a/src/app/view/home/graph-list/graph-list.component.html +++ b/src/app/view/home/graph-list/graph-list.component.html @@ -197,21 +197,24 @@
+ 1 day 1 {{'home.WEEK' | translate}} - 1 {{'home.WEEK' | translate}} + 30 {{'home.DAYS' | translate}} + " id="3" #item33 [ngClass]="{ active: selectedItem3 == item33.id, day30_txt: true }">30 {{'home.DAYS' | translate}} 60 {{'home.DAYS' | translate}} + " id="4" #item34 [ngClass]="{ active: selectedItem3 == item34.id, day60_txt: true }">60 {{'home.DAYS' | translate}} 3 {{'home.MONTHS' | translate}} + " id="5" #item35 [ngClass]="{ active: selectedItem3 == item35.id, day3m_txt: true }">3 {{'home.MONTHS' | translate}}
{{'home.EXPLORE_IT' | translate}} diff --git a/src/app/view/home/graph-list/graph-list.component.ts b/src/app/view/home/graph-list/graph-list.component.ts index 1dfb759..5f3a139 100644 --- a/src/app/view/home/graph-list/graph-list.component.ts +++ b/src/app/view/home/graph-list/graph-list.component.ts @@ -40,7 +40,7 @@ export class GraphListComponent implements OnInit { public pg_last: any = ''; public selectedItem: Number = 6; - public selectedItem3: Number = 3; + public selectedItem3: Number = 2; public selectedItem2: Number = 3; public selectedItem4: Number = 3; public selectedItem5: Number = 3;