• Do not register here on develop.twiki.org, login with your twiki.org account.
• Use View topic Item7848 for generic doc work for TWiki-6.1.1. Use View topic Item7851 for doc work on extensions that are not part of a release. More... Close
• Anything you create or change in standard webs (Main, TWiki, Sandbox etc) will be automatically reverted on every SVN update.
Does this site look broken?. Use the LitterTray web for test cases.

Item4164: TWiki::Time functions are self-inconsistent

Item Form Data

AppliesTo: Component: Priority: CurrentState: WaitingFor: TargetRelease ReleasedIn
Engine   Normal Closed   minor 4.2.0

Edit Form Data

Summary:
Reported By:
Codebase:
Applies To:
Component:
Priority:
Current State:
Waiting For:
Target Release:
Released In:
 

Detail

TWiki::formatTime can generate a time that cannot be parsed by TWiki::parseTime.

Example: TWiki::parseTime(TWiki::Time::formatTime(0))

This is urgent because these functions can used by plugins to populate meta-data in topics that then blows TWiki up when it is read again.

parseTime should always be able to parse times generated by formatTime when it is called without a format parameter.

-- TWiki:Main/CrawfordCurrie - 30 May 2007

This I do not understand

If the formatTime does not get any format the default is $TWiki::cfg{DefaultDateFormat} . ' - $hour:$min'

This format is always a format understood by parseTime because the $TWiki::cfg{DefaultDateFormat} only consists of a very short list of formats that parseTime should be able to decode.

When I added the new feature I also extended parseTime.

Did you test this or do you assume this fails?

I may have made a mistake in the regexes but I did add unit tests that all parse covering the new formats.

-- TWiki:Main.KennethLavrsen - 30 May 2007

I have checked more.

Your example is a bad one. When the function does not parse the time it returns 0.

But since your example tried with epoch the correct return value is 0

I tried to make a little quick plugin that just returns a value on a tag called %LAVR%

Here are some examples going further than just the default format. Using my wedding day as example (will also help me remembering it in future).

The expected result is same output as input. And additionally I am also testing the standard formats and testing all the formats that can be defined in the short list in $TWiki::cfg{DefaultDateFormat}. We agreed not to make $TWiki::cfg{DefaultDateFormat} fully flexible because this would complicate parseTime and it can never be made to understand all formats because exact same string can mean different things.

Test Result OK?
return TWiki::Time::parseTime(TWiki::Func::formatTime(60)); 60 DONE
return TWiki::Time::parseTime(TWiki::Func::formatTime(862617660)); 862617660 DONE
return TWiki::Time::parseTime(TWiki::Func::formatTime(862617660, '$iso')); 862617660 DONE
return TWiki::Time::parseTime(TWiki::Func::formatTime(862617660, '$rcs')); 862617660 DONE
return TWiki::Time::parseTime(TWiki::Func::formatTime(862617660, '$http')); 862617660 DONE
return TWiki::Time::parseTime(TWiki::Func::formatTime(862617660, '$year-$mo-$day - $hour:$min')); 862617660 DONE
return TWiki::Time::parseTime(TWiki::Func::formatTime(862617660, '$year/$mo/$day - $hour:$min')); 862617660 DONE
return TWiki::Time::parseTime(TWiki::Func::formatTime(862617660, '$year.$mo.$day - $hour:$min')); 862617660 DONE

All the formats you can select in configure for $TWiki::cfg{DefaultDateFormat} work. The predefined named formats also works.

return TWiki::Time::parseTime(TWiki::Func::formatTime(862617660, '$day $month $year')); 852076800 Becomes 01 Jan 1997
return TWiki::Time::parseTime(TWiki::Func::formatTime(862617660, '$year $mo $day')); 852076800 Becomes 01 Jan 1997

So the parseTime function could probably later be extended with additional formats without time part. But that is out of scope of this bug report.

I cannot see anything wrong here. I suspect it was raised on an assumption more than actually seeing it fail.

I have spent two hours on this one now. Enough. I am setting this to No Action Required.

-- TWiki:Main.KennethLavrsen - 30 May 2007

Reopening

It bugs me that the format "30 May 2007" is not understood and parsed as "30 May 2007 00:00"

So I have a quick fix ready for that. Then at least we got a little out of all my time smile

-- TWiki:Main.KennethLavrsen - 30 May 2007

Committed 13993. Closing. No need to put this in release note

-- TWiki:Main.KennethLavrsen - 30 May 2007

ItemTemplate
Summary TWiki::Time functions are self-inconsistent
ReportedBy TWiki:Main.CrawfordCurrie
Codebase

SVN Range TWiki-4.1.2, Fri, 18 May 2007, build 13796
AppliesTo Engine
Component

Priority Normal
CurrentState Closed
WaitingFor

Checkins TWikirev:13993
TargetRelease minor
ReleasedIn 4.2.0
Edit | Attach | Watch | Print version | History: r3 < r2 < r1 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r3 - 2007-05-30 - TWikiUserMapping_KennethLavrsen
 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2019 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback