Skip to content
New issue

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

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

Already on GitHub? # to your account

SIGSEGV in DateTime::format() #76

Open
dumblob opened this issue Sep 29, 2015 · 8 comments
Open

SIGSEGV in DateTime::format() #76

dumblob opened this issue Sep 29, 2015 · 8 comments

Comments

@dumblob
Copy link

dumblob commented Sep 29, 2015

dao -e 'load time import time; time.make(2015,9,29).format("%A")'

Btw it might make sense to slightly improve the declaration { TIME_Format2, "format(invar self: DateTime, invar names: map<string,list<string>>, format = '%Y-%M-%D, %H:%I:%S' ) => string" } by using enum: { TIME_Format2, "format(invar self: DateTime, invar names: map<enum<month, week, day, halfday>,list<string>>, format = '%Y-%M-%D, %H:%I:%S' ) => string" }

@dumblob
Copy link
Author

dumblob commented Sep 29, 2015

Also, the TIME_Format2 doesn't seem to work properly:

0$ dao -e 'load time import time; time.make(2015,9,29).format({ "month" => {"le", "un", "br", "du", "kv", "ce", "cec", "sr", "za", "ri", "li", "pr" }, "week" => {"po", "ut", "st", "ct", "pa", "so", "ne"} }, "%a %b %Y")'
= am  2015
0$ dao -e 'load time import time; time.make(2015,9,29).format({ "month" => {"le", "un", "br", "du", "kv", "ce", "cec", "sr", "za", "ri", "li", "pr" }, "week" => {"po", "ut", "st", "ct", "pa", "so", "ne"} }, "%A %B %Y")'
= AM  2015

@Night-walker
Copy link
Collaborator

I would actually either remove the function -- it looks too heavy -- or replace it with something else.

@dumblob
Copy link
Author

dumblob commented Sep 29, 2015

I would actually either remove the function -- it looks too heavy -- or replace it with something else.

I'm not against under the condition, that the new solution will support arbitrary months, weekdays, yeardays and halfdays labeling.

@Night-walker
Copy link
Collaborator

I think it is not required for basic date and time support and is implemented trivially on the user's side.

@dumblob
Copy link
Author

dumblob commented Sep 29, 2015

I think it is not required for basic date and time support and is implemented trivially on the user's side.

The easiest option is to parse the output of format() (to get the index of day_in_month/day_in_week/day_in_year/halfday_of_day), which is pretty inefficient. Or am I missing something?

@Night-walker
Copy link
Collaborator

The easiest option is to parse the output of format() (to get the index of day_in_month/day_in_week/day_in_year/halfday_of_day), which is pretty inefficient. Or am I missing something?

Why, if that info can be fetched directly from the DateTime methods?

@dumblob
Copy link
Author

dumblob commented Sep 29, 2015

Why, if that info can be fetched directly from the DateTime methods?

Shame on me, I missed weekDay() and yearDay() methods. Writing

listWeekDay[x.weekDay()] + x.format(' %d.') + listYearMonth[x.month] + x.format(' %Y ' + translation['at'].replace('%', '%%') + ' %h:%m:%s')

instead of

x.format('%A %d. %B %Y ' + translation['at'].replace('%', '%%') + ' %h:%m:%s', {$weekday => listWeekDay, $yearmonth => listYearMonth})

is less efficient, but is maybe even slightly more readable than the latter one.

@daokoder
Copy link
Owner

I would actually either remove the function -- it looks too heavy -- or replace it with something else.

I think it is not required for basic date and time support and is implemented trivially on the user's side.

Agree.

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

No branches or pull requests

3 participants