本文整理匯總了Python中corehq.util.timezones.conversions.ServerTime.isoformat方法的典型用法代碼示例。如果您正苦於以下問題:Python ServerTime.isoformat方法的具體用法?Python ServerTime.isoformat怎麽用?Python ServerTime.isoformat使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類corehq.util.timezones.conversions.ServerTime
的用法示例。
在下文中一共展示了ServerTime.isoformat方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_server_to_phone
# 需要導入模塊: from corehq.util.timezones.conversions import ServerTime [as 別名]
# 或者: from corehq.util.timezones.conversions.ServerTime import isoformat [as 別名]
def test_server_to_phone(self):
cases = [
('2015-03-20T12:00:00', pytz.FixedOffset(-4 * 60),
'2015-03-20T08:00:00'),
('2015-03-21T00:30:00', pytz.FixedOffset(-4 * 60),
'2015-03-20T20:30:00'),
]
for in_, tz, out in cases:
server_dt = dateutil.parser.parse(in_)
phone_dt = ServerTime(server_dt).phone_time(tz).done()
if phone_timezones_have_been_processed():
# no change
self.assertEqual(phone_dt.isoformat(), in_)
else:
self.assertEqual(phone_dt.isoformat(), out)
示例2: test_server_to_user
# 需要導入模塊: from corehq.util.timezones.conversions import ServerTime [as 別名]
# 或者: from corehq.util.timezones.conversions.ServerTime import isoformat [as 別名]
def test_server_to_user(self):
cases = [
('2015-03-20T12:00:00', pytz.FixedOffset(-4 * 60),
'2015-03-20T08:00:00-04:00'),
('2015-03-21T00:30:00', pytz.FixedOffset(-4 * 60),
'2015-03-20T20:30:00-04:00'),
]
for in_, tz, out in cases:
server_dt = dateutil.parser.parse(in_)
user_dt = ServerTime(server_dt).user_time(tz).done()
self.assertEqual(user_dt.isoformat(), out)
示例3: test_server_to_phone
# 需要導入模塊: from corehq.util.timezones.conversions import ServerTime [as 別名]
# 或者: from corehq.util.timezones.conversions.ServerTime import isoformat [as 別名]
def test_server_to_phone(self):
cases = [
('2015-03-20T12:00:00', pytz.FixedOffset(-4 * 60),
'2015-03-20T08:00:00'),
('2015-03-21T00:30:00', pytz.FixedOffset(-4 * 60),
'2015-03-20T20:30:00'),
]
for in_, tz, out in cases:
server_dt = dateutil.parser.parse(in_)
if get_timezone_data_migration_complete():
phone_dt = server_dt
else:
phone_dt = ServerTime(server_dt).phone_time(tz).done()
self.assertEqual(phone_dt.isoformat(), out)