2Abendsegler / GClh

GC little helper II - Some little things to make life easy (on www.geocaching.com). Powerful, configurable tool to improve and expand the geocaching pages.
GNU General Public License v2.0
59 stars 38 forks source link

Helper function: gclh_parseDate #305

Closed CachingFoX closed 7 years ago

CachingFoX commented 7 years ago

A common function which is able to parse a date in a string and returns it as a Date object. There are many different date formats offered by www.geocaching.com. (see here https://www.geocaching.com/account/settings/preferences). The function should be supported all this formats.

The function should be have to paramters: First parameter contains the string which should be parsed. The second parameter is optional and specifies the date format as a string. If the parameter is undefined or a empty string function gclh_DateFormat is used.

For formats which contains the month as a three letter name: Only English (short) month names are supported.

See also #304

CachingFoX commented 7 years ago
// GS shows the name of the month always in English independes from the language configured by the user. Why we have two Marchs I don't know
var month_names = { "Jan" : 1, "Feb" : 2, "Mrz" : 3, "Mar" : 3, "Apr" : 4, "May" : 5, "Jun" : 6, "Jul" : 7, "Aug" : 8, "Sep" : 9, "Oct" : 10, "Nov" : 11, "Dec" : 12 };
CachingFoX commented 7 years ago

Nearby line 3035 (Show Eventday beside Date): The next 80 lines can be replace with this function.

CachingFoX commented 7 years ago

Inzwischen unterstützt GS 23 verschiedene Datumsformate. GClh unterstützt aber aktuell nur 8 Stück.