Sugerencias para proxima version en FECHA/HORA - Forum

Forum Navigation
You need to log in to create posts and topics.

Sugerencias para proxima version en FECHA/HORA

Hola @luishp

Te dejo unas sugerencias para futuras versiones si es que se pueden agregar en VisualNeoWeb , en  las acciones "FECHA /HORA" o quizas algun plugin de pago mas completo:

. Poder sumar/restar  un dia a una fecha ( que tenga en cuenta el cambio de un mes a otro si el dia justo es fin de mes )

. Poder saber cuantos dias tiene un mes partiendo de una fecha (dd/mm/yyyy)

. Poder saber que dia de la semana (Nombre del dia ) cae una fecha

.

@gustavo1973

@luishp

If you want, I can take a stab at developing the requested functionality (as Plugin commands).

Just advise the command names and parameter details e.g. for DayOfWeek enquiry ...

DateDOW "forDate" "dateFormat" "resultVariable" "resultCSV"

... where ...

dateFormat could be  ...

dd/mm/ccyy
or
ccyy-dd-mm etc.

resultCSV could be ...
Sun,Mon,Tue,Wed etc.
or
Sunday,Monday,Tuesday etc.
or
Dimanche,Lundi,Mardi etc.
or
Domingo,Lunes,Martes etc.
or
0,1,2,3,4 etc.

@gaev me parece excelente, si puedes hacerlo, en mi caso me resultaria muy util, y me dices como te hago el pago

Con respecto a los parametros y sus nombres quizas tu tengas mas experiencia, pero te digo lo que seria util para mi:

Dia de la semana para una fecha determinada:

DateDayName "Date" "dateFormat" "resultVariable" "resultCSV"

Date Format : opcional ? (dd/mm/yyy )  o  (yyyy-mm-dd)

resultCSV : Domingo, Lunes, Martes, Miercoles,Jueves,Viernes,Sabado

@gustavo1973

y me dices como te hago el pago

LOL ... I was not thinking of doing a commercial plugin ... so there will be no charge.

I just made the offer to help out @luishp ... so he can use his valuable time/resources on the rocket science (brain surgeon) stuff :-))

If he agrees, after we have a spec for the plugin commands, I will develop the (javascript) code ... and then, these commands can be added to the DateTime plugin.

Vadim has reacted to this post.
Vadim

@gaev @gutavo1973, I have in my list a very complete library for working with dates,  to make a plugin:
https://momentjs.com/

My list is really long so any help would be very much appreciated.
Thank you!

@luishp

My list is really long so any help would be very much appreciated.

If you can provide (via a shared google sheet or email or a new post here) a list of desired plugin command names and parameters, I will undertake development and initial testing ... then, perhaps the community can help do more thorough testing before you publish it.

I suggest you list the commands/functionality in order of priority ... that way, we can release the plugin in stages (if necessary).

@gustavo1973

The moments plugin (mentioned by @luishp) has the functionality to get DayOfWeek.

I will try and build some VisualNEOWeb subroutines that will allow you to ...

. add / subtract a day from a date (that takes into account the change from one month to another if the day is the end of the month)

. know how many days a month has starting from a date (dd / mm / yyyy)

 

Hi All, i was developing an app but had to let it aside because it became very complex for me in because i'm not developer. I was working with date/hour in sqlite database. For example and perhaps will be an useful idea here for the plugin functionality. I was trying to resolve the problem with certain date/hour difference calculating for example the cost of working by hour expressed in total of minutes using moments library but i think this library does not work with ranges. For example:

MONDAY to FRIDAY
18:00 --- 21:00 ----> working hours pay at 50%
21:00 --- 08:00 (next day)----> working hours pay at 70%

SATURDAY
08:00 --- 13:00 ----> working hours pay at 50%
13:00 --- 00:00 (sunday)----> working hours pay at 100%

SUNDAY
(sunday) 00:00 --- 08:00 (monday) ----> working hours pay at 100%

Would be great do this kind of range calc using a plugin in VNW.

Best regards to all,
Sam

@lesanch

I don't think you will find any plugin that combines date ranges with pay rates.

However, given start and end timestamps, you can set up a loop ...

- starting with the start hour of the start date and ending with the end hour
- advancing the loop by one hour per iteration
- for each iteration, the plugin would return the day of week (so you can assign and accumulate the weighted value for that hour

Tip: best to change the start/end timestamps into "hours since (say) midnight January 1, 20xx" ... then with each iteration (increment of 1 hour), reverse the number to an actual date, day of week and hour of day, before applying rates based on day of week and hour

 

@gustavo1973

Until the Day Of Week functionality is available as a plugin command, here is some code you can use ...

SetVar [daysOfWeek] "Domingo,Lunes,Martes,Miercoles,Jueves,Viernes,Sabado"
SetVar [thisDate] "8/16/2020"

BeginJS

var thisD = new Date($App.thisDate); //create date object
var dow = thisD.getDay() //returns 0 to 6

//get string of names
var thisDaysOfWeek = $App.daysOfWeek;
//turn to array
var daysOfWeekArray = thisDaysOfWeek.split(",");
//copy to VisualNEO space
$App.thisDayOfWeek = daysOfWeekArray[dow];

//alert(daysOfWeekArray[dow]);
//alert($App.thisDayOfWeek);

EndJS

AlertBox "Day of Week" "[thisDate] falls on [thisDayOfWeek]" ""

Please advise if you have any questions or found errors.

luishp has reacted to this post.
luishp

@gustavo1973

Here is code to add/subtract days from a given date ...

SetVar [thisDate] "2020-08-17"
... SetVar [thisDate] "8/17/2020"

... [addDays] can be positive or negative number
SetVar [addDays] 10

BeginJS

var thisD = new Date($App.thisDate); //create date object
//add or sub days
thisD.setDate(thisD.getDate() + $App.addDays);

//month numbers are 0 to 11
var resultMonth = thisD.getMonth() + 1;
//make sure 2 digits for month
if (resultMonth < 10) {
resultMonth = "0" + resultMonth;
}

//make sure 2 digits for day
var resultDay = thisD.getDate()
if (resultDay < 10) {
resultDay = "0" + resultDay;
}

var resultDate = thisD.getFullYear() + "-" + resultMonth + "-" + resultDay;

//copy to VisualNEO space
$App.resultingDate = resultDate;

EndJS

AlertBox "Resulting Date" "[adddays] days from [thisDate] equals [resultingDate]" ""

Warning: I can't explain it but using date format of yyyy-mm-dd gives a different result (by one day) than using format of mm/dd/yyyy

luishp has reacted to this post.
luishp

@Gaev perdon por mi demora, lo pongo a prueba a ver que resultado obtengo

@gaev

El codigo para saber que dia de la semana cae una fecha determinada funciona perfecto

@gaev

@luishp

El codigo para sumar o restar dias no funciona, da como resultado en la fecha resultante

Nan-Nan-Nan

Me parece que el error se puede originar que la fecha ingresada al plugin es del tipo "10/04/2020" y de vuelve el resultado en el formato "11-04-2020" viendo lo que devuelve que es "Nan-Nan-Nan"

@gustavo1973

After I do a Google translate ...

a) I am not surewhat your issue is
b) I am confused because Google also changes the date format during translation

I went back and tried a couple of examples; here is what I got isplayed in the AlertBox ...

a) 10 days from 2020-08-17 equals 2020-08-26
b) 10 days from 8/17/2020 equals 2020-08-27

The discrepancy is explained here ... https://www.w3schools.com/js/js_date_formats.asp ...

The computed date will be relative to your time zone.

So, please post (in English if possible) exact examples like this ...

SetVar [thisDate] "2020-08-17"
SetVar [addDays] 10
AlertBox message '10 days from 2020-08-17 equals 2020-08-26'
Should be "blah blah blah"

... along with your ...

a) time zone (hours relative to GMT)
b) country's default date format (as specified in your Windows Configuration)