view dstep/foundation/NSCalendarDate.d @ 16:19885b43130e

Huge update, the bridge actually works now
author Jacob Carlborg <doob@me.com>
date Sun, 03 Jan 2010 22:06:11 +0100
parents 7ff919f595d5
children b9de51448c6b
line wrap: on
line source

/**
 * Copyright: Copyright (c) 2009 Jacob Carlborg.
 * Authors: Jacob Carlborg
 * Version: Initial created: Aug 3, 2009 
 * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0)
 */
module dstep.foundation.NSCalendarDate;

import dstep.foundation.NSArray;
import dstep.foundation.NSDate;
import dstep.foundation.NSObjCRuntime;
import dstep.foundation.NSString;
import dstep.foundation.NSTimeZone;
import dstep.objc.bridge.Bridge;
import dstep.objc.objc;

const TNSNaturalLangage = `

	static Object dateWithNaturalLanguageString (NSString string)
	{
		return invokeObjcSuperClass!(Object, "dateWithNaturalLanguageString:", NSString)(string);
	}

	static Object dateWithNaturalLanguageString (NSString string, Object locale)
	{
		return invokeObjcSuperClass!(Object, "dateWithNaturalLanguageString:locale:", NSString, Object)(string, locale);
	}
`;

const TNSCalendarDateExtras = `

	static Object dateWithString (NSString aString)
	{
		return invokeObjcSuperClass!(Object, "dateWithString:", NSString)(aString);
	}

	Object initWithString (NSString description)
	{
		return invokeObjcSelf!(Object, "initWithString:", NSString)(description);
	}

	this (NSString description)
	{
		typeof(this).alloc.initWithString(description);
	}

	NSCalendarDate dateWithCalendarFormat (NSString format, NSTimeZone aTimeZone)
	{
		return invokeObjcSelf!(NSCalendarDate, "dateWithCalendarFormat:timeZone:", NSString, NSTimeZone)(format, aTimeZone);
	}

	NSString descriptionWithLocale (Object locale)
	{
		return invokeObjcSelf!(NSString, "descriptionWithLocale:", Object)(locale);
	}

	NSString descriptionWithCalendarFormat (NSString format, NSTimeZone aTimeZone, Object locale)
	{
		return invokeObjcSelf!(NSString, "descriptionWithCalendarFormat:timeZone:locale:", NSString, NSTimeZone, Object)(format, aTimeZone, locale);
	}
`;

class NSCalendarDate : NSDate
{
	mixin (ObjcWrap);
	
	this ()
	{
		super(typeof(this).alloc.init.objcObject);
	}
	
	typeof(this) init ()
	{
		return invokeObjcSelf!(typeof(this), "init");
	}

	static Object dateWithYear (NSInteger year, NSUInteger month, NSUInteger day, NSUInteger hour, NSUInteger minute, NSUInteger second, NSTimeZone aTimeZone)
	{
		return invokeObjcSuperClass!(Object, "dateWithYear:month:day:hour:minute:second:timeZone:", NSInteger, NSUInteger, NSUInteger, NSUInteger, NSUInteger, NSUInteger, NSTimeZone)(year, month, day, hour, minute, second, aTimeZone);
	}

	static Object dateWithString (NSString description, NSString format)
	{
		return invokeObjcSuperClass!(Object, "dateWithString:calendarFormat:", NSString, NSString)(description, format);
	}

	static Object dateWithString (NSString description, NSString format, Object locale)
	{
		return invokeObjcSuperClass!(Object, "dateWithString:calendarFormat:locale:", NSString, NSString, Object)(description, format, locale);
	}

	static Object calendarDate ()
	{
		return invokeObjcSuperClass!(Object, "calendarDate");
	}

	Object initWithYear (NSInteger year, NSUInteger month, NSUInteger day, NSUInteger hour, NSUInteger minute, NSUInteger second, NSTimeZone aTimeZone)
	{
		return invokeObjcSelf!(Object, "initWithYear:month:day:hour:minute:second:timeZone:", NSInteger, NSUInteger, NSUInteger, NSUInteger, NSUInteger, NSUInteger, NSTimeZone)(year, month, day, hour, minute, second, aTimeZone);
	}

	this (NSInteger year, NSUInteger month, NSUInteger day, NSUInteger hour, NSUInteger minute, NSUInteger second, NSTimeZone aTimeZone)
	{
		typeof(this).alloc.initWithYear(year, month, day, hour, minute, second, aTimeZone);
	}

	Object initWithString (NSString description)
	{
		return invokeObjcSelf!(Object, "initWithString:", NSString)(description);
	}

	this (NSString description)
	{
		typeof(this).alloc.initWithString(description);
	}

	Object initWithString (NSString description, NSString format)
	{
		return invokeObjcSelf!(Object, "initWithString:calendarFormat:", NSString, NSString)(description, format);
	}

	this (NSString description, NSString format)
	{
		typeof(this).alloc.initWithString(description, format);
	}

	Object initWithString (NSString description, NSString format, Object locale)
	{
		return invokeObjcSelf!(Object, "initWithString:calendarFormat:locale:", NSString, NSString, Object)(description, format, locale);
	}

	this (NSString description, NSString format, Object locale)
	{
		typeof(this).alloc.initWithString(description, format, locale);
	}

	NSTimeZone timeZone ()
	{
		return invokeObjcSelf!(NSTimeZone, "timeZone");
	}

	void setTimeZone (NSTimeZone aTimeZone)
	{
		return invokeObjcSelf!(void, "setTimeZone:", NSTimeZone)(aTimeZone);
	}

	NSString calendarFormat ()
	{
		return invokeObjcSelf!(NSString, "calendarFormat");
	}

	void setCalendarFormat (NSString format)
	{
		return invokeObjcSelf!(void, "setCalendarFormat:", NSString)(format);
	}

	NSInteger yearOfCommonEra ()
	{
		return invokeObjcSelf!(NSInteger, "yearOfCommonEra");
	}

	NSInteger monthOfYear ()
	{
		return invokeObjcSelf!(NSInteger, "monthOfYear");
	}

	NSInteger dayOfMonth ()
	{
		return invokeObjcSelf!(NSInteger, "dayOfMonth");
	}

	NSInteger dayOfWeek ()
	{
		return invokeObjcSelf!(NSInteger, "dayOfWeek");
	}

	NSInteger dayOfYear ()
	{
		return invokeObjcSelf!(NSInteger, "dayOfYear");
	}

	NSInteger dayOfCommonEra ()
	{
		return invokeObjcSelf!(NSInteger, "dayOfCommonEra");
	}

	NSInteger hourOfDay ()
	{
		return invokeObjcSelf!(NSInteger, "hourOfDay");
	}

	NSInteger minuteOfHour ()
	{
		return invokeObjcSelf!(NSInteger, "minuteOfHour");
	}

	NSInteger secondOfMinute ()
	{
		return invokeObjcSelf!(NSInteger, "secondOfMinute");
	}

	NSCalendarDate dateByAddingYears (NSInteger year, NSInteger month, NSInteger day, NSInteger hour, NSInteger minute, NSInteger second)
	{
		id result = invokeObjcSelf!(id, "dateByAddingYears:months:days:hours:minutes:seconds:", NSInteger, NSInteger, NSInteger, NSInteger, NSInteger, NSInteger)(year, month, day, hour, minute, second);
		return result is this.objcObject ? this : (result !is null ? new NSCalendarDate(result) : null);
	}

	void years (NSInteger* yp, NSInteger* mop, NSInteger* dp, NSInteger* hp, NSInteger* mip, NSInteger* sp, NSCalendarDate date)
	{
		return invokeObjcSelf!(void, "years:months:days:hours:minutes:seconds:sinceDate:", NSInteger*, NSInteger*, NSInteger*, NSInteger*, NSInteger*, NSInteger*, NSCalendarDate)(yp, mop, dp, hp, mip, sp, date);
	}

	NSString description ()
	{
		return invokeObjcSelf!(NSString, "description");
	}

	NSString descriptionWithLocale (Object locale)
	{
		return invokeObjcSelf!(NSString, "descriptionWithLocale:", Object)(locale);
	}

	NSString descriptionWithCalendarFormat (NSString format)
	{
		return invokeObjcSelf!(NSString, "descriptionWithCalendarFormat:", NSString)(format);
	}

	NSString descriptionWithCalendarFormat (NSString format, Object locale)
	{
		return invokeObjcSelf!(NSString, "descriptionWithCalendarFormat:locale:", NSString, Object)(format, locale);
	}
}