Merge pull request #123 from jpsim/use-additional-import-instead-of-defining-constants

Use additional import instead of defining constants on Linux
This commit is contained in:
Norio Nomura 2018-05-08 08:19:40 +09:00 committed by GitHub
commit 3473ce2170
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 6 deletions

View File

@ -9,6 +9,7 @@
#if SWIFT_PACKAGE
import CYaml
#endif
import CoreFoundation
import Foundation
public extension Node {
@ -267,9 +268,6 @@ private extension FloatingPoint where Self: CVarArg {
var formattedStringForCodable: String {
// Since `NumberFormatter` creates a string with insufficient precision for Decode,
// it uses with `String(format:...)`
#if os(Linux)
let DBL_DECIMAL_DIG = 17
#endif
let string = String(format: "%.*g", DBL_DECIMAL_DIG, self)
// "%*.g" does not use scientific notation if the exponent is less than 4.
// So fallback to using `NumberFormatter` if string does not uses scientific notation.

View File

@ -6,6 +6,9 @@
// Copyright (c) 2016 Yams. All rights reserved.
//
#if !_runtime(_ObjC)
import CDispatch
#endif
import Foundation
import XCTest
@ -19,9 +22,6 @@ func timestamp(_ timeZoneHour: Int = 0,
_ fraction: Double? = nil ) -> Date {
let calendar = Calendar(identifier: .gregorian)
let timeZone = TimeZone(secondsFromGMT: timeZoneHour * 60 * 60)
#if os(Linux)
let NSEC_PER_SEC = 1000000000
#endif
let nanosecond = fraction.map { Int($0 * Double(NSEC_PER_SEC)) }
let datecomponents = DateComponents(calendar: calendar, timeZone: timeZone,
year: year, month: month, day: day,