Skip to content

Commit 61dc9bd

Browse files
committed
fmt: rename Decimal to Integer
And similarly for `DecimalFormatter`. I believe I originally called this `Decimal` because it was also used to do fractional formatting.
1 parent 1467f47 commit 61dc9bd

File tree

6 files changed

+99
-99
lines changed

6 files changed

+99
-99
lines changed

src/fmt/friendly/printer.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use crate::{
22
fmt::{
3-
util::{DecimalFormatter, FractionalFormatter},
3+
util::{FractionalFormatter, IntegerFormatter},
44
Write, WriteExt,
55
},
66
Error, SignedDuration, Span, Unit,
@@ -1310,7 +1310,7 @@ impl SpanPrinter {
13101310
span_time = span_time.abs();
13111311

13121312
let fmtint =
1313-
DecimalFormatter::new().padding(self.padding.unwrap_or(2));
1313+
IntegerFormatter::new().padding(self.padding.unwrap_or(2));
13141314
let fmtfraction = FractionalFormatter::new().precision(self.precision);
13151315
wtr.wtr.write_int(&fmtint, span_time.get_hours_ranged().get())?;
13161316
wtr.wtr.write_str(":")?;
@@ -1488,7 +1488,7 @@ impl SpanPrinter {
14881488
// bigger.
14891489

14901490
let fmtint =
1491-
DecimalFormatter::new().padding(self.padding.unwrap_or(2));
1491+
IntegerFormatter::new().padding(self.padding.unwrap_or(2));
14921492
let fmtfraction = FractionalFormatter::new().precision(self.precision);
14931493

14941494
let mut secs = udur.as_secs();
@@ -1618,7 +1618,7 @@ struct DesignatorWriter<'p, 'w, W> {
16181618
wtr: &'w mut W,
16191619
desig: Designators,
16201620
sign: Option<DirectionSign>,
1621-
fmtint: DecimalFormatter,
1621+
fmtint: IntegerFormatter,
16221622
fmtfraction: FractionalFormatter,
16231623
written_non_zero_unit: bool,
16241624
}
@@ -1633,7 +1633,7 @@ impl<'p, 'w, W: Write> DesignatorWriter<'p, 'w, W> {
16331633
let desig = Designators::new(printer.designator);
16341634
let sign = printer.direction.sign(printer, has_calendar, signum);
16351635
let fmtint =
1636-
DecimalFormatter::new().padding(printer.padding.unwrap_or(0));
1636+
IntegerFormatter::new().padding(printer.padding.unwrap_or(0));
16371637
let fmtfraction =
16381638
FractionalFormatter::new().precision(printer.precision);
16391639
DesignatorWriter {
@@ -1733,7 +1733,7 @@ impl<'p, 'w, W: Write> DesignatorWriter<'p, 'w, W> {
17331733
struct FractionalPrinter {
17341734
integer: u64,
17351735
fraction: u32,
1736-
fmtint: DecimalFormatter,
1736+
fmtint: IntegerFormatter,
17371737
fmtfraction: FractionalFormatter,
17381738
}
17391739

@@ -1750,7 +1750,7 @@ impl FractionalPrinter {
17501750
fn from_span(
17511751
span: &Span,
17521752
unit: FractionalUnit,
1753-
fmtint: DecimalFormatter,
1753+
fmtint: IntegerFormatter,
17541754
fmtfraction: FractionalFormatter,
17551755
) -> FractionalPrinter {
17561756
debug_assert!(span.largest_unit() <= Unit::from(unit));
@@ -1762,7 +1762,7 @@ impl FractionalPrinter {
17621762
fn from_duration(
17631763
dur: &core::time::Duration,
17641764
unit: FractionalUnit,
1765-
fmtint: DecimalFormatter,
1765+
fmtint: IntegerFormatter,
17661766
fmtfraction: FractionalFormatter,
17671767
) -> FractionalPrinter {
17681768
match unit {

src/fmt/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ use crate::{
170170
util::escape,
171171
};
172172

173-
use self::util::{Decimal, DecimalFormatter, Fractional, FractionalFormatter};
173+
use self::util::{Fractional, FractionalFormatter, Integer, IntegerFormatter};
174174

175175
pub mod friendly;
176176
mod offset;
@@ -434,7 +434,7 @@ trait WriteExt: Write {
434434
#[inline]
435435
fn write_int(
436436
&mut self,
437-
formatter: &DecimalFormatter,
437+
formatter: &IntegerFormatter,
438438
n: impl Into<i64>,
439439
) -> Result<(), Error> {
440440
self.write_decimal(&formatter.format_signed(n.into()))
@@ -445,7 +445,7 @@ trait WriteExt: Write {
445445
#[inline]
446446
fn write_uint(
447447
&mut self,
448-
formatter: &DecimalFormatter,
448+
formatter: &IntegerFormatter,
449449
n: impl Into<u64>,
450450
) -> Result<(), Error> {
451451
self.write_decimal(&formatter.format_unsigned(n.into()))
@@ -464,7 +464,7 @@ trait WriteExt: Write {
464464

465465
/// Write the given decimal number to this buffer.
466466
#[inline]
467-
fn write_decimal(&mut self, decimal: &Decimal) -> Result<(), Error> {
467+
fn write_decimal(&mut self, decimal: &Integer) -> Result<(), Error> {
468468
self.write_str(decimal.as_str())
469469
}
470470

src/fmt/rfc2822.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ general interchange format for new applications.
4444
use crate::{
4545
civil::{Date, DateTime, Time, Weekday},
4646
error::{fmt::rfc2822::Error as E, ErrorContext},
47-
fmt::{util::DecimalFormatter, Parsed, Write, WriteExt},
47+
fmt::{util::IntegerFormatter, Parsed, Write, WriteExt},
4848
tz::{Offset, TimeZone},
4949
util::{
5050
parse,
@@ -1292,10 +1292,10 @@ impl DateTimePrinter {
12921292
offset: Option<Offset>,
12931293
mut wtr: W,
12941294
) -> Result<(), Error> {
1295-
static FMT_DAY: DecimalFormatter = DecimalFormatter::new();
1296-
static FMT_YEAR: DecimalFormatter = DecimalFormatter::new().padding(4);
1297-
static FMT_TIME_UNIT: DecimalFormatter =
1298-
DecimalFormatter::new().padding(2);
1295+
static FMT_DAY: IntegerFormatter = IntegerFormatter::new();
1296+
static FMT_YEAR: IntegerFormatter = IntegerFormatter::new().padding(4);
1297+
static FMT_TIME_UNIT: IntegerFormatter =
1298+
IntegerFormatter::new().padding(2);
12991299

13001300
if dt.year() < 0 {
13011301
// RFC 2822 actually says the year must be at least 1900, but
@@ -1349,10 +1349,10 @@ impl DateTimePrinter {
13491349
timestamp: &Timestamp,
13501350
mut wtr: W,
13511351
) -> Result<(), Error> {
1352-
static FMT_DAY: DecimalFormatter = DecimalFormatter::new().padding(2);
1353-
static FMT_YEAR: DecimalFormatter = DecimalFormatter::new().padding(4);
1354-
static FMT_TIME_UNIT: DecimalFormatter =
1355-
DecimalFormatter::new().padding(2);
1352+
static FMT_DAY: IntegerFormatter = IntegerFormatter::new().padding(2);
1353+
static FMT_YEAR: IntegerFormatter = IntegerFormatter::new().padding(4);
1354+
static FMT_TIME_UNIT: IntegerFormatter =
1355+
IntegerFormatter::new().padding(2);
13561356

13571357
let dt = TimeZone::UTC.to_datetime(*timestamp);
13581358
if dt.year() < 0 {

src/fmt/strtime/format.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use crate::{
99
weekday_name_full, BrokenDownTime, Config, Custom, Extension,
1010
Flag,
1111
},
12-
util::{DecimalFormatter, FractionalFormatter},
12+
util::{FractionalFormatter, IntegerFormatter},
1313
Write, WriteExt,
1414
},
1515
tz::Offset,
@@ -850,7 +850,7 @@ fn write_offset<W: Write>(
850850
second: bool,
851851
wtr: &mut W,
852852
) -> Result<(), Error> {
853-
static FMT_TWO: DecimalFormatter = DecimalFormatter::new().padding(2);
853+
static FMT_TWO: IntegerFormatter = IntegerFormatter::new().padding(2);
854854

855855
let hours = offset.part_hours_ranged().abs().get();
856856
let minutes = offset.part_minutes_ranged().abs().get();
@@ -946,7 +946,7 @@ impl Extension {
946946
self.width.or(pad_width)
947947
};
948948

949-
let mut formatter = DecimalFormatter::new().padding_byte(pad_byte);
949+
let mut formatter = IntegerFormatter::new().padding_byte(pad_byte);
950950
if let Some(width) = pad_width {
951951
formatter = formatter.padding(width);
952952
}

src/fmt/temporal/printer.rs

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use crate::{
33
error::{fmt::temporal::Error as E, Error},
44
fmt::{
55
temporal::{Pieces, PiecesOffset, TimeZoneAnnotationKind},
6-
util::{DecimalFormatter, FractionalFormatter},
6+
util::{FractionalFormatter, IntegerFormatter},
77
Write, WriteExt,
88
},
99
span::Span,
@@ -108,11 +108,11 @@ impl DateTimePrinter {
108108
date: &Date,
109109
mut wtr: W,
110110
) -> Result<(), Error> {
111-
static FMT_YEAR_POSITIVE: DecimalFormatter =
112-
DecimalFormatter::new().padding(4);
113-
static FMT_YEAR_NEGATIVE: DecimalFormatter =
114-
DecimalFormatter::new().padding(6);
115-
static FMT_TWO: DecimalFormatter = DecimalFormatter::new().padding(2);
111+
static FMT_YEAR_POSITIVE: IntegerFormatter =
112+
IntegerFormatter::new().padding(4);
113+
static FMT_YEAR_NEGATIVE: IntegerFormatter =
114+
IntegerFormatter::new().padding(6);
115+
static FMT_TWO: IntegerFormatter = IntegerFormatter::new().padding(2);
116116

117117
if date.year() >= 0 {
118118
wtr.write_int(&FMT_YEAR_POSITIVE, date.year())?;
@@ -132,7 +132,7 @@ impl DateTimePrinter {
132132
time: &Time,
133133
mut wtr: W,
134134
) -> Result<(), Error> {
135-
static FMT_TWO: DecimalFormatter = DecimalFormatter::new().padding(2);
135+
static FMT_TWO: IntegerFormatter = IntegerFormatter::new().padding(2);
136136
static FMT_FRACTION: FractionalFormatter = FractionalFormatter::new();
137137

138138
wtr.write_int(&FMT_TWO, time.hour())?;
@@ -254,12 +254,12 @@ impl DateTimePrinter {
254254
iso_week_date: &ISOWeekDate,
255255
mut wtr: W,
256256
) -> Result<(), Error> {
257-
static FMT_YEAR_POSITIVE: DecimalFormatter =
258-
DecimalFormatter::new().padding(4);
259-
static FMT_YEAR_NEGATIVE: DecimalFormatter =
260-
DecimalFormatter::new().padding(6);
261-
static FMT_TWO: DecimalFormatter = DecimalFormatter::new().padding(2);
262-
static FMT_ONE: DecimalFormatter = DecimalFormatter::new().padding(1);
257+
static FMT_YEAR_POSITIVE: IntegerFormatter =
258+
IntegerFormatter::new().padding(4);
259+
static FMT_YEAR_NEGATIVE: IntegerFormatter =
260+
IntegerFormatter::new().padding(6);
261+
static FMT_TWO: IntegerFormatter = IntegerFormatter::new().padding(2);
262+
static FMT_ONE: IntegerFormatter = IntegerFormatter::new().padding(1);
263263

264264
if iso_week_date.year() >= 0 {
265265
wtr.write_int(&FMT_YEAR_POSITIVE, iso_week_date.year())?;
@@ -304,7 +304,7 @@ impl DateTimePrinter {
304304
offset: &Offset,
305305
mut wtr: W,
306306
) -> Result<(), Error> {
307-
static FMT_TWO: DecimalFormatter = DecimalFormatter::new().padding(2);
307+
static FMT_TWO: IntegerFormatter = IntegerFormatter::new().padding(2);
308308

309309
wtr.write_str(if offset.is_negative() { "-" } else { "+" })?;
310310
let mut hours = offset.part_hours_ranged().abs().get();
@@ -339,7 +339,7 @@ impl DateTimePrinter {
339339
offset: &Offset,
340340
mut wtr: W,
341341
) -> Result<(), Error> {
342-
static FMT_TWO: DecimalFormatter = DecimalFormatter::new().padding(2);
342+
static FMT_TWO: IntegerFormatter = IntegerFormatter::new().padding(2);
343343

344344
wtr.write_str(if offset.is_negative() { "-" } else { "+" })?;
345345
let hours = offset.part_hours_ranged().abs().get();
@@ -427,7 +427,7 @@ impl SpanPrinter {
427427
span: &Span,
428428
mut wtr: W,
429429
) -> Result<(), Error> {
430-
static FMT_INT: DecimalFormatter = DecimalFormatter::new();
430+
static FMT_INT: IntegerFormatter = IntegerFormatter::new();
431431
static FMT_FRACTION: FractionalFormatter = FractionalFormatter::new();
432432

433433
if span.is_negative() {
@@ -541,7 +541,7 @@ impl SpanPrinter {
541541
dur: &SignedDuration,
542542
mut wtr: W,
543543
) -> Result<(), Error> {
544-
static FMT_INT: DecimalFormatter = DecimalFormatter::new();
544+
static FMT_INT: IntegerFormatter = IntegerFormatter::new();
545545
static FMT_FRACTION: FractionalFormatter = FractionalFormatter::new();
546546

547547
let mut non_zero_greater_than_second = false;
@@ -590,7 +590,7 @@ impl SpanPrinter {
590590
dur: &core::time::Duration,
591591
mut wtr: W,
592592
) -> Result<(), Error> {
593-
static FMT_INT: DecimalFormatter = DecimalFormatter::new();
593+
static FMT_INT: IntegerFormatter = IntegerFormatter::new();
594594
static FMT_FRACTION: FractionalFormatter = FractionalFormatter::new();
595595

596596
let mut non_zero_greater_than_second = false;

0 commit comments

Comments
 (0)