core/src/commands.cpp
changeset 7 184a1eb85cf2
parent 0 7f656887cf89
child 26 5d370dafea69
equal deleted inserted replaced
6:96d581d2147d 7:184a1eb85cf2
  2333 
  2333 
  2334 //
  2334 //
  2335 // CCmdDate.
  2335 // CCmdDate.
  2336 //
  2336 //
  2337 
  2337 
       
  2338 // Appearently kernel reckons to 365.2485 days per year between 0AD (nominal gregorian) and 2000AD, which comes to 730497 days in total.
       
  2339 // timeanddate.com agrees once you factor in Julian->Gregorian and assuming 0AD wasn't a leap year (it refuses to allow you to directly enter 0AD nominal Gregorian)
       
  2340 const TInt64 KY2kInMicroSeconds = 730497 * 24 * 60 * (TInt64)(60 * 1000 * 1000);
       
  2341 
  2338 CCommandBase* CCmdDate::NewLC()
  2342 CCommandBase* CCmdDate::NewLC()
  2339 	{
  2343 	{
  2340 	CCmdDate* self = new(ELeave) CCmdDate();
  2344 	CCmdDate* self = new(ELeave) CCmdDate();
  2341 	CleanupStack::PushL(self);
  2345 	CleanupStack::PushL(self);
  2342 	self->BaseConstructL();
  2346 	self->BaseConstructL();
  2354 
  2358 
  2355 void CCmdDate::Display(const TTime& aTime)
  2359 void CCmdDate::Display(const TTime& aTime)
  2356 	{
  2360 	{
  2357 	if (iRaw)
  2361 	if (iRaw)
  2358 		{
  2362 		{
  2359 		Printf(_L("%Ld\r\n"), aTime.Int64());
  2363 		TInt64 time = aTime.Int64();
       
  2364 		if (iUseKernelFormat) time += KY2kInMicroSeconds;
       
  2365 		Printf(_L("%Ld\r\n"), time);
  2360 		}
  2366 		}
  2361 	else if (iUseTimestampFormat)
  2367 	else if (iUseTimestampFormat)
  2362 		{
  2368 		{
  2363 		TDateTime dateTime(aTime.DateTime());
  2369 		TDateTime dateTime(aTime.DateTime());
  2364 		Printf(_L("%04d%02d%02d-%02d%02d.%02d"), dateTime.Year(), dateTime.Month() + 1, dateTime.Day() + 1, dateTime.Hour(), dateTime.Minute(), dateTime.Second());
  2370 		Printf(_L("%04d%02d%02d-%02d%02d.%02d"), dateTime.Year(), dateTime.Month() + 1, dateTime.Day() + 1, dateTime.Hour(), dateTime.Minute(), dateTime.Second());
  2410 		Display(time);
  2416 		Display(time);
  2411 		}
  2417 		}
  2412 	else
  2418 	else
  2413 		{
  2419 		{
  2414 		_LIT(KSettingError, "Cannot set the time");
  2420 		_LIT(KSettingError, "Cannot set the time");
       
  2421 		if (iUseKernelFormat) iRawTimeToSet -= KY2kInMicroSeconds;
  2415 		TTime time(iRawTimeToSet);
  2422 		TTime time(iRawTimeToSet);
  2416 		if (iDateToSet)
  2423 		if (iDateToSet)
  2417 			{
  2424 			{
  2418 			_LIT(KParsingTime, "Cannot parse time string");
  2425 			_LIT(KParsingTime, "Cannot parse time string");
  2419 			LeaveIfErr(time.Parse(*iDateToSet), KParsingTime);
  2426 			LeaveIfErr(time.Parse(*iDateToSet), KParsingTime);
  2467 	_LIT(KCmdDateOptSecure, "secure");
  2474 	_LIT(KCmdDateOptSecure, "secure");
  2468 #endif
  2475 #endif
  2469 	_LIT(KCmdDateOptRaw, "raw");
  2476 	_LIT(KCmdDateOptRaw, "raw");
  2470 	_LIT(KCmdDateOptJustDisplay, "just-display");
  2477 	_LIT(KCmdDateOptJustDisplay, "just-display");
  2471 	_LIT(KCmdDateOptSetRaw, "raw-set");
  2478 	_LIT(KCmdDateOptSetRaw, "raw-set");
  2472 	_LIT(KCmdDataOptTimestamp, "timestamp");
  2479 	_LIT(KCmdDateOptTimestamp, "timestamp");
       
  2480 	_LIT(KCmdDateOptKern, "kern");
  2473 
  2481 
  2474 	aOptions.AppendBoolL(iUniversalTime, KCmdDateOptUniversal);
  2482 	aOptions.AppendBoolL(iUniversalTime, KCmdDateOptUniversal);
  2475 	aOptions.AppendStringL(iDateToSet, KCmdDateOptSet);
  2483 	aOptions.AppendStringL(iDateToSet, KCmdDateOptSet);
  2476 	aOptions.AppendIntL(iUtcOffset, KCmdDateOptUtcOffset);
  2484 	aOptions.AppendIntL(iUtcOffset, KCmdDateOptUtcOffset);
  2477 #ifdef FSHELL_CORE_SUPPORT_SECURE_TIME
  2485 #ifdef FSHELL_CORE_SUPPORT_SECURE_TIME
  2478 	aOptions.AppendBoolL(iSecure, KCmdDateOptSecure);
  2486 	aOptions.AppendBoolL(iSecure, KCmdDateOptSecure);
  2479 #endif
  2487 #endif
  2480 	aOptions.AppendBoolL(iRaw, KCmdDateOptRaw);
  2488 	aOptions.AppendBoolL(iRaw, KCmdDateOptRaw);
  2481 	aOptions.AppendBoolL(iJustDisplay, KCmdDateOptJustDisplay);
  2489 	aOptions.AppendBoolL(iJustDisplay, KCmdDateOptJustDisplay);
  2482 	aOptions.AppendIntL(iRawTimeToSet, KCmdDateOptSetRaw);
  2490 	aOptions.AppendIntL(iRawTimeToSet, KCmdDateOptSetRaw);
  2483 	aOptions.AppendBoolL(iUseTimestampFormat, KCmdDataOptTimestamp);
  2491 	aOptions.AppendBoolL(iUseTimestampFormat, KCmdDateOptTimestamp);
       
  2492 	aOptions.AppendBoolL(iUseKernelFormat, KCmdDateOptKern);
  2484 	}
  2493 	}
  2485 
  2494 
  2486 
  2495 
  2487 //
  2496 //
  2488 // CCmdFsck.
  2497 // CCmdFsck.