Agent for information

Ah ok… let me test it (but you never told/wrote it :woozy_face:)

1 Like

yes good i know my english is bad, sorry

jeje… my english is worse, no problem :sweat_smile:

I think I got it finally, maybe a cache issue caused my problems to see data but it’s working now.

But a question:

We are still going to have problems to compare dates using the medium/long format anyway, right?

This command returns “Invalid Date” using this kind of value:

new Date(‘16 de septiembre de 2021 12:10:00’).toLocaleString()

Thanks Manu

I’m not following these date related threads very closely, so I’m not fully clear on what the issue is. I apologize if I’m way off track on this, but couldn’t you do a math column to make a numeric column in the format of YYYYMMDD, and then split that in the code and/or convert it to a valid date? If it’s for sorting, you wouldn’t even need to convert it to a valid date since the number would sort properly as a number or as a string. With this, there wouldn’t be a need to worry about the regional date format. The math column would always give you YYYYMMDD. But then again, I may have missed the entire point of this whole conversation.

5 Likes

Exactly. I keep saying it because it’s true. Use a proper date format, and all the problems melt away.

2 Likes

Thanks Jeff, great idea!

In my case, I was looking for having a sorted date array (already done!) to compare any other date with the array values and find an available date (think about a hotel reservation with a Date Check-In and a Date Check-Out).

The problem with sort and compare dates is the several formats used and find the smartest/simplest method is the challenge.

Your method is perfect to simplify my goal and what I have done so far.

Thanks again, tú eres un crack! :trophy:

2 Likes

Hello @Jeff_Hager , @Darren_Murphy
The idea is to be able to manage dates in YC, without worrying about the regional format and without adding columns in glide. Because if you need to add a few things, you might as well do it in the script.
because for javascript you need the format “mm / dd / yyyy, hh: mm: ss”.

So I made a script that can be used as a base as soon as the dates are used.
The script works great (eihn @gvalero :stuck_out_tongue_winking_eye: :stuck_out_tongue_winking_eye:)

After once the date is in the script, you can do what you want with it and especially make a return table that respects the regional format, otherwise you still have to add columns to process each date in the table. (whereas with the script, the date is immediately usable without adding columns)

1 Like

erm, no you don’t.
Javascript handles ISO8601 format pefectly fine, and will return the correct result in all timezones.

function test_dates() {
  var date_string = '2021-09-03 11:15:23'; // ISO Format
  console.log("Current Timezone: %s", Session.getScriptTimeZone());
  try {
    console.log("%s returns %s", date_string, new Date(date_string).toDateString());
  }
  catch (err) {
    console.warn("%s returns %s", date_string, err);
  }
}

America/New_York

11:21:48 AM Info Current Timezone: America/New_York
11:21:48 AM Info 2021-09-03 11:15:23 returns Fri Sep 03 2021 11:15:23 GMT-0400 (Eastern Daylight Time)

America/Sao_Paulo

11:31:23 AM Info Current Timezone: America/Sao_Paulo
11:31:23 AM Info 2021-09-03 11:15:23 returns Fri Sep 03 2021 11:15:23 GMT-0300 (Brasilia Standard Time)

Asia/Singapore

11:25:40 AM Info Current Timezone: Asia/Singapore
11:25:40 AM Info 2021-09-03 11:15:23 returns Fri Sep 03 2021 11:15:23 GMT+0800 (Singapore Standard Time)

Europe/Rome

11:27:36 AM Info Current Timezone: Europe/Rome
11:27:36 AM Info 2021-09-03 11:15:23 returns Fri Sep 03 2021 11:15:23 GMT+0200 (Central European Summer Time)
3 Likes

Yes of course,
Okay, I’ll try to be more specific.
The problem is not in JS, but in the data exchange between glide and the YC script.

So even though JS accepts a lot of formats (I used mm / dd / yyyy as an example for simplicity), if your application is used worldwide, you are going to have problems transferring data.

2 Likes

Good afternoon, I would like to know if there is a way to obtain the city of the IP address of a visitor to the App.

I explain a little why I do not need: I have an Uber-type transport App and when the user writes his address it is not possible today for Today it shows the autocomplete of Google maps, which makes the user write the address but does not enter the sector or city, losing accuracy many times when transforming the address into coordinates.

If I can get the city through the IP with the EC I could concatenate to the written address and achieve more accuracy.

This looks promising:

https://ipstack.com/

1 Like

Hello,
I have no solution for you, but I find that this approach is not good. Because for example at home, the city according to my IP address is more than 50 km from my home.
Maybe it can work in big cities or the communication centers are in the same city.

2 Likes