tracker issue : CF-4100144

select a category, or use search below
(searches all categories and all time range)
Title:

[ANeff] ER for: weekYear(dateTime[, "iso"])

| View in Tracker

Status/Resolution/Reason: Needs Review//

Reporter/Name(from Bugbase): Aaron Neff / Aaron Neff (Aaron Neff)

Created: 12/15/2015

Components: Language

Versions: 11.0

Failure Type: Enhancement Request

Found In Build/Fixed In Build: CF11_Final /

Priority/Frequency: Trivial / Unknown

Locale/System: English / Win All

Vote Count: 0

Java supports ISO8601's "week year". CF should support the same via weekYear(dateTime[, "iso"]).

Suggestion:
weekYear(dateTime)//returns 1 for the week having January 1
weekYear(dateTime, "iso")//returns 1 for the week with the year's first Thursday (the formal ISO definition)

----------------------------- Additional Watson Details -----------------------------

Watson Bug ID:	4100144

External Customer Info:
External Company:  
External Customer Name: Aaron Neff
External Customer Email:

Attachments:

Comments:

Aaron, Thanks for raising this. The current method week returns the week of the year, and CF2016 (ER #CF-3917706) already supports "iso" as the second argument. So, hows the behavior of the proposed method "weekYear" going to be any different? dateTime = createDate(2016,2,3); writeOutput(dateFormat(dateTime, "dd-mmmm,yyyy") & "<br>"); writeOutput(week(dateTime) & "<br>"); writeOutput(week(dateTime, "iso") & "<br>"); outputs : 03-February,2016 6 5
Comment by Piyush K.
5087 | December 22, 2015 04:54:41 AM GMT
Hi Piyush, You're very welcome and thanks for the follow-up. The issue is to get the ISO week year, for weeks at the beginning/end of the calendar year. The calendar year may differ from the ISO week year. Example: <cfscript> dateTime = createDate(2016,1,3); writeOutput(week(dateTime, "iso") & "<br>");//returns 53 (good) writeOutput(weekYear(dateTime, "iso"));//would return 2015 (per this ER) </cfscript> The ISO week for that date is "2015-W53". Meaning, the ISO 8601 "week year" is 2015. But, year(dateTime) will return 2016. Currently there is no function to get the ISO "week year" 2015. Thanks!, -Aaron
Comment by External U.
5088 | December 22, 2015 05:17:41 AM GMT
Hi Aaron, Isn't this something that can be deducted with some simple script like so: _dt = createDateTime(2016, 1, 3, 0, 0, 0); if(dayOfYear(_dt) LTE 3 && week(_dt, 'ISO') EQ 53) writeOutput("The year in which the week starts is: " & (Year(_dt)-1)); else writeOutput("The year in which the week starts is: " & Year(_dt)); Just wondering what kind of situations and how often, one may need to know the year of the week, to warrant a CF supplied method. I'll put this up for review, but I not sure if we'll take this up. Perhaps you can weigh in with some practical use cases.
Comment by Piyush K.
5089 | December 22, 2015 11:16:13 PM GMT
Hi Piyush, An "ISO week date" is, for example, string "2015-W53". Code needing a date's "ISO week" likely also needs the date's "ISO week year". B/c an ISO week date cannot be expressed with just the week or the year - it requires both parts. The code would also need to check the last week of the year (not just the 1st week), so would look more like: _dt = createDateTime(2016, 1, 3, 0, 0, 0); if(month(_dt) EQ 1 && week(_dt, 'ISO') EQ 53) writeOutput("The year in which the week starts is: " & (Year(_dt)-1)); else if(month(_dt) EQ 12 && week(_dt, 'ISO') EQ 1) writeOutput("The year in which the week starts is: " & (Year(_dt)+1)); else writeOutput("The year in which the week starts is: " & Year(_dt)); I just don't know the point of a CF supplied method to get the week part but no CF supplied method to get the year part. That's only half of the info. If weekYear() won't be added, then the "iso" attribute should be removed from all date/time functions. Then users can just use dateTimeFormat() masks to get the ISO week number, ISO week year number and ISO day of week. It just seems odd to use a formatting function to get all that info tho, and it's much more typing. But adding an "iso" parameter to the other date/time functions is an incomplete solution if week year can only obtained via dateTimeFormat() or requiring developers to write their own UDF for that 1 piece of info. Thanks!, -Aaron
Comment by External U.
5090 | December 23, 2015 12:37:54 AM GMT
NOTE: ISO week numbering system was recently introduced in ISO 8601:2015. While I'd prefer that this functionality built-in, I think I'd rather have these functions be available as non-black-boxed/built-in UDFs so that they can be updated quickly by responsive CFML-Community-at-Large members when errors are reported. This would prevent developers from having to pay additional licensing fees for the future versions of CF that finally address & fix the bugs. I've been impressed with the DateJS library and its ability to parse more dates that various Java libraries I've tested. (It already works with many IOS8601-formatted dates and text values like "today".) It'd be awesome if something like it were ported to Java/CFML. http://www.datejs.com/
Comment by External U.
5091 | December 23, 2015 09:22:49 AM GMT