Exemple #1
0
    def _buildFullDateAndTimeStrings(self, commandDic, timezoneStr):
        '''
		This method ensures that the full command string is unified whatever the completness of the
		dated/time components specified in the request by the user.

		Ex: btc usd 1/1 bitfinex or btc usd 1/01/18 bitfinex or btc usd 1/1 12:23 bitfinex all return
			a full commaand of btc usd 01/01/18 00:00 bitfinex, btc usd 01/01/18 12:23 bitfinex
			respectively.

		This is important since the ful command string is what is stored in the command history list, with
		no duplicates. Otherwxise, btc usd 1/1 00:00 bitfinex and btc usd 01/01/18 00:00 bitfinex would
		be stored as 2 entries !

		:param commandDic:
		:param timezoneStr:
		:seqdiag_return requestDateDMY, requestDateHM
		:return:
		'''
        day = commandDic[CommandPrice.DAY]
        month = commandDic[CommandPrice.MONTH]
        year = commandDic[CommandPrice.YEAR]
        hour = commandDic[CommandPrice.HOUR]
        minute = commandDic[CommandPrice.MINUTE]

        requestDateDMY, requestDateHM = DateTimeUtil.formatPrintDateTimeFromStringComponents(
            day, month, year, hour, minute, timezoneStr,
            self.configurationMgr.dateTimeFormat)

        from seqdiagbuilder import SeqDiagBuilder
        SeqDiagBuilder.recordFlow()

        return requestDateDMY, requestDateHM
    def testFormatPrintDateFromStringComponentsTimeDayMonthTwoDigitsYearHourMinute(
            self):
        dayStr = '17'
        monthStr = '11'
        yearStr = '18'
        hourStr = '8'
        minuteStr = '7'
        timezoneStr = LOCAL_TIME_ZONE
        dateTimeFormat = 'DD/MM/YY HH:mm'

        dateDMY, dateHM = DateTimeUtil.formatPrintDateTimeFromStringComponents(
            dayStr, monthStr, yearStr, hourStr, minuteStr, timezoneStr,
            dateTimeFormat)

        self.assertEqual('17/11/18', dateDMY)
        self.assertEqual('08:07', dateHM)
    def testFormatPrintDateFromStringComponentsTimeDayMonthOnlyWithZero(self):
        dayStr = '04'
        monthStr = '09'
        yearStr = None
        hourStr = None
        minuteStr = None
        timezoneStr = LOCAL_TIME_ZONE
        dateTimeFormat = 'DD/MM/YY HH:mm'

        now = DateTimeUtil.localNow(timezoneStr)
        nowYearStr, nowMonthStr, nowDayStr, nowHourStr, nowMinuteStr = UtilityForTest.getFormattedDateTimeComponentsForArrowDateTimeObj(
            now)

        dateDMY, dateHM = DateTimeUtil.formatPrintDateTimeFromStringComponents(
            dayStr, monthStr, yearStr, hourStr, minuteStr, timezoneStr,
            dateTimeFormat)

        self.assertEqual('04/09/' + nowYearStr, dateDMY)
        self.assertEqual('00:00', dateHM)