1
0
mirror of https://github.com/SquidDev-CC/CC-Tweaked synced 2024-12-14 20:20:30 +00:00

Remove some unused arguments in LuaDateTime

See comments in #1157
This commit is contained in:
Jonathan Coates 2022-09-11 15:03:09 +01:00
parent 61ac48c99f
commit c3b7302108
No known key found for this signature in database
GPG Key ID: B9E431FF07C98D06
2 changed files with 9 additions and 11 deletions

View File

@ -24,7 +24,7 @@ final class LuaDateTime
{ {
} }
static void format( DateTimeFormatterBuilder formatter, String format, ZoneOffset offset ) throws LuaException static void format( DateTimeFormatterBuilder formatter, String format ) throws LuaException
{ {
for( int i = 0; i < format.length(); ) for( int i = 0; i < format.length(); )
{ {
@ -61,7 +61,7 @@ final class LuaDateTime
formatter.appendText( ChronoField.MONTH_OF_YEAR, TextStyle.FULL ); formatter.appendText( ChronoField.MONTH_OF_YEAR, TextStyle.FULL );
break; break;
case 'c': case 'c':
format( formatter, "%a %b %e %H:%M:%S %Y", offset ); format( formatter, "%a %b %e %H:%M:%S %Y" );
break; break;
case 'C': case 'C':
formatter.appendValueReduced( CENTURY, 2, 2, 0 ); formatter.appendValueReduced( CENTURY, 2, 2, 0 );
@ -71,13 +71,13 @@ final class LuaDateTime
break; break;
case 'D': case 'D':
case 'x': case 'x':
format( formatter, "%m/%d/%y", offset ); format( formatter, "%m/%d/%y" );
break; break;
case 'e': case 'e':
formatter.padNext( 2 ).appendValue( ChronoField.DAY_OF_MONTH ); formatter.padNext( 2 ).appendValue( ChronoField.DAY_OF_MONTH );
break; break;
case 'F': case 'F':
format( formatter, "%Y-%m-%d", offset ); format( formatter, "%Y-%m-%d" );
break; break;
case 'g': case 'g':
formatter.appendValueReduced( IsoFields.WEEK_BASED_YEAR, 2, 2, 0 ); formatter.appendValueReduced( IsoFields.WEEK_BASED_YEAR, 2, 2, 0 );
@ -107,10 +107,10 @@ final class LuaDateTime
formatter.appendText( ChronoField.AMPM_OF_DAY ); formatter.appendText( ChronoField.AMPM_OF_DAY );
break; break;
case 'r': case 'r':
format( formatter, "%I:%M:%S %p", offset ); format( formatter, "%I:%M:%S %p" );
break; break;
case 'R': case 'R':
format( formatter, "%H:%M", offset ); format( formatter, "%H:%M" );
break; break;
case 'S': case 'S':
formatter.appendValue( ChronoField.SECOND_OF_MINUTE, 2 ); formatter.appendValue( ChronoField.SECOND_OF_MINUTE, 2 );
@ -120,7 +120,7 @@ final class LuaDateTime
break; break;
case 'T': case 'T':
case 'X': case 'X':
format( formatter, "%H:%M:%S", offset ); format( formatter, "%H:%M:%S" );
break; break;
case 'u': case 'u':
formatter.appendValue( ChronoField.DAY_OF_WEEK ); formatter.appendValue( ChronoField.DAY_OF_WEEK );
@ -212,15 +212,13 @@ final class LuaDateTime
throw new LuaException( "field \"" + field + "\" missing in date table" ); throw new LuaException( "field \"" + field + "\" missing in date table" );
} }
private static final TemporalField CENTURY = map( ChronoField.YEAR, ValueRange.of( 0, 6 ), x -> (x / 100) % 100 ); private static final TemporalField CENTURY = map( ChronoField.YEAR, ValueRange.of( 0, 99 ), x -> (x / 100) % 100 );
private static final TemporalField ZERO_WEEK = map( WeekFields.SUNDAY_START.dayOfWeek(), ValueRange.of( 0, 6 ), x -> x - 1 ); private static final TemporalField ZERO_WEEK = map( WeekFields.SUNDAY_START.dayOfWeek(), ValueRange.of( 0, 6 ), x -> x - 1 );
private static TemporalField map( TemporalField field, ValueRange range, LongUnaryOperator convert ) private static TemporalField map( TemporalField field, ValueRange range, LongUnaryOperator convert )
{ {
return new TemporalField() return new TemporalField()
{ {
private final ValueRange range = ValueRange.of( 0, 99 );
@Override @Override
public TemporalUnit getBaseUnit() public TemporalUnit getBaseUnit()
{ {

View File

@ -493,7 +493,7 @@ public class OSAPI implements ILuaAPI
if( format.equals( "*t" ) ) return LuaDateTime.toTable( date, offset, instant ); if( format.equals( "*t" ) ) return LuaDateTime.toTable( date, offset, instant );
DateTimeFormatterBuilder formatter = new DateTimeFormatterBuilder(); DateTimeFormatterBuilder formatter = new DateTimeFormatterBuilder();
LuaDateTime.format( formatter, format, offset ); LuaDateTime.format( formatter, format );
return formatter.toFormatter( Locale.ROOT ).format( date ); return formatter.toFormatter( Locale.ROOT ).format( date );
} }