This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type RemoveNull = { | |
(x: null): undefined | |
<T> (x: T): T | |
<T> (x: T[]): T[] | |
} | |
/** | |
* null を取り除く | |
* x が null の場合は undefined を返す | |
* x が Array の場合は null を undefined に変換した Array を返す |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export type IntervalUnit = 'hour' | 'minute' | 'second' | 'millisecond' | |
export type Interval = { | |
time?: number | |
unit?: IntervalUnit | |
} | |
type StartOptions = { | |
immediately?: boolean | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension NSDateFormatter { | |
/** | |
カレンダー, ロケール, タイムゾーンを指定して初期化 | |
@param calendarIdentifier カレンダーの識別子 (NSCalendarIdentifierGregorian...) | |
@param localeIdentifier ロケールの識別子 (ja_JP, en_US_POSIX...) | |
@param abbreviation タイムゾーンの略称 (GMT, JST...) | |
*/ | |
convenience init(calendarIdentifier: String, localeIdentifier: String = "ja_JP", abbreviation: String = "GMT") { | |
self.init() | |
if let cal = NSCalendar(calendarIdentifier: calendarIdentifier) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Pattern A func | |
func rgb(red r: CGFloat, green g: CGFloat, blue b: CGFloat) -> UIColor { | |
return rgba(red: r, green: g, blue: b, alpha: 1.0) | |
} | |
func rgba(red r: CGFloat, green g: CGFloat, blue b: CGFloat, alpha a: CGFloat) -> UIColor { | |
return UIColor(red: r/255.0, green: g/255.0, blue: b/255.0, alpha: a) | |
} | |
// Pattern B Extension |