CREATE OR REPLACE FUNCTION is_business_day(p_date date)
RETURNS boolean AS
$BODY$
DECLARE
is_business_day boolean;
dow int;
BEGIN
dow := extract('dow' from p_date);
IF dow = 6 OR dow = 0
THEN
is_business_day := FALSE;
ELSE
is_business_day := TRUE;
END IF;
RETURN is_business_day ;
END;
$BODY$
LANGUAGE plpgsql IMMUTABLE;
CREATE OR REPLACE FUNCTION working_date(date start_date, int duration)
RETURNS date AS
$BODY$
DECLARE
ret_date date;
loop_date date;
BEGIN
--add days
ret_date := start_date + (duration - 1);
loop_date := start_date + 1;
--add extra day for each no business day between start_date and ret_date
WHILE loop_date <= ret_date LOOP
IF not is_business_day(loop_date) THEN
ret_date := ret_date + 1;
END IF;
loop_date := loop_date + 1;
END LOOP;
--add day if ret_date is no business day
WHILE not is_business_day(ret_date) LOOP
ret_date := ret_date + 1;
END LOOP;
RETURN ret_date;
END;
$BODY$
LANGUAGE plpgsql VOLATILE SECURITY DEFINER
COST 100;
请在swift中转换此目标c函数
答案 0 :(得分:1)
看起来像
func connectDataReceived(connection: NSURLConnection, data: NSData){
let str = NSString(data: data, encoding: NSUTF8StringEncoding)!
print(str)
}
答案 1 :(得分:1)
我发布的答案非常简单,您可以轻松理解。
let strData = "A384CVHJLWHBWRLBRH2348945607275epiuthgthgbpbfvrvdiac15szerqTUDGA89ty757909577257908hbdshjkbhvalasdhbchdcvgcvjvgvaKLOYAQCGHQ"
let data = strData.dataUsingEncoding(NSUTF8StringEncoding, allowLossyConversion: false)!
let str = NSString(data: data, encoding: NSUTF8StringEncoding)!
print("\(str)")