Mercurial > projects > dwt-mac
diff dwt/internal/cocoa/NSTimeZone.d @ 0:380af2bdd8e5
Upload of whole dwt tree
author | Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com> |
---|---|
date | Sat, 09 Aug 2008 17:00:02 +0200 |
parents | |
children | 8b48be5454ce |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/internal/cocoa/NSTimeZone.d Sat Aug 09 17:00:02 2008 +0200 @@ -0,0 +1,214 @@ +/******************************************************************************* + * Copyright (c) 2007 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + * + * Port to the D Programming language: + * Jacob Carlborg <jacob.carlborg@gmail.com> + *******************************************************************************/ +module dwt.internal.cocoa.NSTimeZone; + +import dwt.internal.cocoa.id; +import dwt.internal.cocoa.NSArray; +import dwt.internal.cocoa.NSData; +import dwt.internal.cocoa.NSDate; +import dwt.internal.cocoa.NSDictionary; +import dwt.internal.cocoa.NSInteger; +import dwt.internal.cocoa.NSLocale; +import dwt.internal.cocoa.NSObject; +import dwt.internal.cocoa.NSString; +import dwt.internal.cocoa.OS; +import objc = dwt.internal.objc.runtime; + +enum NSTimeZoneNameStyle : NSInteger +{ + NSTimeZoneNameStyleStandard, + NSTimeZoneNameStyleShortStandard, + NSTimeZoneNameStyleDaylightSaving, + NSTimeZoneNameStyleShortDaylightSaving +} + +alias NSTimeZoneNameStyle.NSTimeZoneNameStyleStandard NSTimeZoneNameStyleStandard; +alias NSTimeZoneNameStyle.NSTimeZoneNameStyleShortStandard NSTimeZoneNameStyleShortStandard; +alias NSTimeZoneNameStyle.NSTimeZoneNameStyleDaylightSaving NSTimeZoneNameStyleDaylightSaving; +alias NSTimeZoneNameStyle.NSTimeZoneNameStyleShortDaylightSaving NSTimeZoneNameStyleShortDaylightSaving; + +public class NSTimeZone : NSObject +{ + + public this () + { + super(); + } + + public this (objc.id id) + { + super(id); + } + + public NSString abbreviation () + { + objc.id result = OS.objc_msgSend(this.id, OS.sel_abbreviation); + return result !is null ? new NSString(result) : null; + } + + public static NSDictionary abbreviationDictionary () + { + objc.id result = OS.objc_msgSend(OS.class_NSTimeZone, OS.sel_abbreviationDictionary); + return result !is null ? new NSDictionary(result) : null; + } + + public NSString abbreviationForDate (NSDate aDate) + { + objc.id result = OS.objc_msgSend(this.id, OS.sel_abbreviationForDate_1, aDate !is null ? aDate.id : null); + return result !is null ? new NSString(result) : null; + } + + public NSData data () + { + objc.id result = OS.objc_msgSend(this.id, OS.sel_data); + return result !is null ? new NSData(result) : null; + } + + public NSTimeInterval daylightSavingTimeOffset () + { + return cast(NSTimeInterval) OS.objc_msgSend_fpret(this.id, OS.sel_daylightSavingTimeOffset); + } + + public NSTimeInterval daylightSavingTimeOffsetForDate (NSDate aDate) + { + return cast(NSTimeInterval) OS.objc_msgSend_fpret(this.id, OS.sel_daylightSavingTimeOffsetForDate_1, aDate !is null ? aDate.id : null); + } + + public static NSTimeZone defaultTimeZone () + { + objc.id result = OS.objc_msgSend(OS.class_NSTimeZone, OS.sel_defaultTimeZone); + return result !is null ? new NSTimeZone(result) : null; + } + + public NSString description () + { + objc.id result = OS.objc_msgSend(this.id, OS.sel_description); + return result !is null ? new NSString(result) : null; + } + + public id initWithName_ (NSString tzName) + { + objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithName_1, tzName !is null ? tzName.id : null); + return result !is null ? new id(result) : null; + } + + public id initWithName_data_ (NSString tzName, NSData aData) + { + objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithName_1data_1, tzName !is null ? tzName.id : null, aData !is null ? aData.id : null); + return result !is null ? new id(result) : null; + } + + public bool isDaylightSavingTime () + { + return OS.objc_msgSend(this.id, OS.sel_isDaylightSavingTime) !is null; + } + + public bool isDaylightSavingTimeForDate (NSDate aDate) + { + return OS.objc_msgSend(this.id, OS.sel_isDaylightSavingTimeForDate_1, aDate !is null ? aDate.id : null) !is null; + } + + public bool isEqualToTimeZone (NSTimeZone aTimeZone) + { + return OS.objc_msgSend(this.id, OS.sel_isEqualToTimeZone_1, aTimeZone !is null ? aTimeZone.id : null) !is null; + } + + public static NSArray knownTimeZoneNames () + { + objc.id result = OS.objc_msgSend(OS.class_NSTimeZone, OS.sel_knownTimeZoneNames); + return result !is null ? new NSArray(result) : null; + } + + public static NSTimeZone localTimeZone () + { + objc.id result = OS.objc_msgSend(OS.class_NSTimeZone, OS.sel_localTimeZone); + return result !is null ? new NSTimeZone(result) : null; + } + + public NSString localizedName (NSTimeZoneNameStyle style, NSLocale locale) + { + objc.id result = OS.objc_msgSend(this.id, OS.sel_localizedName_1locale_1, style, locale !is null ? locale.id : null); + return result !is null ? new NSString(result) : null; + } + + public NSString name () + { + objc.id result = OS.objc_msgSend(this.id, OS.sel_name); + return result !is null ? new NSString(result) : null; + } + + public NSDate nextDaylightSavingTimeTransition () + { + objc.id result = OS.objc_msgSend(this.id, OS.sel_nextDaylightSavingTimeTransition); + return result !is null ? new NSDate(result) : null; + } + + public NSDate nextDaylightSavingTimeTransitionAfterDate (NSDate aDate) + { + objc.id result = OS.objc_msgSend(this.id, OS.sel_nextDaylightSavingTimeTransitionAfterDate_1, aDate !is null ? aDate.id : null); + return result !is null ? new NSDate(result) : null; + } + + public static void resetSystemTimeZone () + { + OS.objc_msgSend(OS.class_NSTimeZone, OS.sel_resetSystemTimeZone); + } + + public NSInteger secondsFromGMT () + { + return cast(NSInteger) OS.objc_msgSend(this.id, OS.sel_secondsFromGMT); + } + + public NSInteger secondsFromGMTForDate (NSDate aDate) + { + return cast(NSInteger) OS.objc_msgSend(this.id, OS.sel_secondsFromGMTForDate_1, aDate !is null ? aDate.id : null); + } + + public static void setDefaultTimeZone (NSTimeZone aTimeZone) + { + OS.objc_msgSend(OS.class_NSTimeZone, OS.sel_setDefaultTimeZone_1, aTimeZone !is null ? aTimeZone.id : null); + } + + public static NSTimeZone systemTimeZone () + { + objc.id result = OS.objc_msgSend(OS.class_NSTimeZone, OS.sel_systemTimeZone); + return result !is null ? new NSTimeZone(result) : null; + } + + public static id timeZoneForSecondsFromGMT (NSInteger seconds) + { + objc.id result = OS.objc_msgSend(OS.class_NSTimeZone, OS.sel_timeZoneForSecondsFromGMT_1, seconds); + return result !is null ? new id(result) : null; + } + + public static id timeZoneWithAbbreviation (NSString abbreviation) + { + objc.id result = OS.objc_msgSend(OS.class_NSTimeZone, OS.sel_timeZoneWithAbbreviation_1, abbreviation !is null ? abbreviation.id : null); + return result !is null ? new id(result) : null; + } + + public static id static_timeZoneWithName_ (NSString tzName) + { + objc.id result = OS.objc_msgSend(OS.class_NSTimeZone, OS.sel_timeZoneWithName_1, tzName !is null ? tzName.id : null); + return result !is null ? new id(result) : null; + } + + public static id static_timeZoneWithName_data_ (NSString tzName, NSData aData) + { + objc.id result = OS.objc_msgSend(OS.class_NSTimeZone, OS.sel_timeZoneWithName_1data_1, tzName !is null ? tzName.id : null, + aData !is null ? aData.id : null); + return result !is null ? new id(result) : null; + } + +}