#! /usr/bin/env python import string import re import thing import notation3 # N3 parsers and generators, and RDF generator import isodate from thing import * LITERAL_URI_prefix = "data:application/n3;" DATE_NS_URI = "http://www.mnot.net/2002/01/11/date#" __version__ = "0.2" class BI_inSeconds(LightBuiltIn, Function, ReverseFunction): def evaluateObject(self, store, context, subj, subj_py): try: return store._fromPython(context, str(isodate.parse(subj_py))) except: return None # Register the string built-ins with the store def register(store): str = store.internURI(DATE_NS_URI[:-1]) str.internFrag("inSeconds", BI_inSeconds)