Skip to content

Commit

Permalink
added mdy to js/py/php
Browse files Browse the repository at this point in the history
  • Loading branch information
kroitor committed Jun 1, 2018
1 parent 487243f commit 5aa4a63
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
11 changes: 11 additions & 0 deletions js/base/Exchange.js
Expand Up @@ -1059,6 +1059,17 @@ module.exports = class Exchange {
}
}

mdy (timestamp, infix = '-') {
infix = infix || ''
let date = new Date (timestamp)
let Y = date.getUTCFullYear ().toString ()
let m = date.getUTCMonth () + 1
let d = date.getUTCDate ()
m = m < 10 ? ('0' + m) : m.toString ()
d = d < 10 ? ('0' + d) : d.toString ()
return m + infix + d + infix + y
}

ymd (timestamp, infix = '-') {
infix = infix || ''
let date = new Date (timestamp)
Expand Down
4 changes: 4 additions & 0 deletions php/Exchange.php
Expand Up @@ -509,6 +509,10 @@ public static function parse8601 ($timestamp) {
return $time;
}

public static function dmy ($timestamp, $infix = '-') {
return gmdate ('m' . $infix . 'd' . $infix . 'Y', (int) round ($timestamp / 1000));
}

public static function ymd ($timestamp, $infix = '-') {
return gmdate ('Y' . $infix . 'm' . $infix . 'd', (int) round ($timestamp / 1000));
}
Expand Down
5 changes: 5 additions & 0 deletions python/ccxt/base/exchange.py
Expand Up @@ -671,6 +671,11 @@ def iso8601(timestamp):
utc = datetime.datetime.utcfromtimestamp(int(round(timestamp / 1000)))
return utc.strftime('%Y-%m-%dT%H:%M:%S.%f')[:-6] + "{:<03d}".format(int(timestamp) % 1000) + 'Z'

@staticmethod
def dmy(timestamp, infix='-'):
utc_datetime = datetime.datetime.utcfromtimestamp(int(round(timestamp / 1000)))
return utc_datetime.strftime('%m' + infix + '%d' + infix + '%Y')

@staticmethod
def ymd(timestamp, infix='-'):
utc_datetime = datetime.datetime.utcfromtimestamp(int(round(timestamp / 1000)))
Expand Down

0 comments on commit 5aa4a63

Please sign in to comment.