Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add WEEKNUM function #5

Open
rowanseymour opened this issue Jan 20, 2016 · 12 comments
Open

Add WEEKNUM function #5

rowanseymour opened this issue Jan 20, 2016 · 12 comments

Comments

@rowanseymour
Copy link
Contributor

See https://support.office.com/en-us/article/WEEKNUM-function-e5c43a03-b4ab-426c-b411-b18c13c75340

@Vandeabdou
Copy link

In which Files of rapidPro can i add the function WEEKNUM??

@Vandeabdou
Copy link

@rowanseymour thank you very much. I will add it with java implementation

@Vandeabdou
Copy link

@rowanseymour I don't find these files on rapidPro. I must install them with command ?

@rowanseymour
Copy link
Contributor Author

This is separate library which we import into RapidPro.

Remember you need to implement it in both Java and Python - then add tests to show that they are consistent with each other, and consistent with Excel itself.

@Vandeabdou
Copy link

OK. I install openjdk and now di i put ExcelFunctions.java in rapidpro/expressions/functions/ folder? Also if i add new function i can just call it with @(NEW_FUNCTION()) ?

@rowanseymour
Copy link
Contributor Author

Look at the existing functions in ExcelFunctions.java and follow the same pattern. If you create a method called new_function you will be able to call it like @(NEW_FUNCTION())

@Vandeabdou
Copy link

I don't find ExcelFunctions.java in my RapidPro. I just find excels.py in /env/lib/python2.7/site-packages/expressions/functions folder.
Do i import in that folder or in another folder?

@rowanseymour
Copy link
Contributor Author

It's not in RapidPro - it's in this repo that this issue belongs to. This is a project which contains the Java implementation of the RapidPro expression engine (used by Surveyor) and the Python implementation (used by the RapidPro Django app)

@Vandeabdou
Copy link

Thank you. I finally add WEEKNUM function but in python.
This is the function and it works fine

def weeknum(ctx, date):
"""
Returns the num of the week of a date (Between 1 and 52)
"""
return (conversions.to_date_or_datetime(date, ctx).isocalendar()[1])

@Vandeabdou
Copy link

Hello @rowanseymour. The function run in the simulator without error but if i test the flow with a phone i get @(WEEKNUM(TODAY())) instead of 4 for example

@Vandeabdou
Copy link

How can i test my need function just added in my copy of expressions lib ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants