How to use the dateparser.conf.settings.replace function in dateparser

To help you get started, we’ve selected a few dateparser examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github scrapinghub / dateparser / tests / test_settings.py View on Github external
def given_configurations(self, confs):
        if 'TIMEZONE' not in confs:
            confs.update({'TIMEZONE': 'local'})

        self.confs = settings.replace(**confs)
github scrapinghub / dateparser / tests / test_freshness_date_parser.py View on Github external
def test_freshness_date_with_to_timezone_setting(self):
        _settings = settings.replace(**{
            'TIMEZONE': 'local',
            'TO_TIMEZONE': 'UTC',
            'RELATIVE_BASE': datetime(2014, 9, 1, 10, 30)
        })

        parser = dateparser.freshness_date_parser.FreshnessDateDataParser()
        parser.get_local_tz = Mock(return_value=pytz.timezone('US/Eastern'))
        result = parser.get_date_data('1 minute ago', _settings)
        result = result['date_obj']
        self.assertEqual(result.date(), date(2014, 9, 1))
        self.assertEqual(result.time(), time(14, 29))