Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to not parse date-looking-strings as dates, but as strings? #161

Closed
coolaj86 opened this issue Feb 3, 2015 · 3 comments
Closed

how to not parse date-looking-strings as dates, but as strings? #161

coolaj86 opened this issue Feb 3, 2015 · 3 comments

Comments

@coolaj86
Copy link

coolaj86 commented Feb 3, 2015

Is there a way to turn off the datetime parsing?

I have a bunch of date and time strings, but they're meant for literal presentation as strings, not for interpretation as date objects.

@dervus
Copy link
Collaborator

dervus commented Feb 3, 2015

There are two ways.

var SCHEMA = yaml.Schema.create(yaml.CORE_SCHEMA, [ /* additional types */ ])

@dervus dervus closed this as completed Feb 3, 2015
@coolaj86
Copy link
Author

coolaj86 commented Feb 3, 2015

For reference, I was able to get it working like this:

var YAML = (window.jsyaml || require('js-yaml'))
  , schema
  ;

schema = YAML.Schema.create(YAML.CORE_SCHEMA, []);
YAML.load('date: 2006-03-06 06:38:00 -07:00', { schema: schema });

@ixti
Copy link
Contributor

ixti commented Feb 3, 2015

My two cents. IMHO strings in YAML should be strings. If you need to have something that might be interpreted as non-string but you need it to be string, either explicitly set type, or implicitly (use quotes):

---
explicit: !!str 2015-02-03
implicit: "2015-02-03"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants