Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #35588

Re: Parsing calendar weeks to LocalDates with DateTimeFormatter

From Dr J R Stockton <reply1600@merlyn.demon.co.uk.invalid>
Newsgroups comp.lang.java.programmer
Subject Re: Parsing calendar weeks to LocalDates with DateTimeFormatter
Date 2016-09-11 16:43 +0100
Organization Home
Message-ID <wByFVjdwuX1XFw5r@invalid.uk.co.demon.merlyn.invalid> (permalink)
References <87inu8gpqv.fsf@gnu.org> <XSD8BfGz2y0XFwl7@invalid.uk.co.demon.merlyn.invalid> <week-20160910025343@ram.dialup.fu-berlin.de>

Show all headers | View raw


In comp.lang.java.programmer message <week-20160910025343@ram.dialup.fu-
berlin.de>, Sat, 10 Sep 2016 01:56:51, Stefan Ram <ram@zedat.fu-
berlin.de> posted:

>Dr J R Stockton <reply1600@merlyn.demon.co.uk.invalid> writes:
>>Firstly, you need to say, clearly, what your definition of Week
>>Numbering is.
>
>  In VBA, there is
>
>Function DatePart
>( Interval As String,
>  Date,
>  [FirstDayOfWeek As VbDayOfWeek = vbSunday],
>  [FirstWeekOfYear As VbFirstWeekOfYear = vbFirstJan1] )
>
>  , with VbDayOfWeek containing
>
>vbUseSystemDayofWeek, vbSunday, vbMonday, vbTuesday, vbWednesday,
>vbThursday, vbFriday, and vbSaturday
>
>  and VbFirstweekofyear containing
>
>vbUseSystem, vbFirstJan1, vbFirstFourDays, and vbFirstFullWeek.
>
>  So, one can adjust the first day of the week and the rule
>  for the first week. Impressive design, but reportedly
>
>VBA.DateTime.DatePart( "ww", #2059-12-30#, vbSunday, vbFirstFourDays )
>
>  gives 53, which reportedly is wrong. It reportedly should be 1 instead.
>  This reportedly is a bug that reportedly repeats every 28 years.
>
>  So, in the end, one still has to program it oneself in VBA
>  if one wants a bug-free implementation.


Not _oneself_; it is sufficient for one individual to have done it.

I have done it for VBscript; Java could be different.  I see Java has
DateSerial, I suppose equivalent.

See, preferably using a browser which runs VBscript, in
http://web.archive.org/web/20150511204319/http://www.merlyn.demon.co.uk/
vb-date2.htm>.

The 28-year interval only applies between missing leap years; and there
are three errors in every such interval - 3 or 4 per century.  Another
error repeats every 400 years; next 2101-01-02.

Microsoft have a bug fix, which that page links to, for the 3/28-year
errors.

For VBscript code written and tested in IE8, see, in the cited page, the
script section beginning with the line
        Sub WeekNumJRS(Tdy, YNo, WNo, DoW) '' Tdy is CDate in; Y W D out

Any code giving the ISO 8601 Week Number for a date needs to give also
the year number; and it might as well give also the day-of-week number
(Sunday=7, as earlier established in the Book of Genesis).

If you produce corresponding well-tested similar code in Java, I'd be
pleased to have a URL for it that I may cite.  E-address implied by
signature + headers.

-- 
 (c) John Stockton, near London.                Mail ?.?.Stockton@physics.org
  Web  <                              > - FAQish topics, acronyms, and links.

Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Parsing calendar weeks to LocalDates with DateTimeFormatter Tassilo Horn <tsdh@gnu.org> - 2016-09-07 08:58 +0200
  Re: Parsing calendar weeks to LocalDates with DateTimeFormatter Tassilo Horn <tsdh@gnu.org> - 2016-09-07 10:11 +0200
  Re: Parsing calendar weeks to LocalDates with DateTimeFormatter Dr J R Stockton <reply1600@merlyn.demon.co.uk.invalid> - 2016-09-09 22:46 +0100
    Re: Parsing calendar weeks to LocalDates with DateTimeFormatter Dr J R Stockton <reply1600@merlyn.demon.co.uk.invalid> - 2016-09-11 16:43 +0100
      Re: Parsing calendar weeks to LocalDates with DateTimeFormatter Lew <lewbloch@gmail.com> - 2016-09-13 17:50 -0700
        Re: Parsing calendar weeks to LocalDates with DateTimeFormatter Dr J R Stockton <reply1600@merlyn.demon.co.uk.invalid> - 2016-09-17 19:34 +0100
    Re: Parsing calendar weeks to LocalDates with DateTimeFormatter Tassilo Horn <tsdh@gnu.org> - 2016-09-12 09:18 +0200
      Re: Parsing calendar weeks to LocalDates with DateTimeFormatter Dr J R Stockton <reply1600@merlyn.demon.co.uk.invalid> - 2016-09-13 23:39 +0100

csiph-web