daylight savings confusion

34 views
Skip to first unread message

Kevin Moran

unread,
Feb 29, 2012, 4:03:41 PM2/29/12
to coreplot...@googlegroups.com
Hi all,

Does anyone have any example code of how to deal with daylight savings? I'm still very confused about how to get the graph to work with it. I'd want the graph to be:

1:00am 2:00am 2:00am 3:00am

How do I accomplish this?

Thanks a lot,
K

Craig Hockenberry

unread,
Mar 2, 2012, 7:23:51 PM3/2/12
to coreplot-discuss
It should work with the CPTCalendarFormatter I just posted if you use
a NSHourCalendarUnit.

-ch

Kevin Moran

unread,
Mar 2, 2012, 10:16:43 PM3/2/12
to coreplot...@googlegroups.com
Hey Craig,

I don't see that on the CorePlot Documentation under "Class List". How would it be used? Right now I am using a dateformatter. However, when you zoom in the values will change. So zoomed out it will be every 6 hours, then as you zoom in it'll go to 3 hrs, then 1 hr, then 30 min. Will that still work?

Also does this rely on the reference date being set to 12:00pm? That seems to be a comment in all of the demos using dates on the x-axis

Thanks,
K

> --
> You received this message because you are subscribed to the Google Groups "coreplot-discuss" group.
> To post to this group, send email to coreplot...@googlegroups.com.
> To unsubscribe from this group, send email to coreplot-discu...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/coreplot-discuss?hl=en.
>

Craig Hockenberry

unread,
Mar 3, 2012, 1:38:15 PM3/3/12
to coreplot-discuss
It's not a part of the Core Plot project (yet). You can download it
here:

http://files.iconfactory.net/craig/whatever/CPTCalendarFormatter.zip

You use it like this:

CPTXYAxis *x = axisSet.xAxis;
{
x.majorIntervalLength = CPTDecimalFromInteger(1);
NSDateFormatter *dateFormatter = [[[NSDateFormatter
alloc] init]
autorelease];
dateFormatter.dateStyle = kCFDateFormatterShortStyle;
CPTCalendarFormatter *calendarFormatter =
[[[CPTCalendarFormatter
alloc] initWithDateFormatter:dateFormatter] autorelease];
calendarFormatter.referenceDate = [NSDate date];
calendarFormatter.referenceCalendarUnit =
NSHourCalendarUnit;
x.labelFormatter = calendarFormatter;
}

Each hour increment along the x axis should be computed into the
correct NSDate and formatted (using the current NSCalendar which knows
about daylight savings.)

-ch

Kevin Moran

unread,
Mar 3, 2012, 6:57:20 PM3/3/12
to coreplot...@googlegroups.com
Thanks Craig.

Since my timezone is sent to me from the server (I'm not using the phone's current timezone), would i just set that timezone in the dateformatter and then things should just work? This is all for iOS by the way if that makes any difference.

I'll take a look at the CPTCalendarFormatter. Thanks!

K

Reply all
Reply to author
Forward
0 new messages