Dual-Life / Time-Piece

Object Oriented time objects
Other
15 stars 33 forks source link

strptime parsing of %W and %w broken #55

Open stoecker opened 2 years ago

stoecker commented 2 years ago

perl -e 'use Time::Piece; print Time::Piece->strptime("2021 47 1","%Y %W %w");' should output 2021-11-22, but outputs 2021-01-01

using the same with C

#define _XOPEN_SOURCE
#include <stdio.h>
#include <time.h>

int main(void)
{
  struct tm t;
  printf("%s\n", strptime("2021 47 1", "%Y %W %w", &t));

  printf("%d-%02d-%02d\n", 1900+t.tm_year, t.tm_mon+1, t.tm_mday);
}

outputs 2021-11-22

It seems the _strptime in Piece.xs is improperly implemented.