Skip to content

Commit

Permalink
FormatStyle: Added plainInteger
Browse files Browse the repository at this point in the history
  • Loading branch information
orchetect committed Oct 30, 2024
1 parent 4ba3f55 commit 4d3452d
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions Sources/OTCore/Extensions/Foundation/FormatStyle.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
//
// FormatStyle.swift
// OTCore • https://github.com/orchetect/OTCore
// © 2024 Steffan Andrews • Licensed under MIT License
//

#if canImport(Foundation)

import Foundation

@available(macOS 12.0, iOS 15.0, tvOS 15.0, watchOS 8.0, *)
extension FormatStyle where Self == IntegerFormatStyle<Int> {
/// Plain integer format style.
///
/// Integer with no decimal places, without grouping (thousands separators), and without sign.
///
/// Suitable for technical integer input, including network port numbers.
@_disfavoredOverload
public static var plainInteger: IntegerFormatStyle<Int> {
IntegerFormatStyle<Int>()
.precision(.fractionLength(0))
.grouping(.never)
.sign(strategy: .never)
}
}

#endif

0 comments on commit 4d3452d

Please sign in to comment.