(fmt_out: str, is_naive: bool)
| 238 | ], |
| 239 | ) |
| 240 | def test_strftime(fmt_out: str, is_naive: bool) -> None: |
| 241 | if "%Z" in fmt_out: |
| 242 | pytest.xfail("%Z output different between python and rust chrono") |
| 243 | if "%z" in fmt_out and is_naive: |
| 244 | pytest.xfail("%z (timezone) failing for naive timestamp") # FIXME |
| 245 | data = [ |
| 246 | "1960-02-03 08:00:00.000000000", |
| 247 | "2008-02-29 08:00:00.000000000", |
| 248 | "2023-03-25 12:00:00.000000000", |
| 249 | "2023-03-25 12:00:00.000000001", |
| 250 | "2023-03-25 12:00:00.123456789", |
| 251 | "2023-03-25 16:43:21.000123000", |
| 252 | "2023-03-25 17:00:01.987000000", |
| 253 | "2023-03-25 23:59:59.999999999", |
| 254 | "2023-03-26 01:59:59.999999999", |
| 255 | "2023-03-26 03:00:00.000000001", |
| 256 | "2023-03-26 04:00:00.000000001", |
| 257 | "2023-03-26 12:00:00.000000001", |
| 258 | "2123-03-26 12:00:00.000000001", |
| 259 | ] |
| 260 | fmt_in = "%Y-%m-%d %H:%M:%S.%f" |
| 261 | if not is_naive: |
| 262 | data = [entry + "-02:00" for entry in data] |
| 263 | fmt_in += "%z" |
| 264 | df = pd.DataFrame({"ts": pd.to_datetime(data, format=fmt_in)}) |
| 265 | if is_naive: |
| 266 | df_converted = df |
| 267 | else: |
| 268 | df_converted = pd.DataFrame({"ts": df.ts.dt.tz_convert(tz.UTC)}) |
| 269 | df_new = pd.DataFrame({"txt": df_converted.ts.dt.strftime(fmt_out)}) |
| 270 | table = table_from_pandas(df) |
| 271 | fmt_out_pw = fmt_out.replace("%f", "%6f") |
| 272 | fmt_out_pw = fmt_out_pw.replace("%%6f", "%%f") |
| 273 | table_pw = table.select(txt=table.ts.dt.strftime(fmt_out_pw)) |
| 274 | table_pd = table_from_pandas(df_new) |
| 275 | assert_table_equality(table_pw, table_pd) |
| 276 | |
| 277 | |
| 278 | def test_strftime_with_format_in_column() -> None: |
nothing calls this directly
no test coverage detected