diff dstep/foundation/NSCalendarDate.d @ 14:89f3c3ef1fd2

Added the Foundation framework
author Jacob Carlborg <doob@me.com>
date Mon, 03 Aug 2009 15:23:15 +0200
parents
children 7ff919f595d5
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dstep/foundation/NSCalendarDate.d	Mon Aug 03 15:23:15 2009 +0200
@@ -0,0 +1,250 @@
+/**
+ * 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.NSString;
+import dstep.foundation.NSTimeZone;
+import dstep.objc.bridge.Bridge;
+import dstep.objc.objc : id;
+
+class NSCalendarDate : NSDate
+{
+	mixin ObjcWrap;
+
+	static Object dateWithYear (NSInteger year, NSUInteger month, NSUInteger day, NSUInteger hour, NSUInteger minute, NSUInteger second, NSTimeZone aTimeZone)
+	{
+		return invokeObjcSelfClass!(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 invokeObjcSelfClass!(Object, "dateWithString:calendarFormat:", NSString, NSString)(description, format);
+	}
+
+	static Object dateWithString (NSString description, NSString format, Object locale)
+	{
+		return invokeObjcSelfClass!(Object, "dateWithString:calendarFormat:locale:", NSString, NSString, Object)(description, format, locale);
+	}
+
+	static Object calendarDate ()
+	{
+		return invokeObjcSelfClass!(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)
+	{
+		objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass);
+		id result = Bridge.invokeObjcMethod!(id, "initWithYear:month:day:hour:minute:second:timeZone:", NSInteger, NSUInteger, NSUInteger, NSUInteger, NSUInteger, NSUInteger, NSTimeZone)(objcObject, year, month, day, hour, minute, second, aTimeZone);
+
+		if (result)
+			objcObject = ret;
+
+		dObject = this;
+	}
+
+	Object initWithString (NSString description)
+	{
+		return invokeObjcSelf!(Object, "initWithString:", NSString)(description);
+	}
+
+	this (NSString description)
+	{
+		objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass);
+		id result = Bridge.invokeObjcMethod!(id, "initWithString:", NSString)(objcObject, description);
+
+		if (result)
+			objcObject = ret;
+
+		dObject = this;
+	}
+
+	Object initWithString (NSString description, NSString format)
+	{
+		return invokeObjcSelf!(Object, "initWithString:calendarFormat:", NSString, NSString)(description, format);
+	}
+
+	this (NSString description, NSString format)
+	{
+		objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass);
+		id result = Bridge.invokeObjcMethod!(id, "initWithString:calendarFormat:", NSString, NSString)(objcObject, description, format);
+
+		if (result)
+			objcObject = ret;
+
+		dObject = this;
+	}
+
+	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)
+	{
+		objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass);
+		id result = Bridge.invokeObjcMethod!(id, "initWithString:calendarFormat:locale:", NSString, NSString, Object)(objcObject, description, format, locale);
+
+		if (result)
+			objcObject = ret;
+
+		dObject = this;
+	}
+
+	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, secondreturn 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);
+	}
+}
+
+template TNSNaturalLangage ()
+{
+	static Object dateWithNaturalLanguageString (NSString string)
+	{
+		return invokeObjcSelfClass!(Object, "dateWithNaturalLanguageString:", NSString)(string);
+	}
+
+	static Object dateWithNaturalLanguageString (NSString string, Object locale)
+	{
+		return invokeObjcSelfClass!(Object, "dateWithNaturalLanguageString:locale:", NSString, Object)(string, locale);
+	}
+}
+
+template TNSCalendarDateExtras ()
+{
+	static Object dateWithString (NSString aString)
+	{
+		return invokeObjcSelfClass!(Object, "dateWithString:", NSString)(aString);
+	}
+
+	Object initWithString (NSString description)
+	{
+		return invokeObjcSelf!(Object, "initWithString:", NSString)(description);
+	}
+
+	this (NSString description)
+	{
+		objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass);
+		id result = Bridge.invokeObjcMethod!(id, "initWithString:", NSString)(objcObject, description);
+
+		if (result)
+			objcObject = ret;
+
+		dObject = this;
+	}
+
+	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);
+	}
+}
+