|
9 | 9 | You can find more information on http://presbrey.mit.edu/PyDTA and
|
10 | 10 | http://www.statsmodels.org/devel/
|
11 | 11 | """
|
12 |
| -import numpy as np |
13 |
| - |
14 |
| -import sys |
| 12 | +import datetime |
15 | 13 | import struct
|
16 |
| -from dateutil.relativedelta import relativedelta |
| 14 | +import sys |
17 | 15 |
|
18 |
| -from pandas.types.common import (is_categorical_dtype, is_datetime64_dtype, |
19 |
| - _ensure_object) |
| 16 | +import numpy as np |
| 17 | +from dateutil.relativedelta import relativedelta |
| 18 | +from pandas.lib import max_len_string_array, infer_dtype |
| 19 | +from pandas.tslib import NaT, Timestamp |
20 | 20 |
|
| 21 | +import pandas as pd |
| 22 | +from pandas import compat, to_timedelta, to_datetime, isnull, DatetimeIndex |
| 23 | +from pandas.compat import lrange, lmap, lzip, text_type, string_types, range, \ |
| 24 | + zip, BytesIO |
21 | 25 | from pandas.core.base import StringMixin
|
22 | 26 | from pandas.core.categorical import Categorical
|
23 | 27 | from pandas.core.frame import DataFrame
|
24 | 28 | from pandas.core.series import Series
|
25 |
| -import datetime |
26 |
| -from pandas import compat, to_timedelta, to_datetime, isnull, DatetimeIndex |
27 |
| -from pandas.compat import lrange, lmap, lzip, text_type, string_types, range, \ |
28 |
| - zip, BytesIO |
29 |
| -from pandas.util.decorators import Appender |
30 |
| -import pandas as pd |
31 |
| - |
32 | 29 | from pandas.io.common import get_filepath_or_buffer, BaseIterator
|
33 |
| -from pandas.lib import max_len_string_array, infer_dtype |
34 |
| -from pandas.tslib import NaT, Timestamp |
| 30 | +from pandas.types.common import (is_categorical_dtype, is_datetime64_dtype, |
| 31 | + _ensure_object) |
| 32 | +from pandas.util.decorators import Appender |
35 | 33 |
|
36 | 34 | _version_error = ("Version of given Stata file is not 104, 105, 108, "
|
37 | 35 | "111 (Stata 7SE), 113 (Stata 8/9), 114 (Stata 10/11), "
|
@@ -2157,9 +2155,14 @@ def _write_header(self, data_label=None, time_stamp=None):
|
2157 | 2155 | time_stamp = datetime.datetime.now()
|
2158 | 2156 | elif not isinstance(time_stamp, datetime.datetime):
|
2159 | 2157 | raise ValueError("time_stamp should be datetime type")
|
2160 |
| - self._file.write( |
2161 |
| - self._null_terminate(time_stamp.strftime("%d %b %Y %H:%M")) |
2162 |
| - ) |
| 2158 | + # Avoid locale-specific month conversion |
| 2159 | + months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', |
| 2160 | + 'Sep', 'Oct', 'Nov', 'Dec'] |
| 2161 | + month_lookup = {i + 1: month for i, month in enumerate(months)} |
| 2162 | + ts = (time_stamp.strftime("%d ") + |
| 2163 | + month_lookup[time_stamp.month] + |
| 2164 | + time_stamp.strftime(" %Y %H:%M")) |
| 2165 | + self._file.write(self._null_terminate(ts)) |
2163 | 2166 |
|
2164 | 2167 | def _write_descriptors(self, typlist=None, varlist=None, srtlist=None,
|
2165 | 2168 | fmtlist=None, lbllist=None):
|
|
0 commit comments