@@ -46,8 +46,6 @@ def __init__(self, measurement_name):
46
46
self ._name = measurement_name
47
47
self ._time = None
48
48
self ._write_precision = DEFAULT_WRITE_PRECISION
49
-
50
- self ._parse_function = get_date_parse_function ()
51
49
pass
52
50
53
51
def time (self , time , write_precision = DEFAULT_WRITE_PRECISION ):
@@ -84,7 +82,7 @@ def to_line_protocol(self):
84
82
_fields = _append_fields (self ._fields )
85
83
if not _fields :
86
84
return ""
87
- _time = _append_time (self ._time , self ._write_precision , self . _parse_function )
85
+ _time = _append_time (self ._time , self ._write_precision )
88
86
89
87
return f"{ _measurement } { _tags } { _fields } { _time } "
90
88
@@ -131,10 +129,10 @@ def _append_fields(fields):
131
129
return f"{ ',' .join (_return )} "
132
130
133
131
134
- def _append_time (time , write_precision , _parse_function ):
132
+ def _append_time (time , write_precision ):
135
133
if time is None :
136
134
return ''
137
- return f" { int (_convert_timestamp (time , write_precision , _parse_function ))} "
135
+ return f" { int (_convert_timestamp (time , write_precision ))} "
138
136
139
137
140
138
def _escape_key (tag ):
@@ -152,12 +150,12 @@ def _escape_string(value):
152
150
return str (value ).translate (_ESCAPE_STRING )
153
151
154
152
155
- def _convert_timestamp (timestamp , precision = DEFAULT_WRITE_PRECISION , _parse_function = parser . parse ):
153
+ def _convert_timestamp (timestamp , precision = DEFAULT_WRITE_PRECISION ):
156
154
if isinstance (timestamp , Integral ):
157
155
return timestamp # assume precision is correct if timestamp is int
158
156
159
157
if isinstance (timestamp , str ):
160
- timestamp = _parse_function (timestamp )
158
+ timestamp = get_date_parse_function () (timestamp )
161
159
162
160
if isinstance (timestamp , timedelta ) or isinstance (timestamp , datetime ):
163
161
0 commit comments