Click here to Skip to main content
6,292,426 members and growing! (9,524 online)
Email Password   helpLost your password?
General Programming » Date and Time » Tools     Beginner License: The Code Project Open License (CPOL)

Seagate Date Code Calculator

By Paw Jershauge

How to get the date 20 November 2005 from the number 06212.
C# (C# 2.0).NET 2.0, Win2K, WinXP, Win2003, VistaVS2005, Dev
Version:2 (See All)
Posted:6 Aug 2007
Views:22,392
Bookmarked:12 times
Announcements
Loading...
 
Search    
Advanced Search
printPrint   Broken Article?Report       add Share
  Discuss Discuss   Recommend Article Email
7 votes for this article.
Popularity: 3.49 Rating: 4.13 out of 5
1 vote, 14.3%
1

2

3
4 votes, 57.1%
4
2 votes, 28.6%
5

Screenshot - SeagateDateCode.jpg

Introduction

The code described in this article helps users convert Seagate's (the hard drive manufacture) date code to a DateTime value.

This article is based on this documentation.

Background

I had to check some hard drives for warranty, and found myself checking very old hard drives.

The code

Here is the actual code invloved:

Class variables

private DateTime datecalc;
private string _datecode;

Class properties

public string DateCode
{
    get { return _datecode; }
    set 
    {
        int _CodeYear = 0;
        byte _CodeWeek = 0;
        byte _CodeDayOfWeek = 0;
        _datecode = value;
        if (_datecode.Length == 5)
        {
            //Get the number of weeks to add
            _CodeWeek = Convert.ToByte(_datecode.Substring(2, 2));
            //Get the day of the week in the final week
            _CodeDayOfWeek = Convert.ToByte(_datecode.Substring(4));
        }
        else if (_datecode.Length == 4)
        {
            //Get the number of weeks to add
            _CodeWeek = Convert.ToByte(_datecode.Substring(2, 1));
            //Get the day of the week in the final week
            _CodeDayOfWeek = Convert.ToByte(_datecode.Substring(3));
        }
        if (_datecode.Length == 4 || _datecode.Length == 5)
        {
            _CodeWeek--;
            _CodeDayOfWeek--;
            _CodeYear = (2000 + Convert.ToInt32(_datecode.Substring(0, 2)) - 1);
            datecalc = new DateTime(_CodeYear, 7, 1);
            datecalc.AddDays(-1);
            do { datecalc = datecalc.AddDays(1); } 
            while (datecalc.DayOfWeek != DayOfWeek.Saturday);
            datecalc = datecalc.AddDays((_CodeWeek * 7) + _CodeDayOfWeek);
        }
    }
}

public DateTime CalculatedDate
{
    get { return datecalc; }
}

Class constructors

public SeagateDateCodeCalc()
{

}
public SeagateDateCodeCalc(string dateCode)
{
    this.DateCode = dateCode;
}

History

This is my first submission here, so let me know if I am missing anything.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

Paw Jershauge


Member
An Code Generator, for making SQL table into .Net Classses (2nd place in the Code Generation 2008 Competition)
A Class for getting the Rss feed list of a website
Seagate Date Code Calculator
DNSBL lookup Class
Base N converter (N = 10-62)
Lightweight Directory Access Protocol Uniform resource identifier (LDAPUri)
LoginHours from DirectoryEntry into boolean array
Occupation: Software Developer
Location: Denmark Denmark

Other popular Date and Time articles:

Article Top
You must Sign In to use this message board.
FAQ FAQ 
 
Noise Tolerance  Layout  Per page   
 Msgs 1 to 8 of 8 (Total in Forum: 8) (Refresh)FirstPrevNext
GeneralRunning the prog Pinmembergimmegimme12:00 8 Oct '08  
GeneralRe: Running the prog PinmemberPaw Jershauge3:42 9 Oct '08  
GeneralRe: Running the prog Pinmembericefloe015:37 8 Jan '09  
GeneralRe: Running the prog PinmemberPaw Jershauge11:14 8 Jan '09  
GeneralRe: Running the prog Pinmembericefloe0112:40 8 Jan '09  
GeneralRe: Running the prog PinmemberKnight of Cydonia13:37 11 Jan '09  
GeneralRe: Running the prog PinmemberPaw Jershauge0:47 12 Jan '09  
GeneralRe: Running the prog PinmemberKnight of Cydonia9:29 12 Jan '09  

General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

PermaLink | Privacy | Terms of Use
Last Updated: 6 Aug 2007
Editor: Smitha Vijayan
Copyright 2007 by Paw Jershauge
Everything else Copyright © CodeProject, 1999-2009
Web11 | Advertise on the Code Project