Talk:Last Friday of each month

From Rosetta Code
Revision as of 00:00, 9 November 2011 by rosettacode>Ledrug (→‎C version: 3.4.4 is ancient: libc bug?)

task name

of year? not of month?--eMBee 13:43, 7 November 2011 (UTC)

It looks like it's all of the last fridays of the months of a given year? --Rdm 14:52, 7 November 2011 (UTC)
yes, exactly, which is why i find the current title confusing. something like Last Friday of every month would be more to the point. otherwise, i thought the original title was sufficient. something about fridays. it is clear enough that this is about the calendar. is more details really needed?--eMBee 14:59, 7 November 2011 (UTC)

C version

Building the C version under cygwin (gcc 3.4.4), I get:

<lang bash>$ make last_fridays cc last_fridays.c -o last_fridays

$ ./last_fridays 2011 2011-01-27 2011-02-24 2011-03-31 2011-04-28 2011-05-26 2011-06-30 2011-07-28 2011-08-25 2011-09-29 2011-10-27 2011-11-24 2011-12-29

$ ./last_fridays 2012 2012-01-27 2012-02-24 2012-03-30 2012-04-27 2012-05-25 2012-06-29 2012-07-27 2012-08-31 2012-09-28 2012-10-26 2012-11-30 2012-12-28

$ cc --version cc (GCC) 3.4.4 (cygming special, gdc 0.12, using dmd 0.125) Copyright (C) 2004 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.</lang>

The C entry currently shows different results for 2011, but I cannot reproduce them. --Rdm 23:25, 8 November 2011 (UTC)

I'll assume it's a cygwin bug for now. For the record, can you change two lines to
<lang>sprintf(buf, "%d-01-01 09:01:01", y);

strptime(buf, "%Y-%m-%d %H:%M:%S", &tm);</lang> and see how it does?