week-number

What settings in Mac OS X affect the `Locale` and `Calendar` inside Java?

流过昼夜 提交于 2019-11-30 21:47:20
These two questions prompted me to wonder what settings in Mac OS X affect the Locale and Calendar defaults and behavior in Java: WEEK_OF_YEAR inconsistent on different machines Why would Calendar.getInstance() fail to use the default locale? Key in those discussions are these two properties in Calendar: firstDayOfWeek minimalDaysInFirstWeek The default for both those values is 1 in Java 7 & 8 when run on a default United States. What can cause other values to be reported? I've seen some peculiar behavior as to what affects these properties of java.util.Calendar. Conclusions The facts

Is .NET giving me the wrong week number for Dec. 29th 2008?

懵懂的女人 提交于 2019-11-30 08:32:52
According to the official (gregorian) calendar , the week number for 29/12/2008 is 1, because after the last day of week 52 (i.e. 28/12) there are three or less days left in the year. Kinda weird, but OK, rules are rules. So according to this calendar, we have these boundary values for 2008/2009 28/12 is week 52 29/12 is week 1 1/1 is week 1 8/1 is week 2 C# offers a GregorianCalendar class, that has a function GetWeekOfYear(date, rule, firstDayOfWeek) . The parameter rule is an enumeration with 3 possible values: FirstDay, FirstFourWeekDay, FirstFullWeek . From what I've understood I should

Calculate the week number (0-53) in year

偶尔善良 提交于 2019-11-30 06:47:25
I have a dataset with locations and dates. I would like to calculate week of the year as number (00–53) but using Thursday as the first day of the week. The data looks like this: location <- c(a,b,a,b,a,b) date <- c("04-01-2013","26-01-2013","03-02-2013","09-02-2013","20-02-2013","03-03-2013") mydf <- data.frame(location, date) mydf I know that there is strftime function for calculating week of year but it is only possible to use Monday or Sunday as the first day of the week. Any help would be highly appreciated. Just add 4 to the Date-formatted values: > mydf$Dt <- as.Date(mydf$date, format="

What settings in Mac OS X affect the `Locale` and `Calendar` inside Java?

Deadly 提交于 2019-11-30 05:39:27
问题 These two questions prompted me to wonder what settings in Mac OS X affect the Locale and Calendar defaults and behavior in Java: WEEK_OF_YEAR inconsistent on different machines Why would Calendar.getInstance() fail to use the default locale? Key in those discussions are these two properties in Calendar: firstDayOfWeek minimalDaysInFirstWeek The default for both those values is 1 in Java 7 & 8 when run on a default United States. What can cause other values to be reported? 回答1: I've seen some

Moment.js get the week number based on a specific day (also past years)

血红的双手。 提交于 2019-11-30 05:38:31
How could I get from moment JS the week number from a date in the past only from a moment formatted object from a day selected? $(document).ready(function(){ var weeknumber = moment("12-25-1995", "MM-DD-YYYY").week(); console.log(weeknumber); }); According momentjs docs: Because different locales define week of year numbering differently, Moment.js added moment#week to get/set the localized week of the year. The week of the year varies depending on which day is the first day of the week (Sunday, Monday, etc), and which week is the first week of the year. For example, in the United States,

Get next/previous ISO week and year in PHP

大兔子大兔子 提交于 2019-11-29 15:57:56
I need a function that takes an ISO week and an ISO year as parameter and returns the next ISO week and year (and a function that returns the previous ISO week/year). So answer for 4 day so i give it a shot: <?php // Start with Timstamp 0, else the seconds might be off $x = new DateTime("1970-01-01 00:00:00"); $x->setISODate(2010, 2); echo $x->format("Y-m-d H:i:s"); // 2010-01-11 00:00:00 $x->modify("+1 week"); echo $x->format("Y-m-d H:i:s"); // 2010-01-18 00:00:00 // Now for the next ISO Week echo $x->format("Y W"); // 2010 03 Hope that helps, else let me know :) 来源: https://stackoverflow.com

Is .NET giving me the wrong week number for Dec. 29th 2008?

北城余情 提交于 2019-11-29 11:40:17
问题 According to the official (gregorian) calendar, the week number for 29/12/2008 is 1, because after the last day of week 52 (i.e. 28/12) there are three or less days left in the year. Kinda weird, but OK, rules are rules. So according to this calendar, we have these boundary values for 2008/2009 28/12 is week 52 29/12 is week 1 1/1 is week 1 8/1 is week 2 C# offers a GregorianCalendar class, that has a function GetWeekOfYear(date, rule, firstDayOfWeek) . The parameter rule is an enumeration

How to get year-sensitive calendar week ? date(“W”) gives back 52 for 1st of January

穿精又带淫゛_ 提交于 2019-11-29 00:10:35
As the headline says, PHP's date("W") function gives back the calendar week (for the current day). Unfortunatly it gives back 52 or 53 for the first day(s) of most years. This is, in a simple thinking way, correct, but very annoying, as January 1st of 2012 is not calendar week 52, it's NOT a calendar week of the current year. Most calendars define this as week 0 or week 52 of the previous year. This is very tricky when you group each day of the year by their calendar week: 1st of January 2012 and 31st of December 2012 are both put into the same calendar week group. So my question is: Is there

calculate the month from the year and week number in excel

筅森魡賤 提交于 2019-11-28 18:28:16
In Excel 2007 I have a Year number and Week number and I want to work out the Month number. The catch is that in my case the start of every week is a monday, so some weeks will overlap through the years. Examples: Year: 2012 Week 1 started: Monday 2nd January Sunday 1st January was in week 52 of 2011 So given the below: Year: 2011 Week: 10 How can I work out that week 10 started on 7th March and therefore week 10 was in Month number 3. Thanks for any help on this. I suggest the following approach Determine the (ISO) week of January 1st (see this page ) [in cell C4 ] =INT((B4-DATE(YEAR(B4

Calculating the number of weeks in a year with Ruby

爱⌒轻易说出口 提交于 2019-11-28 12:17:37
Is there a way in Ruby to calculate the number of weeks(ISO 8601) for a given year? I'm currently using a lookup table and I'd like to stop using it. def num_weeks(year = Date.today.year) Date.new(year, 12, 28).cweek # magick date! end long_iso_years = (2000..2400).select{|year| num_weeks(year) == 53} Yields the same list as wikipedia require 'date' def num_weeks(year = Date.today.year) # all years starting with Thursday, and leap years starting with Wednesday have 53 weeks # http://en.wikipedia.org/wiki/ISO_week_date#Last_week d = Date.new(year, 1, 1) return 53 if d.wday == 4 return 53 if d