Search Results

Search found 1902 results on 77 pages for 'calendar'.

Page 26/77 | < Previous Page | 22 23 24 25 26 27 28 29 30 31 32 33  | Next Page >

  • Java giving incorrect year values

    - by whistler
    Something very, very strange is occurring in my program, and I'm wondering if anyone out there has seen this occur before. And, if so, how to fix it. Basically, I am parsing an csv file...no problem there. One column contains a date and I am taking it in as a String and changing to a Date object. Again, no problem there. The code is as follows: SimpleDateFormat dateFormat = new SimpleDateFormat("MM/dd/yy hh:mm"); Date initialDate = new Date(); try { initialDate = dateFormat.parse(rows.get(0)[8]); System.out.println(initialDate); } catch (ParseException e) { // TODO Auto-generated catch block e.printStackTrace(); } Of course, I'm parsing other columns as well (and those are working fine). So, when I run my program for a small csv file (2.8 MB), the dates come out (i.e. are parsed) perfectly. However, when I run the program for a large csv file (25 MB), the dates are a hot mess. For example, take a look at the year values I am getting (the following is just a tiny portion of the println output from the code above): 1000264 at Sun Nov 05 15:30:00 EST 2186 1000320 at Sat Mar 04 17:30:00 EST 2169 1000347 at Sat Apr 01 09:45:00 EDT 2169 1000413 at Tue Jul 09 13:00:00 EDT 2182 1000638 at Fri Dec 11 13:45:00 EST 2167 1000667 at Wed Dec 10 10:00:00 EST 2188 1000690 at Mon Jan 02 13:00:00 EST 2169 1000843 at Thu Feb 11 13:30:00 EST 2196 In actuality, the years are in the realm of 1990-2006 or so. Again, this does not happen with the small csv file. Does anyone know what's going on here and how I can fix it? I need to process the large csv file (the small one was just for testing purposes). By request, here are the actual dates in the csv file and after that the value given by the code above: 5/20/03 15:30 5/20/03 15:30 8/30/04 9:00 8/30/04 9:00 12/20/04 10:30 12/20/04 10:30 Sun Nov 05 15:30:00 EST 2186 Sun Nov 05 15:30:00 EST 2186 Sun Nov 05 15:30:00 EST 2186 Thu Dec 08 09:00:00 EST 2196 Tue Dec 12 10:30:00 EST 2186 Tue Dec 12 10:30:00 EST 2186

    Read the article

  • How do I calculate someone's age in Java?

    - by nojevive
    I want to return an age in years as an int in a Java method. What I have now is the following where getBirthDate() returns a Date object (with the birth date ;-)): public int getAge() { long ageInMillis = new Date().getTime() - getBirthDate().getTime(); Date age = new Date(ageInMillis); return age.getYear(); } But since getYear() is deprecated I'm wondering if there is a better way to do this? I'm not even sure this works correctly, since I have no unit tests in place (yet).

    Read the article

  • Python : How to add month to December 2012 and get January 2013?

    - by daydreamer
    >>> start_date = date(1983, 11, 23) >>> start_date.replace(month=start_date.month+1) datetime.date(1983, 12, 23) This works until the month is <=11, as soon as I do >>> start_date = date(1983, 12, 23) >>> start_date.replace(month=start_date.month+1) Traceback (most recent call last): File "<stdin>", line 1, in <module> ValueError: month must be in 1..12 How can I keep adding months which increments the year when new month is added to December?

    Read the article

  • If either one of both equals

    - by user1620028
    I have start and end dates which are stored in a database in this format: start date= 20121004 //4th October 2012 end date= 20121004 //16th November 2012 so I can use date format: $date = date("Ymd"); // returns: 20121004 to determine when to display and not display to repopulate my update input boxes I use: $start=(str_split($stdate,4));// START DATE: splits stored date into 2x4 ie: 20121209 = 2012 1209 $syr = $start[0];// re first half ie: 2012 which is the year $start2 = $start[1];//re second half ie: 1209 $start3=(str_split($start2,2));// splits second half date into 2x2 ie: 1209 = 12 09 $smth = $start3[0]; // first half = month ie: 12 $sday = $start3[1]; // second half = day ie: 09 $expiry=(str_split($exdate,4)); ///SAME AGAIN FOR EXPIRY DATE ... $xyr = $expiry[0]; $expiry2 = $expiry[1]; $expiry3=(str_split($expiry2,2)); $xmth = $expiry3[0]; $xday = $expiry3[1]; which works fine but I need to repopulate the input boxes for the month showing the date in the database like this <option value="01">January</option`> using if ($smth==01):$month='January'; endif; if ($xmth==01):$month='January'; endif; // if the start and/or expiry month number = 01 display $month as January if ($smth==02):$smonth='February'; endif; if ($xmth==02):$smonth='February'; endif; if ($smth==03):$month='March'; endif; <select name="stmonth" class="input"> <option value="<?=$smth?>"><?=$month?></option> ... </select> is there an easier way to display IF EITHER ONE EQUALS rather than having to write the same line twice once for each $smth AND $xmth ? re: if ($smth **and or** $xmth ==01):$month='January'; endif;

    Read the article

  • "Passing Go" in a (python) date range

    - by anonymous coward
    The Rules: An employee accrues 8 hours of Paid Time Off on the day after each quarter. Quarters, specifically being: Jan 1 - Mar 31 Apr 1 - Jun 30 Jul 1 - Sep 30 Oct 1 - Dec 31 The Problem Employees will use an automated system to request paid time off, possibly occurring in the past, as well as the future. Requests should only be accepted if the employee has (or will have) that time available. For instance, if an employee only has 1 Day of Paid Time Off currently available (currently being January 20th), but is requesting 2 Days of Paid Time Off, beginning September 20th, the system should take into account that the employee would have accrued enough time off by then and allow the request. (Obviously ignoring that the employee may use up existing time before that date). I'm currently using Python, and wondering what the correct approach to something like this would be. I'm assuming that using DateTime objects, and possibly the dateutil module, would help here, but my brain isn't wrapping around this problem for some reason.

    Read the article

  • jquery datepicker - retrieve events and show on hover in dialog - allow the a href to be clicked to access individual event entries

    - by paul724
    Please see this jsfiddle - http://jsfiddle.net/paul724/HXb6v/ What is working: The datepicker displays correctly, picks up the css for todays date and on hover. The dialog box follows the mouse On click the dialog box "stops" and displays a link What I want to achieve When a table cell is hovered over the title of the dialog box shows the date e.g "Mon 8th Oct 2012" When a table cell is hovered over the html of the dialog box shows the events for that day in list format (there is code that succesfully retrieves the first row in function getSelectedDates() ) function getSelectedDates() needs to be called in the hover event - showing multiple events for that date in the dialog box I hope that if we can display the date being hovered over in the title of the dialog then we can use the same information to retrieve the rows from the database to populate the html of the dialog for that day

    Read the article

  • run two thread at the same time in java

    - by user1805005
    i have used timertask to schedule my java program. now when the run method of timertask is in process, i want to run two threads which run at the same time and do different functions. here is my code.. please help me.. import java.util.Calendar; import java.util.Date; import java.util.Timer; import java.util.TimerTask; public class timercheck extends TimerTask{ // my first thread Thread t1 = new Thread(){ public void run(){ for(int i = 1;i <= 10;i++) { System.out.println(i); } } }; // my second thread Thread t2 = new Thread(){ public void run(){ for(int i = 11;i <= 20;i++) { System.out.println(i); } } }; public static void main(String[] args){ long ONCE_PER_DAY = 1000*60*60*24; Calendar calendar = Calendar.getInstance(); calendar.set(Calendar.HOUR_OF_DAY, 12); calendar.set(Calendar.MINUTE, 05); calendar.set(Calendar.SECOND, 00); Date time = calendar.getTime(); TimerTask check = new timercheck(); Timer timer = new Timer(); timer.scheduleAtFixedRate(check, time ,ONCE_PER_DAY); } @Override // run method of timer task public void run() { t1.start(); t2.start(); } }

    Read the article

  • WP7 silverlight custom control using popup

    - by Miloud B.
    Hi guys, I'm creating a custom datepicker, I have a textbox, once clicked it opens a calendar within a popup. What I want to do is change the size of the popup so it shows my whole calendar, but I can't manage to change it..., I've tried using Height, Width, MinHeight, MinWidth... but it doesn't work, the popup keep showing with a fixed size. The thing is that my popup's parent property isn't evaluated since it has expression issues (according to debugger), so I'm sure my popup's parent isn't the main screen( say layout grid). How can I for example make my popup open within a specific context ? This part of my code isn't XAML, it's C# code only and it looks like: using System; using System.Net; using System.Windows; using System.Windows.Controls; using System.Windows.Documents; using System.Windows.Ink; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Animation; using System.Windows.Shapes; using System.Windows.Controls.Primitives; namespace CalendarBranch.components { public class wpDatePicker:TextBox { private CalendarPopup calendar; private Popup popup; public wpDatePicker() { this.calendar = new CalendarPopup(); this.popup = new Popup(); this.popup.Child = this.calendar; this.popup.Margin = new Thickness(0); this.MouseLeftButtonUp += new MouseButtonEventHandler(wpDatePicker_MouseLeftButtonUp); this.calendar.onDateSelect += new EventHandler(onDateSelected); this.IsReadOnly = true; } protected void wpDatePicker_MouseLeftButtonUp(object sender, MouseButtonEventArgs e) { this.popup.Height = this.calendar.Height; this.popup.Width = this.calendar.Width; this.popup.HorizontalAlignment = HorizontalAlignment.Center; this.popup.VerticalAlignment = VerticalAlignment.Center; this.popup.HorizontalOffset = 0; this.popup.VerticalOffset = 0; this.popup.MinHeight = this.calendar.Height; this.popup.MinWidth = this.calendar.Width; this.popup.IsOpen = true; } private void onDateSelected(Object sender, EventArgs ea) { this.Text = this.calendar.SelectedValue.ToShortDateString(); this.popup.IsOpen = false; } } } PS: the class Calendar is simply a UserControl that contains a grid with multiple columns, HyperLinkButtons and TextBlocks, so nothing special. Thank you in advance guys ;) Cheers Miloud B.

    Read the article

  • How do I create a calendar appointment from an e-mail in Outlook 2011?

    - by Jeff O
    How do I create a calendar appointment from an e-mail in Outlook 2011 for Mac? In Windows, the e-mail content and attachments are carried over just by dragging and dropping. Dragging and dropping on the Mac doesn't work. Is there any other function to take an e-mail and make it a calendar appointment? I'm trying to avoid emailing it to myself. Edit: Since someone went to the trouble to make email2task, is it safe to assume this feature is not available otherwise?

    Read the article

  • How do I create a calendar appointment from an e-mail in Outlook 2011 for Mac?

    - by Jeff O
    How do I create a calendar appointment from an e-mail in Outlook 2011 for Mac? In Windows, the e-mail content and attachments are carried over just by dragging and dropping. Dragging and dropping on the Mac doesn't work. Is there any other function to take an e-mail and make it a calendar appointment? I'm trying to avoid emailing it to myself. Edit: Since someone went to the trouble to make email2task, is it safe to assume this feature is not available otherwise?

    Read the article

  • Elegant solution to retrieve custom date and time?

    - by kefs
    I am currently using a date and time picker to retrieve a user-submitted date and time, and then I set a control's text to the date and time selected. I am using the following code: new DatePickerDialog(newlog3.this, d, calDT.get(Calendar.YEAR), calDT.get(Calendar.MONTH), calDT.get(Calendar.DAY_OF_MONTH)).show(); new TimePickerDialog(newlog3.this, t, calDT.get(Calendar.HOUR_OF_DAY), calDT.get(Calendar.MINUTE), true).show(); optCustom.setText(fmtDT.format(calDT.getTime())); Now, while the above code block does bring up the date and time widgets and sets the text, the code block is being executed in full before the user can select the date.. ie: It brings up the date box first, then the time box over that, and then updates the text, all without any user interaction. I would like the date widget to wait to execute the time selector until the date selection is done, and i would like the settext to execute only after the time widget is done. How is this possible? Or is there is a more elegant solution that is escaping me? Edit: This is the code for DatePickerDialog/TimePickerDialog which is located within the class: DatePickerDialog.OnDateSetListener d=new DatePickerDialog.OnDateSetListener() { public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) { calDT.set(Calendar.YEAR, year); calDT.set(Calendar.MONTH, monthOfYear); calDT.set(Calendar.DAY_OF_MONTH, dayOfMonth); //updateLabel(); } }; TimePickerDialog.OnTimeSetListener t=new TimePickerDialog.OnTimeSetListener() { public void onTimeSet(TimePicker view, int hourOfDay, int minute) { calDT.set(Calendar.HOUR_OF_DAY, hourOfDay); calDT.set(Calendar.MINUTE, minute); //updateLabel(); } }; Thanks in advance

    Read the article

  • Is there a working example of using WebDAV for querying Exchange server for calendar items?

    - by Lasse V. Karlsen
    I have tried to hack together a small test project, but it fails with "400 Bad Request" so I'm pretty sure I have done something very basic wrong, but the examples I've found are all in the form of questions, only showing minor pieces of the puzzle, such as a request XML for public folders or whatnot. Is there a complete example somewhere where I can just put in my username and servername and it would list the calendar items in my calendar? This is for C# 3.0/4.0.

    Read the article

  • Combining the jquery Calendar picker with the jquery validation and getting them to play nice?

    - by MBonig
    I'm just starting to get into jquery/javascript programming so this may be a beginner question but I sure can't seem to find anything about it. I have a text field on a form. I've used the JQuery UI Calendar picker to make data entry better. I've also added jquery validation to ensure that if the user enters the date by hand that it's still valid. Here is the html: <input class="datepicker" id="Log_ServiceStartTime_date" name="Log_ServiceStartTime_date" type="text" value="3/16/2010"></input> and javascript: $('form').validate(); $('#Log_ServiceStartTime_date').rules('add','required'); $('#Log_ServiceStartTime_date').rules('add','date'); the problem I'm having is this: If a user puts in a bad date, or no date at all, the validation correctly kicks in and the error description displays. However, if the user clicks on the textbox to bring up the calendar picker and selects a date, the date fills into the field but the validation does not go away. If the user clicks into the textbox and then back out, the validation correctly goes away. How can I get the calendar picker to kick off the validation routine once a date is selected? thanks

    Read the article

  • onDateSet does not get called from DatePickerDialog on tablet

    - by cit
    I am using a DatePickerDialog to prompt the user for a date. It works fine in the simulator and on my Samsung Galaxy Nexus, but onDateSet does not get called on my Samsung Galaxy Tab 2. I noticed, that the dialog is bigger and shows a calendar besides the normal spin view. Can that be the problem? Here is some code: import java.util.Calendar; import java.util.Date; import android.app.DatePickerDialog; import android.app.Dialog; import android.content.DialogInterface; import android.content.Intent; import android.os.Bundle; import android.support.v4.app.DialogFragment; import android.widget.DatePicker; import com.cbit.gtbetapp.R; import com.cbit.gtbetapp.gui.racedata.MeetingDataActivity; import com.cbit.gtbetapp.gui.racedata.MeetingListFragment; import com.cbit.gtbetapp.logic.Utility; public class DatePickerFragment extends DialogFragment implements DatePickerDialog.OnDateSetListener { protected Date date = null; @Override public Dialog onCreateDialog(Bundle savedInstanceState) { // Use the current date as the default date in the picker final Calendar c = Utility.getToday(); int year = c.get(Calendar.YEAR); int month = c.get(Calendar.MONTH); int day = c.get(Calendar.DAY_OF_MONTH); date = c.getTime(); // Create a new instance of DatePickerDialog and return it DatePickerDialog dialog = new DatePickerDialog(getActivity(), this, year, month, day) { @Override public void onDateChanged(DatePicker view, int year, int month, int day) { super.onDateChanged(view, year, month, day); setTitle(getString(R.string.date_picker_title)); } }; dialog.setTitle(getString(R.string.date_picker_title)); dialog.setButton(DatePickerDialog.BUTTON_POSITIVE, getString(android.R.string.ok), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.cancel(); Intent intent = new Intent(getActivity(), MeetingDataActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); intent.putExtra(MeetingListFragment.EXTRA_DATE, date.getTime()); startActivity(intent); } }); dialog.setButton(DatePickerDialog.BUTTON_NEGATIVE, getString(R.string.button_cancel), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.cancel(); } }); return dialog; } public void onDateSet(DatePicker view, int year, int month, int day) { Calendar c = Calendar.getInstance(); c.clear(); c.set(Calendar.YEAR, year); c.set(Calendar.MONTH, month); c.set(Calendar.DAY_OF_MONTH, day); date = c.getTime(); } } What could cause this? A bug in the tablet? Am I missing something? Can anyone think of a workaround? Thanks a lot!

    Read the article

  • Thunderbird/Lightning - How to "accept" an outlook invite and have it added to my google calendar?

    - by Dan
    Thunderbird/Lightning - How to "accept" an outlook invite and have it added to my google calendar? Currently, when I "accept" outlook originated events they are added to my "work" cal by default and not sure how to sync this or have this sync'ed to my google cal. Is there a way to set lightning to add accepted events to my google cal by default, which i've set up remotely using the google provider? Thanks -dm

    Read the article

  • Can I use Google Apps for mail but Exchange for calendar, tasks & contacts?

    - by RexE
    My parents' domain is registered with Google Apps (standard edition). Currently, the only service they are using is email (which they access via IMAP in Outlook). I'd like to register this same domain with a hosted Exchange service so that they can sync their Exchange calendar, tasks, and contacts with Outlook as well. I'd like to keep their email on Google for a couple of reasons. Is this possible?

    Read the article

  • OWA 2010 calendar is it possible to get the 2003 week view back or customize it?

    - by Scott Szretter
    In OWA (Exchange Outlook) 2003 calendar, there was a week view, which was a simple list type view, showing the day, time, and details. In OWA 2010, this is gone and the week view shows a more graphical view with boxes spanning the time slots. It is very difficult to read when you have many appointments. Is there a way to get a list style view, or some way to customize the views in OWA 2010 so I can build one?

    Read the article

  • Problem getting weeks in a month with NSCalendar...

    - by AngrySpade
    I am creating a calendar control of sorts... One thing I need to know is how many weeks are there in a Month... So NSCalendar rangeOfUnit:inUnit:forDate Seems to be exactly what I need... Except I am noticing something that seems off and I can't quite figure out why this is happening... The following code... NSCalendar *calendar = [NSCalendar currentCalendar]; NSDateComponents *dateComponents = [[NSDateComponents alloc] init]; [dateComponents setYear: 2010]; [dateComponents setDay: 1]; for (int x=1; x<=12; x++) { [dateComponents setMonth: x]; NSDate *date = [calendar dateFromComponents:dateComponents]; NSLog(@"Date: %@", date); NSRange range = [calendar rangeOfUnit: NSWeekCalendarUnit inUnit: NSMonthCalendarUnit forDate:date]; NSLog(@"%d Weeks in Month %d", range.length, [dateComponents month]); } Is returning the following debug messages... 2010-03-14 13:08:10.350 Scrap[4256:207] Date: 2010-01-01 00:00:00 -0500 2010-03-14 13:08:10.351 Scrap[4256:207] 5 Weeks in Month 1 2010-03-14 13:08:10.352 Scrap[4256:207] Date: 2010-02-01 00:00:00 -0500 2010-03-14 13:08:10.352 Scrap[4256:207] 4 Weeks in Month 2 2010-03-14 13:08:10.353 Scrap[4256:207] Date: 2010-03-01 00:00:00 -0500 2010-03-14 13:08:10.353 Scrap[4256:207] 5 Weeks in Month 3 2010-03-14 13:08:10.354 Scrap[4256:207] Date: 2010-04-01 00:00:00 -0400 2010-03-14 13:08:10.355 Scrap[4256:207] 5 Weeks in Month 4 2010-03-14 13:08:10.356 Scrap[4256:207] Date: 2010-05-01 00:00:00 -0400 2010-03-14 13:08:10.357 Scrap[4256:207] 5 Weeks in Month 5 2010-03-14 13:08:10.358 Scrap[4256:207] Date: 2010-06-01 00:00:00 -0400 2010-03-14 13:08:10.358 Scrap[4256:207] 5 Weeks in Month 6 2010-03-14 13:08:10.359 Scrap[4256:207] Date: 2010-07-01 00:00:00 -0400 2010-03-14 13:08:10.360 Scrap[4256:207] 5 Weeks in Month 7 2010-03-14 13:08:10.361 Scrap[4256:207] Date: 2010-08-01 00:00:00 -0400 2010-03-14 13:08:10.364 Scrap[4256:207] 5 Weeks in Month 8 2010-03-14 13:08:10.364 Scrap[4256:207] Date: 2010-09-01 00:00:00 -0400 2010-03-14 13:08:10.365 Scrap[4256:207] 5 Weeks in Month 9 2010-03-14 13:08:10.366 Scrap[4256:207] Date: 2010-10-01 00:00:00 -0400 2010-03-14 13:08:10.366 Scrap[4256:207] 5 Weeks in Month 10 2010-03-14 13:08:10.367 Scrap[4256:207] Date: 2010-11-01 00:00:00 -0400 2010-03-14 13:08:10.367 Scrap[4256:207] 5 Weeks in Month 11 2010-03-14 13:08:10.369 Scrap[4256:207] Date: 2010-12-01 00:00:00 -0500 2010-03-14 13:08:10.369 Scrap[4256:207] 52 Weeks in Month 12 I cant quite figure out why I get 52 weeks in month 12. Any clues? Edit on 3/20/2010: Seeing as how I couldnt use rangeOfUnit:inUnit:forDate to calculate the number of weeks in a month. I decided to figure out a different way of calculating the same value. I figured I should do this in a non-Gregorian localized way, so I attempted to start with getting the number of days in a week, but I got the result of 28 days in a week. So I started writing more code to figure out why... I wanted to make sure that the type of NSCalendar that I was playing with was in fact what I was supposed to be getting... And that led me to finding some differences... NSCalendar *currentCalendar = [NSCalendar currentCalendar]; NSLog(@"Calendar with 'currentCalendar' Identifier: %@", [currentCalendar calendarIdentifier]); NSCalendar *calendarWithIdentifier = [[[NSCalendar alloc] initWithCalendarIdentifier: NSGregorianCalendar] autorelease]; NSLog(@"Calendar created with identifier Identifier: %@", [calendarWithIdentifier calendarIdentifier]); NSDate *now = [[NSDate alloc] init]; NSDateComponents *currentMonth = [currentCalendar components: NSMonthCalendarUnit | NSYearCalendarUnit fromDate: now]; NSDate *currentMonthDate = [currentCalendar dateFromComponents: currentMonth]; NSRange daysInWeekRange = [currentCalendar rangeOfUnit: NSDayCalendarUnit inUnit: NSWeekCalendarUnit forDate: currentMonthDate]; NSLog(@"CurrentCalendar: Length:%u Location:%u", daysInWeekRange.length, daysInWeekRange.location); currentMonth = [calendarWithIdentifier components: NSMonthCalendarUnit | NSYearCalendarUnit fromDate: now]; currentMonthDate = [calendarWithIdentifier dateFromComponents: currentMonth]; daysInWeekRange = [calendarWithIdentifier rangeOfUnit: NSDayCalendarUnit inUnit: NSWeekCalendarUnit forDate: currentMonthDate]; NSLog(@"GregorianCalendar: Length:%u Location:%u", daysInWeekRange.length, daysInWeekRange.location); And that got me the following log results... 2010-03-20 21:02:27.245 Scrap[52189:207] Calendar with 'currentCalendar' Identifier: gregorian 2010-03-20 21:02:27.246 Scrap[52189:207] Calendar created with identifier Identifier: gregorian 2010-03-20 21:02:27.248 Scrap[52189:207] CurrentCalendar: Length:28 Location:1 2010-03-20 21:02:27.249 Scrap[52189:207] GregorianCalendar: Length:7 Location:1 Taking direction from @CarlNorum's experience, I compiled the code snippet as a 10.6 Cocoa application, and I got the following... 2010-03-20 21:05:35.636 ScrapCocoa[52238:a0f] Calendar with 'currentCalendar' Identifier: gregorian 2010-03-20 21:05:35.636 ScrapCocoa[52238:a0f] Calendar created with identifier Identifier: gregorian 2010-03-20 21:05:35.637 ScrapCocoa[52238:a0f] CurrentCalendar: Length:6 Location:1 2010-03-20 21:05:35.638 ScrapCocoa[52238:a0f] GregorianCalendar: Length:7 Location:1 I saw hope in that creating a NSCalendar Instance explicitly as a Gregorian Calendar would lead to better results in my original problem... So I modified that original code NSCalendar *currentCalendar = [NSCalendar currentCalendar]; NSLog(@"Calendar with 'currentCalendar' Identifier: %@", [currentCalendar calendarIdentifier]); NSCalendar *calendarWithIdentifier = [[[NSCalendar alloc] initWithCalendarIdentifier: NSGregorianCalendar] autorelease]; NSLog(@"Calendar created with identifier Identifier: %@", [calendarWithIdentifier calendarIdentifier]); NSDateComponents *dateComponents = [[[NSDateComponents alloc] init] autorelease]; [dateComponents setYear: 2010]; [dateComponents setDay: 1]; for (int x=1; x<=12; x++) { [dateComponents setMonth: x]; NSDate *date = [currentCalendar dateFromComponents: dateComponents]; NSRange range = [currentCalendar rangeOfUnit: NSWeekCalendarUnit inUnit: NSMonthCalendarUnit forDate: date]; NSLog(@"CurrentCalendar Date: %@", date); NSLog(@"CurrentCalendar: %d Weeks in Month %d", range.length, [dateComponents month]); date = [calendarWithIdentifier dateFromComponents: dateComponents]; range = [calendarWithIdentifier rangeOfUnit: NSWeekCalendarUnit inUnit: NSMonthCalendarUnit forDate: date]; NSLog(@"GregorianCalendar Date: %@", date); NSLog(@"GregorianCalendar: %d Weeks in Month %d", range.length, [dateComponents month]); } Unfortunately using a calendar created that way did not return a different result. 2010-03-20 21:15:40.465 Scrap[52367:207] Calendar with 'currentCalendar' Identifier: gregorian 2010-03-20 21:15:40.466 Scrap[52367:207] Calendar created with identifier Identifier: gregorian 2010-03-20 21:15:40.468 Scrap[52367:207] CurrentCalendar Date: 2010-01-01 00:00:00 -0500 2010-03-20 21:15:40.468 Scrap[52367:207] CurrentCalendar: 5 Weeks in Month 1 2010-03-20 21:15:40.469 Scrap[52367:207] GregorianCalendar Date: 2010-01-01 00:00:00 -0500 2010-03-20 21:15:40.470 Scrap[52367:207] GregorianCalendar: 5 Weeks in Month 1 2010-03-20 21:15:40.471 Scrap[52367:207] CurrentCalendar Date: 2010-02-01 00:00:00 -0500 2010-03-20 21:15:40.471 Scrap[52367:207] CurrentCalendar: 4 Weeks in Month 2 2010-03-20 21:15:40.472 Scrap[52367:207] GregorianCalendar Date: 2010-02-01 00:00:00 -0500 2010-03-20 21:15:40.473 Scrap[52367:207] GregorianCalendar: 4 Weeks in Month 2 2010-03-20 21:15:40.473 Scrap[52367:207] CurrentCalendar Date: 2010-03-01 00:00:00 -0500 2010-03-20 21:15:40.474 Scrap[52367:207] CurrentCalendar: 5 Weeks in Month 3 2010-03-20 21:15:40.475 Scrap[52367:207] GregorianCalendar Date: 2010-03-01 00:00:00 -0500 2010-03-20 21:15:40.475 Scrap[52367:207] GregorianCalendar: 5 Weeks in Month 3 2010-03-20 21:15:40.476 Scrap[52367:207] CurrentCalendar Date: 2010-04-01 00:00:00 -0400 2010-03-20 21:15:40.477 Scrap[52367:207] CurrentCalendar: 5 Weeks in Month 4 2010-03-20 21:15:40.478 Scrap[52367:207] GregorianCalendar Date: 2010-04-01 00:00:00 -0400 2010-03-20 21:15:40.479 Scrap[52367:207] GregorianCalendar: 5 Weeks in Month 4 2010-03-20 21:15:40.480 Scrap[52367:207] CurrentCalendar Date: 2010-05-01 00:00:00 -0400 2010-03-20 21:15:40.480 Scrap[52367:207] CurrentCalendar: 5 Weeks in Month 5 2010-03-20 21:15:40.482 Scrap[52367:207] GregorianCalendar Date: 2010-05-01 00:00:00 -0400 2010-03-20 21:15:40.482 Scrap[52367:207] GregorianCalendar: 5 Weeks in Month 5 2010-03-20 21:15:40.483 Scrap[52367:207] CurrentCalendar Date: 2010-06-01 00:00:00 -0400 2010-03-20 21:15:40.483 Scrap[52367:207] CurrentCalendar: 5 Weeks in Month 6 2010-03-20 21:15:40.484 Scrap[52367:207] GregorianCalendar Date: 2010-06-01 00:00:00 -0400 2010-03-20 21:15:40.485 Scrap[52367:207] GregorianCalendar: 5 Weeks in Month 6 2010-03-20 21:15:40.485 Scrap[52367:207] CurrentCalendar Date: 2010-07-01 00:00:00 -0400 2010-03-20 21:15:40.486 Scrap[52367:207] CurrentCalendar: 5 Weeks in Month 7 2010-03-20 21:15:40.486 Scrap[52367:207] GregorianCalendar Date: 2010-07-01 00:00:00 -0400 2010-03-20 21:15:40.487 Scrap[52367:207] GregorianCalendar: 5 Weeks in Month 7 2010-03-20 21:15:40.488 Scrap[52367:207] CurrentCalendar Date: 2010-08-01 00:00:00 -0400 2010-03-20 21:15:40.488 Scrap[52367:207] CurrentCalendar: 5 Weeks in Month 8 2010-03-20 21:15:40.489 Scrap[52367:207] GregorianCalendar Date: 2010-08-01 00:00:00 -0400 2010-03-20 21:15:40.489 Scrap[52367:207] GregorianCalendar: 5 Weeks in Month 8 2010-03-20 21:15:40.490 Scrap[52367:207] CurrentCalendar Date: 2010-09-01 00:00:00 -0400 2010-03-20 21:15:40.491 Scrap[52367:207] CurrentCalendar: 5 Weeks in Month 9 2010-03-20 21:15:40.491 Scrap[52367:207] GregorianCalendar Date: 2010-09-01 00:00:00 -0400 2010-03-20 21:15:40.492 Scrap[52367:207] GregorianCalendar: 5 Weeks in Month 9 2010-03-20 21:15:40.493 Scrap[52367:207] CurrentCalendar Date: 2010-10-01 00:00:00 -0400 2010-03-20 21:15:40.493 Scrap[52367:207] CurrentCalendar: 5 Weeks in Month 10 2010-03-20 21:15:40.494 Scrap[52367:207] GregorianCalendar Date: 2010-10-01 00:00:00 -0400 2010-03-20 21:15:40.494 Scrap[52367:207] GregorianCalendar: 5 Weeks in Month 10 2010-03-20 21:15:40.495 Scrap[52367:207] CurrentCalendar Date: 2010-11-01 00:00:00 -0400 2010-03-20 21:15:40.496 Scrap[52367:207] CurrentCalendar: 5 Weeks in Month 11 2010-03-20 21:15:40.496 Scrap[52367:207] GregorianCalendar Date: 2010-11-01 00:00:00 -0400 2010-03-20 21:15:40.497 Scrap[52367:207] GregorianCalendar: 5 Weeks in Month 11 2010-03-20 21:15:40.498 Scrap[52367:207] CurrentCalendar Date: 2010-12-01 00:00:00 -0500 2010-03-20 21:15:40.498 Scrap[52367:207] CurrentCalendar: 52 Weeks in Month 12 2010-03-20 21:15:40.499 Scrap[52367:207] GregorianCalendar Date: 2010-12-01 00:00:00 -0500 2010-03-20 21:15:40.500 Scrap[52367:207] GregorianCalendar: 52 Weeks in Month 12 Compiling the code for Cocoa just for kicks, was actually amusing... As the results are really really different 2010-03-20 21:11:24.610 ScrapCocoa[52313:a0f] Calendar with 'currentCalendar' Identifier: gregorian 2010-03-20 21:11:24.611 ScrapCocoa[52313:a0f] Calendar created with identifier Identifier: gregorian 2010-03-20 21:11:24.613 ScrapCocoa[52313:a0f] CurrentCalendar Date: 2010-01-01 00:00:00 -0500 2010-03-20 21:11:24.613 ScrapCocoa[52313:a0f] CurrentCalendar: 6 Weeks in Month 1 2010-03-20 21:11:24.614 ScrapCocoa[52313:a0f] GregorianCalendar Date: 2010-01-01 00:00:00 -0500 2010-03-20 21:11:24.615 ScrapCocoa[52313:a0f] GregorianCalendar: 5 Weeks in Month 1 2010-03-20 21:11:24.616 ScrapCocoa[52313:a0f] CurrentCalendar Date: 2010-02-01 00:00:00 -0500 2010-03-20 21:11:24.616 ScrapCocoa[52313:a0f] CurrentCalendar: 5 Weeks in Month 2 2010-03-20 21:11:24.617 ScrapCocoa[52313:a0f] GregorianCalendar Date: 2010-02-01 00:00:00 -0500 2010-03-20 21:11:24.618 ScrapCocoa[52313:a0f] GregorianCalendar: 4 Weeks in Month 2 2010-03-20 21:11:24.619 ScrapCocoa[52313:a0f] CurrentCalendar Date: 2010-03-01 00:00:00 -0500 2010-03-20 21:11:24.619 ScrapCocoa[52313:a0f] CurrentCalendar: 5 Weeks in Month 3 2010-03-20 21:11:24.620 ScrapCocoa[52313:a0f] GregorianCalendar Date: 2010-03-01 00:00:00 -0500 2010-03-20 21:11:24.621 ScrapCocoa[52313:a0f] GregorianCalendar: 5 Weeks in Month 3 2010-03-20 21:11:24.622 ScrapCocoa[52313:a0f] CurrentCalendar Date: 2010-04-01 00:00:00 -0400 2010-03-20 21:11:24.622 ScrapCocoa[52313:a0f] CurrentCalendar: 5 Weeks in Month 4 2010-03-20 21:11:24.623 ScrapCocoa[52313:a0f] GregorianCalendar Date: 2010-04-01 00:00:00 -0400 2010-03-20 21:11:24.623 ScrapCocoa[52313:a0f] GregorianCalendar: 5 Weeks in Month 4 2010-03-20 21:11:24.624 ScrapCocoa[52313:a0f] CurrentCalendar Date: 2010-05-01 00:00:00 -0400 2010-03-20 21:11:24.625 ScrapCocoa[52313:a0f] CurrentCalendar: 6 Weeks in Month 5 2010-03-20 21:11:24.625 ScrapCocoa[52313:a0f] GregorianCalendar Date: 2010-05-01 00:00:00 -0400 2010-03-20 21:11:24.626 ScrapCocoa[52313:a0f] GregorianCalendar: 6 Weeks in Month 5 2010-03-20 21:11:24.627 ScrapCocoa[52313:a0f] CurrentCalendar Date: 2010-06-01 00:00:00 -0400 2010-03-20 21:11:24.627 ScrapCocoa[52313:a0f] CurrentCalendar: 5 Weeks in Month 6 2010-03-20 21:11:24.628 ScrapCocoa[52313:a0f] GregorianCalendar Date: 2010-06-01 00:00:00 -0400 2010-03-20 21:11:24.628 ScrapCocoa[52313:a0f] GregorianCalendar: 5 Weeks in Month 6 2010-03-20 21:11:24.629 ScrapCocoa[52313:a0f] CurrentCalendar Date: 2010-07-01 00:00:00 -0400 2010-03-20 21:11:24.630 ScrapCocoa[52313:a0f] CurrentCalendar: 5 Weeks in Month 7 2010-03-20 21:11:24.630 ScrapCocoa[52313:a0f] GregorianCalendar Date: 2010-07-01 00:00:00 -0400 2010-03-20 21:11:24.631 ScrapCocoa[52313:a0f] GregorianCalendar: 5 Weeks in Month 7 2010-03-20 21:11:24.632 ScrapCocoa[52313:a0f] CurrentCalendar Date: 2010-08-01 00:00:00 -0400 2010-03-20 21:11:24.632 ScrapCocoa[52313:a0f] CurrentCalendar: 5 Weeks in Month 8 2010-03-20 21:11:24.633 ScrapCocoa[52313:a0f] GregorianCalendar Date: 2010-08-01 00:00:00 -0400 2010-03-20 21:11:24.633 ScrapCocoa[52313:a0f] GregorianCalendar: 6 Weeks in Month 8 2010-03-20 21:11:24.634 ScrapCocoa[52313:a0f] CurrentCalendar Date: 2010-09-01 00:00:00 -0400 2010-03-20 21:11:24.635 ScrapCocoa[52313:a0f] CurrentCalendar: 5 Weeks in Month 9 2010-03-20 21:11:24.636 ScrapCocoa[52313:a0f] GregorianCalendar Date: 2010-09-01 00:00:00 -0400 2010-03-20 21:11:24.636 ScrapCocoa[52313:a0f] GregorianCalendar: 5 Weeks in Month 9 2010-03-20 21:11:24.637 ScrapCocoa[52313:a0f] CurrentCalendar Date: 2010-10-01 00:00:00 -0400 2010-03-20 21:11:24.637 ScrapCocoa[52313:a0f] CurrentCalendar: 6 Weeks in Month 10 2010-03-20 21:11:24.638 ScrapCocoa[52313:a0f] GregorianCalendar Date: 2010-10-01 00:00:00 -0400 2010-03-20 21:11:24.639 ScrapCocoa[52313:a0f] GregorianCalendar: 5 Weeks in Month 10 2010-03-20 21:11:24.640 ScrapCocoa[52313:a0f] CurrentCalendar Date: 2010-11-01 00:00:00 -0400 2010-03-20 21:11:24.640 ScrapCocoa[52313:a0f] CurrentCalendar: 5 Weeks in Month 11 2010-03-20 21:11:24.641 ScrapCocoa[52313:a0f] GregorianCalendar Date: 2010-11-01 00:00:00 -0400 2010-03-20 21:11:24.641 ScrapCocoa[52313:a0f] GregorianCalendar: 5 Weeks in Month 11 2010-03-20 21:11:24.642 ScrapCocoa[52313:a0f] CurrentCalendar Date: 2010-12-01 00:00:00 -0500 2010-03-20 21:11:24.642 ScrapCocoa[52313:a0f] CurrentCalendar: 5 Weeks in Month 12 2010-03-20 21:11:24.643 ScrapCocoa[52313:a0f] GregorianCalendar Date: 2010-12-01 00:00:00 -0500 2010-03-20 21:11:24.644 ScrapCocoa[52313:a0f] GregorianCalendar: 5 Weeks in Month 12 I think this is when I give up...

    Read the article

< Previous Page | 22 23 24 25 26 27 28 29 30 31 32 33  | Next Page >