Custom export filter month field

Hello, I am writing a custom export filter in order to create a simplified bibtex bibliography from selected entries.
If I find the expansion of the Bibtex custom strings usefull, I have a problem against the expansion of the month field.
Indeed, to allow using smoothly the Bibtex file for non English documents, I would like to be able to recover the month number associated to the field instead of the full name in English.

To sum up, with a database file such as this:

@String{acmtog = {ACM} Transaction on Graphics}
@Article{key,
[…]
journal = acmtog,
date = {2018-06}
}

And a custom export filter like this:

@\bibtextype{\bibtexkey,\begin{journal},
journal = {\journal}\end{journal}\begin{month},
month = {\month}\end{month}
}

I get something like:

@Article{key,
//[…]
journal = {SIGGRAPH Computer Graphics}, //nice!
month = {January}, //why not the month number? how to get it?
}

Any idea to get the number of the month instead of its name in English?

Hi,

I think this could be possible by using the date formatter. Evenif you only have month setup, as date is an alias field for month + year.

It should be sufficient either with M for single month or MM for month with leading zero

DateFormatter : formats a date. With no argument, the date is given in ISO-format (yyyy-MM-dd), which is also the expected format of the input. The argument may contain yyyy, MM, and dd in any combination. For example \format[DateFormatter(MM/yyyy)]{\date} will output 07/2016 if the date field contains 2016-07-15.

Well, first, thanks for your answer!
I just tried to use the DateFormatter, which seemed exactly what I needed, as you pointed out.

So I wrote:

@\bibtextype{\bibtexkey,\begin{journal},
journal = {\journal}\end{journal}\begin{month},
month = \format[DateFormatter(MM)]{\date}\end{month}
}

But I get an error:

Text ‘2013-10’ could not be parsed at index 7

So I tried:

@\bibtextype{\bibtexkey,\begin{journal},
journal = {\journal}\end{journal}\begin{month},
month = \format[DateFormatter(MM)]{2013-10}\end{month}
}

And get the same error.
But if I write for example:

@\bibtextype{\bibtexkey,\begin{journal},
journal = {\journal}\end{journal}\begin{month},
month = \format[DateFormatter(MM)]{2013-10-01}\end{month}
}

It is working.

So, is it a bug or what?

Yes, that’s a limitation of the current implementation. It always expects a full ISO date https://github.com/JabRef/jabref/blob/master/src/main/java/org/jabref/logic/layout/format/DateFormatter.java#L15. Could you please open a bug report at https://github.com/JabRef/jabref/issues thanks!