1
0
mirror of https://github.com/SquidDev-CC/CC-Tweaked synced 2024-12-14 04:00: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(); )
{
@ -61,7 +61,7 @@ final class LuaDateTime
formatter.appendText( ChronoField.MONTH_OF_YEAR, TextStyle.FULL );
break;
case 'c':
format( formatter, "%a %b %e %H:%M:%S %Y", offset );
format( formatter, "%a %b %e %H:%M:%S %Y" );
break;
case 'C':
formatter.appendValueReduced( CENTURY, 2, 2, 0 );
@ -71,13 +71,13 @@ final class LuaDateTime
break;
case 'D':
case 'x':
format( formatter, "%m/%d/%y", offset );
format( formatter, "%m/%d/%y" );
break;
case 'e':
formatter.padNext( 2 ).appendValue( ChronoField.DAY_OF_MONTH );
break;
case 'F':
format( formatter, "%Y-%m-%d", offset );
format( formatter, "%Y-%m-%d" );
break;
case 'g':
formatter.appendValueReduced( IsoFields.WEEK_BASED_YEAR, 2, 2, 0 );
@ -107,10 +107,10 @@ final class LuaDateTime
formatter.appendText( ChronoField.AMPM_OF_DAY );
break;
case 'r':
format( formatter, "%I:%M:%S %p", offset );
format( formatter, "%I:%M:%S %p" );
break;
case 'R':
format( formatter, "%H:%M", offset );
format( formatter, "%H:%M" );
break;
case 'S':
formatter.appendValue( ChronoField.SECOND_OF_MINUTE, 2 );
@ -120,7 +120,7 @@ final class LuaDateTime
break;
case 'T':
case 'X':
format( formatter, "%H:%M:%S", offset );
format( formatter, "%H:%M:%S" );
break;
case 'u':
formatter.appendValue( ChronoField.DAY_OF_WEEK );
@ -212,15 +212,13 @@ final class LuaDateTime
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 TemporalField map( TemporalField field, ValueRange range, LongUnaryOperator convert )
{
return new TemporalField()
{
private final ValueRange range = ValueRange.of( 0, 99 );
@Override
public TemporalUnit getBaseUnit()
{

View File

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