Breaking out strtotime from locutus lib
This commit is contained in:
		
							parent
							
								
									dd03629d20
								
							
						
					
					
						commit
						b273f71d60
					
				
							
								
								
									
										27
									
								
								backend/package-lock.json
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										27
									
								
								backend/package-lock.json
									
									
									
										generated
									
									
									
								
							@ -15,7 +15,6 @@
 | 
			
		||||
        "bitcoinjs-lib": "6.0.1",
 | 
			
		||||
        "crypto-js": "^4.0.0",
 | 
			
		||||
        "express": "^4.17.1",
 | 
			
		||||
        "locutus": "^2.0.12",
 | 
			
		||||
        "mysql2": "2.3.3",
 | 
			
		||||
        "node-worker-threads-pool": "^1.4.3",
 | 
			
		||||
        "socks-proxy-agent": "^6.1.1",
 | 
			
		||||
@ -25,7 +24,6 @@
 | 
			
		||||
      "devDependencies": {
 | 
			
		||||
        "@types/compression": "^1.0.1",
 | 
			
		||||
        "@types/express": "^4.17.2",
 | 
			
		||||
        "@types/locutus": "^0.0.6",
 | 
			
		||||
        "tslint": "^6.1.0"
 | 
			
		||||
      }
 | 
			
		||||
    },
 | 
			
		||||
@ -114,12 +112,6 @@
 | 
			
		||||
        "@types/range-parser": "*"
 | 
			
		||||
      }
 | 
			
		||||
    },
 | 
			
		||||
    "node_modules/@types/locutus": {
 | 
			
		||||
      "version": "0.0.6",
 | 
			
		||||
      "resolved": "https://registry.npmjs.org/@types/locutus/-/locutus-0.0.6.tgz",
 | 
			
		||||
      "integrity": "sha512-P+BQds4wrJhqKiIOBWAYpbsE9UOztnnqW9zHk4Bci7kCXjEQAA7FJrD9HX5JU2Z36fhE2WDctuuIpLvqDsciWQ==",
 | 
			
		||||
      "dev": true
 | 
			
		||||
    },
 | 
			
		||||
    "node_modules/@types/mime": {
 | 
			
		||||
      "version": "2.0.3",
 | 
			
		||||
      "resolved": "https://registry.npmjs.org/@types/mime/-/mime-2.0.3.tgz",
 | 
			
		||||
@ -804,14 +796,6 @@
 | 
			
		||||
        "js-yaml": "bin/js-yaml.js"
 | 
			
		||||
      }
 | 
			
		||||
    },
 | 
			
		||||
    "node_modules/locutus": {
 | 
			
		||||
      "version": "2.0.15",
 | 
			
		||||
      "resolved": "https://registry.npmjs.org/locutus/-/locutus-2.0.15.tgz",
 | 
			
		||||
      "integrity": "sha512-2xWC4RkoAoCVXEb/stzEgG1TNgd+mrkLBj6TuEDNyUoKeQ2XzDTyJUC23sMiqbL6zJmJSP3w59OZo+zc4IBOmA==",
 | 
			
		||||
      "engines": {
 | 
			
		||||
        "node": ">= 10"
 | 
			
		||||
      }
 | 
			
		||||
    },
 | 
			
		||||
    "node_modules/long": {
 | 
			
		||||
      "version": "4.0.0",
 | 
			
		||||
      "resolved": "https://registry.npmjs.org/long/-/long-4.0.0.tgz",
 | 
			
		||||
@ -1562,12 +1546,6 @@
 | 
			
		||||
        "@types/range-parser": "*"
 | 
			
		||||
      }
 | 
			
		||||
    },
 | 
			
		||||
    "@types/locutus": {
 | 
			
		||||
      "version": "0.0.6",
 | 
			
		||||
      "resolved": "https://registry.npmjs.org/@types/locutus/-/locutus-0.0.6.tgz",
 | 
			
		||||
      "integrity": "sha512-P+BQds4wrJhqKiIOBWAYpbsE9UOztnnqW9zHk4Bci7kCXjEQAA7FJrD9HX5JU2Z36fhE2WDctuuIpLvqDsciWQ==",
 | 
			
		||||
      "dev": true
 | 
			
		||||
    },
 | 
			
		||||
    "@types/mime": {
 | 
			
		||||
      "version": "2.0.3",
 | 
			
		||||
      "resolved": "https://registry.npmjs.org/@types/mime/-/mime-2.0.3.tgz",
 | 
			
		||||
@ -2135,11 +2113,6 @@
 | 
			
		||||
        "esprima": "^4.0.0"
 | 
			
		||||
      }
 | 
			
		||||
    },
 | 
			
		||||
    "locutus": {
 | 
			
		||||
      "version": "2.0.15",
 | 
			
		||||
      "resolved": "https://registry.npmjs.org/locutus/-/locutus-2.0.15.tgz",
 | 
			
		||||
      "integrity": "sha512-2xWC4RkoAoCVXEb/stzEgG1TNgd+mrkLBj6TuEDNyUoKeQ2XzDTyJUC23sMiqbL6zJmJSP3w59OZo+zc4IBOmA=="
 | 
			
		||||
    },
 | 
			
		||||
    "long": {
 | 
			
		||||
      "version": "4.0.0",
 | 
			
		||||
      "resolved": "https://registry.npmjs.org/long/-/long-4.0.0.tgz",
 | 
			
		||||
 | 
			
		||||
@ -34,7 +34,6 @@
 | 
			
		||||
    "bitcoinjs-lib": "6.0.1",
 | 
			
		||||
    "crypto-js": "^4.0.0",
 | 
			
		||||
    "express": "^4.17.1",
 | 
			
		||||
    "locutus": "^2.0.12",
 | 
			
		||||
    "mysql2": "2.3.3",
 | 
			
		||||
    "node-worker-threads-pool": "^1.4.3",
 | 
			
		||||
    "socks-proxy-agent": "^6.1.1",
 | 
			
		||||
@ -44,7 +43,6 @@
 | 
			
		||||
  "devDependencies": {
 | 
			
		||||
    "@types/compression": "^1.0.1",
 | 
			
		||||
    "@types/express": "^4.17.2",
 | 
			
		||||
    "@types/locutus": "^0.0.6",
 | 
			
		||||
    "tslint": "^6.1.0"
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -1,7 +1,7 @@
 | 
			
		||||
import { Currencies, OffersData, TradesData, Depth, Currency, Interval, HighLowOpenClose,
 | 
			
		||||
  Markets, Offers, Offer, BisqTrade, MarketVolume, Tickers, Ticker, SummarizedIntervals, SummarizedInterval } from './interfaces';
 | 
			
		||||
 | 
			
		||||
import * as datetime from 'locutus/php/datetime';
 | 
			
		||||
const strtotime = require('./strtotime');
 | 
			
		||||
 | 
			
		||||
class BisqMarketsApi {
 | 
			
		||||
  private cryptoCurrencyData: Currency[] = [];
 | 
			
		||||
@ -312,7 +312,7 @@ class BisqMarketsApi {
 | 
			
		||||
 | 
			
		||||
  getTickerFromMarket(market: string): Ticker | null {
 | 
			
		||||
    let ticker: Ticker;
 | 
			
		||||
    const timestamp_from = datetime.strtotime('-24 hour');
 | 
			
		||||
    const timestamp_from = strtotime('-24 hour');
 | 
			
		||||
    const timestamp_to = new Date().getTime() / 1000;
 | 
			
		||||
    const trades = this.getTradesByCriteria(market, timestamp_to, timestamp_from,
 | 
			
		||||
      undefined, undefined, undefined, 'asc', Number.MAX_SAFE_INTEGER);
 | 
			
		||||
@ -638,13 +638,13 @@ class BisqMarketsApi {
 | 
			
		||||
        case 'half_day':
 | 
			
		||||
            return (ts - (ts % (3600 * 12)));
 | 
			
		||||
        case 'day':
 | 
			
		||||
            return datetime.strtotime('midnight today', ts);
 | 
			
		||||
            return strtotime('midnight today', ts);
 | 
			
		||||
        case 'week':
 | 
			
		||||
            return datetime.strtotime('midnight sunday last week', ts);
 | 
			
		||||
            return strtotime('midnight sunday last week', ts);
 | 
			
		||||
        case 'month':
 | 
			
		||||
            return datetime.strtotime('midnight first day of this month', ts);
 | 
			
		||||
            return strtotime('midnight first day of this month', ts);
 | 
			
		||||
        case 'year':
 | 
			
		||||
            return datetime.strtotime('midnight first day of january', ts);
 | 
			
		||||
            return strtotime('midnight first day of january', ts);
 | 
			
		||||
        default:
 | 
			
		||||
            throw new Error('Unsupported interval: ' + interval);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										1375
									
								
								backend/src/api/bisq/strtotime.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1375
									
								
								backend/src/api/bisq/strtotime.ts
									
									
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user