This file contains hidden or 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
import Foundation | |
let japanese = Calendar(identifier: .japanese) | |
let gregorian = Calendar(identifier: .gregorian) | |
let locale = Locale(identifier: "ja") | |
let format = DateFormatter() | |
format.calendar = japanese | |
format.dateFormat = "Gy年" | |
format.locale = locale |
This file contains hidden or 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
import Foundation | |
let japanease = Calendar(identifier: .japanese) | |
let gregorian = Calendar(identifier: .gregorian) | |
let locale = Locale(identifier: "ja") | |
let format = DateFormatter() | |
format.calendar = japanease | |
format.dateFormat = "Gy年" | |
format.locale = locale |
This file contains hidden or 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
import Foundation | |
// | |
// print gregorian calendar year with japanease calendar year | |
// siwftc -o jyear jyear.swift | |
// ./jyear startYearInGregorianCalendar // (-length 10) | |
// ./jyear startYearInGregorianCalendar -length years | |
// ./jyear startYearInGregorianCalendar stopYearInGregorianCalendar | |
// | |
let japanease = Calendar(identifier: .japanese) | |
let gregorian = Calendar(identifier: .gregorian) |
This file contains hidden or 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
#!/usr/bin/perl | |
# | |
sub is_num { | |
my ($val) = @_; | |
if ( $val =~ /^-?\d+$/ ) { | |
return 1; | |
} | |
return 0; | |
} | |
sub test_is_num { |
This file contains hidden or 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
import Foundation | |
class StreamReader { | |
let encoding: NSStringEncoding | |
let chunkSize: Int | |
let fileHandle: NSFileHandle | |
var buffer: NSMutableData | |
let delimPattern : NSData | |
var isAtEOF: Bool = false | |
This file contains hidden or 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
import Foundation | |
extension String { | |
var hankanaRange : NSRange { | |
get { | |
return String.rangeOfHankana(self) | |
} | |
} | |
var stringWithoutHankana : String { | |
get { |
This file contains hidden or 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
// | |
// Use with String+Hankana.swift | |
// half2full | |
// | |
// half2full textfile.utf8 // all Half -> Full | |
// half2full -r textfile.utf8 // all Full -> Half | |
// half2full -k textfile.utf8 // only Half Kana -> Full Kana | |
// | |
import Foundation |
This file contains hidden or 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 String { | |
func rangeFromNSRange(nsrange:NSRange) -> Range<String.Index> { | |
let string = self | |
let startIndex = string.startIndex.advancedBy(nsrange.location) | |
let endIndex = startIndex.advancedBy(nsrange.length) | |
let range = Range(start:startIndex, end:endIndex) | |
return range | |
} | |
func NSRangeFromRange(range:Range<String.Index>) -> NSRange { | |
let location = self.startIndex.distanceTo(range.startIndex) |
This file contains hidden or 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
// | |
// main.swift | |
// half2full | |
// | |
// Created by [email protected] on 2017/08/02. | |
// Copyright © 2017年 Eien Factory. All rights reserved. | |
// | |
import Foundation |
This file contains hidden or 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
import Foundation | |
func jdFromDate(date : NSDate) -> Double { | |
let JD_JAN_1_1970_0000GMT = 2440587.5 | |
return JD_JAN_1_1970_0000GMT + date.timeIntervalSince1970 / 86400 | |
} | |
func dateFromJd(jd : Double) -> NSDate { | |
let JD_JAN_1_1970_0000GMT = 2440587.5 | |
return NSDate(timeIntervalSince1970: (jd - JD_JAN_1_1970_0000GMT) * 86400) |
NewerOlder