• Resolved ramonjosegn

    (@ramonjosegn)


    Hi dear

    I have a webpage about bus routs

    I have been able to create an excel file with the approximate timetables of the bus at each stop (through statistical analysis).

    However, at the moment I would have to show something like this (example)

    STOP A – bus arrives at 12:15, 12:30, 12:50, 12:60, etc.
    STOP B – bus arrives at 14:15, 14:30, 14:50, 14:60, etc.

    A little horrible and disconcerting for the web visitor….

    However, I would like to know if I could show ONLY the time left before the bus arrives.

    Would it be possible to use Calculated Fields Form for this?

    I would no longer show
    STOP A – bus arrives at 12:15, 12:30, 12:50, 12:60, etc.

    but it would only show

    STOP A – NEXT ARRIVAL IN 10 MINUTES (the countdown would be REAL and regressive, taking into account my city’s schedule)

    Too complex? Possible? Impossible?

    • This topic was modified 6 years, 5 months ago by ramonjosegn.
Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author codepeople

    (@codepeople)

    Hello @ramonjosegn,

    I’m sorry, but your project’s description is too general, and does not include anything about the implementation.

    However, assuming there is an array with the times, that I will call: bus, for example, with the structure:

    
    var bus = ['12:15', '12:30', '12:50', '12:60'];
    

    a possible equation would be:

    
    (function () {
    	var current = new Date(), 
    		hours = current.getHours(), 
    		minutes = current.getMinutes(),
    		next, tmp, result;
    	
    	if(hours < 10 ) hours = '0'+hours;
    	if(minutes < 10 ) minutes = '0'+minutes;
    	
    	for(var i=0, h = bus.length; i<h; i++)
    	{
    		if(hours+':'+minutes < bus[i]) 
    		{
    			next = bus[i];
    			break;
    		}	
    	}
    	
    	if(next)  	
    	{
    		next = next.split(':');
    		next = next[0]*60+next[1]*1;
    		tmp = hours*60+minutes*1; 
    		result = next - tmp;
    		
    		return FLOOR(result/60)+' hours and '+(result%60)+' minutes';
    	}	
    	else
    	{
    		return 'Next buss tomorrow: '+bus[0];
    	}	
    })()
    

    If you need more help to implement your project, I can offer you a custom coding service from my private website:

    https://cff.dwbooster.com/customization

    Best regards.

    Thread Starter ramonjosegn

    (@ramonjosegn)

    Great thanks.

    The website generates little revenue, if they grow in the future I would seriously consider implementing different custom code options, thanks for the proposal.

    Currently I only have a dynamic list of timetables in Excel…

    Plugin Author codepeople

    (@codepeople)

    Hello @ramonjosegn,

    If your data are stored into an Excel file you can save them as a CSV file, and use the DS controls (a set of controls that read the their values form external data sources like a MySQL database or CSV file) distributed with the Developer and Platinum versions of the plugin to read them and use their values from the equations.

    Best regards.

    Thread Starter ramonjosegn

    (@ramonjosegn)

    Thanks for support

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Would it be possible use to show the arrival of the next bus?’ is closed to new replies.