Skip to content

Commit

Permalink
BL-135 resolve
Browse files Browse the repository at this point in the history
  • Loading branch information
jclausen committed May 23, 2024
1 parent 8baa948 commit bca6dd8
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ public Object _invoke( IBoxContext context, ArgumentsScope arguments ) {
}

// LS Subclass locales
Locale locale = LocalizationUtil.parseLocale( arguments.getAsString( Key.locale ) );
Locale locale = LocalizationUtil.parseLocaleFromContext( context, arguments );

Key bifMethodKey = arguments.getAsKey( BIF.__functionName );
String methodName = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
import java.time.ZonedDateTime;
import java.time.temporal.ChronoField;
import java.time.temporal.IsoFields;
import java.time.temporal.WeekFields;
import java.util.Locale;

import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
Expand All @@ -38,6 +40,7 @@
import ortus.boxlang.runtime.context.IBoxContext;
import ortus.boxlang.runtime.context.ScriptingRequestBoxContext;
import ortus.boxlang.runtime.dynamic.casters.LongCaster;
import ortus.boxlang.runtime.scopes.ArgumentsScope;
import ortus.boxlang.runtime.scopes.IScope;
import ortus.boxlang.runtime.scopes.Key;
import ortus.boxlang.runtime.scopes.VariablesScope;
Expand All @@ -50,6 +53,7 @@ public class TimeUnitsTest {
IBoxContext context;
IScope variables;
static Key result = new Key( "result" );
static Locale locale;

@BeforeAll
public static void setUp() {
Expand All @@ -64,6 +68,7 @@ public static void teardown() {
public void setupEach() {
context = new ScriptingRequestBoxContext( instance.getRuntimeContext() );
variables = context.getScopeNearby( VariablesScope.name );
locale = LocalizationUtil.parseLocaleFromContext( context, new ArgumentsScope() );
}

@DisplayName( "It tests the BIF Year" )
Expand Down Expand Up @@ -276,7 +281,7 @@ public void testMemberDaysInYear() {
@DisplayName( "It tests the BIF DayOfWeek" )
@Test
public void testBifDayOfWeek() {
Integer refDayOfWeek = ZonedDateTime.now().getDayOfWeek().getValue();
Integer refDayOfWeek = ZonedDateTime.now().get( WeekFields.of( locale ).dayOfWeek() );
instance.executeSource(
"""
now = now();
Expand All @@ -285,12 +290,20 @@ public void testBifDayOfWeek() {
context );
Integer result = ( Integer ) variables.get( Key.of( "result" ) );
assertEquals( result, refDayOfWeek );
instance.executeSource(
"""
now = parseDateTime( "2024-04-07" );
result = dayOfWeek( now );
""",
context );
result = variables.getAsInteger( Key.of( "result" ) );
assertEquals( 1, result );
}

@DisplayName( "It tests the DateTime Member function DayOfWeek" )
@Test
public void testMemberDayOfWeek() {
Integer refDayOfWeek = ZonedDateTime.now().getDayOfWeek().getValue();
Integer refDayOfWeek = ZonedDateTime.now().get( WeekFields.of( locale ).dayOfWeek() );
instance.executeSource(
"""
result = now().dayOfWeek();
Expand Down

0 comments on commit bca6dd8

Please sign in to comment.