It's not that simple but not that hard, either. Try this:
- insert the following script code after you include exhibit-api.js
<script>
var months = {
"jan": "01", "feb": "02", "mar": "03", "apr": "04", "may":
"05", "jun": "06", "jul": "07", "aug": "08", "sep": "09", "oct": "10",
"nov": "11", "dec": "12",
"january": "01", "february": "02", "march": "03", "april":
"04", "june": "06", "july": "07", "august": "08", "september": "09",
"october": "10", "november": "11", "december": "12",
};
Exhibit.Functions["bibtex-date"] = {
f: function(args) {
var results = new Exhibit.Set();
args[0].forEachValue(function(year) {
if (args[1].size == 0) {
try {
var d =
SimileAjax.DateTime.parseIso8601DateTime(year);
if (d != null) results.add(d);
} catch (e) {}
} else {
args[1].forEachValue(function(month) {
month = month.toLowerCase();
if (month in months) {
try {
var d =
SimileAjax.DateTime.parseIso8601DateTime(year + "-" + months[month] +
"-01");
if (d != null) results.add(d);
} catch (e) {}
}
});
}
});
return new Exhibit.Expression._Collection(results, "date");
}
};
</script>
- then specify ex:start="bibtex-date(.year, .month)"
David
Natsu wrote:
> Hello, I'm thinking of adding a timeline view to an Exhibit generated
> from a BibTex file. My question is about generating date format in-line.
>
> My JSON data is as follows:
> {"items":[
> {"id":"Some paper",
> "author":["John, E.B.","Jane, M. V."],
> "year":"2007",
> "month":"March"}
> ]}
>
> Then I would write the html code like this.
> <div ex:role="view"
> ex:viewClass="Timeline"
> ex:start="concat(.year, .month)">
>
> Do I need some helper function in javascript to do the date format
> conversion from the name of the month to number string?
> Or should I prepare the JSON date formatted using iso8601?
> ---
> Natsuhiko Mizutani
>
>
>
> _______________________________________________
> General mailing list
> [email protected]
> http://simile.mit.edu/mailman/listinfo/general
>
_______________________________________________
General mailing list
[email protected]
http://simile.mit.edu/mailman/listinfo/general